Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HELM_HOME as default if set #855

Merged
merged 2 commits into from
Dec 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Improvements

- Use HELM_HOME as default if set. (https://github.com/pulumi/pulumi-kubernetes/pull/855).
- Use `namespace` provided by `KUBECONFIG`, if it is not explicitly set in the provider (https://github.com/pulumi/pulumi-kubernetes/pull/903).

## 1.3.3 (November 29, 2019)
Expand Down
17 changes: 15 additions & 2 deletions pkg/gen/nodejs-templates/helm/v2/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,16 @@ export class Chart extends yaml.CollectionComponentResource {
const namespaceArg = cfg.namespace
? `--namespace ${shell.quote([cfg.namespace])}`
: "";
let cmd = `helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${namespaceArg}`;

// Use the HELM_HOME environment variable value if set.
const home = process.env.HELM_HOME || undefined;
if (home !== undefined) {
cmd += ` --home ${path.quotePath(home)}`;
}

const yamlStream = execSync(
`helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${namespaceArg}`,
cmd,
{
maxBuffer: 512 * 1024 * 1024 // 512 MB
},
Expand Down Expand Up @@ -394,7 +402,12 @@ export function fetch(chart: string, opts?: ResolvedFetchOpts) {
// Untar by default.
if(opts.untar !== false) { flags.push(`--untar`); }

// For arguments that are not paths to files, it is sufficent to use shell.quote to quote the arguments.
// Fallback to using the HELM_HOME environment variable if opts.home is not set.
if (!opts.home) {
opts.home = process.env.HELM_HOME || undefined;
}

// For arguments that are not paths to files, it is sufficient to use shell.quote to quote the arguments.
// However, for arguments that are actual paths to files we use path.quotePath (note that path here is
// not the node path builtin module). This ensures proper escaping of paths on Windows.
if (opts.version !== undefined) { flags.push(`--version ${shell.quote([opts.version])}`); }
Expand Down
11 changes: 9 additions & 2 deletions pkg/gen/python-templates/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,14 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi

namespace_arg = ['--namespace', config.namespace] if config.namespace else []

home = os.environ.get('HELM_HOME')
home_arg = ['--home', home] if home else []

# Use 'helm template' to create a combined YAML manifest.
cmd = ['helm', 'template', chart, '--name-template', release_name,
'--values', default_values, '--values', overrides_filename]
cmd.extend(namespace_arg)
cmd.extend(home_arg)

chart_resources = pulumi.Output.all(cmd, data).apply(_run_helm_cmd)

Expand All @@ -360,6 +364,11 @@ def _fetch(chart: str, opts: FetchOpts) -> None:
if opts.untar is not False:
cmd.append('--untar')

if opts.home:
cmd.extend(['--home', opts.home])
elif os.environ.get('HELM_HOME'):
cmd.extend(['--home', os.environ.get('HELM_HOME')])

if opts.version:
cmd.extend(['--version', opts.version])
if opts.ca_file:
Expand All @@ -380,8 +389,6 @@ def _fetch(chart: str, opts: FetchOpts) -> None:
cmd.extend(['--untardir', opts.untar_dir])
if opts.username:
cmd.extend(['--username', opts.username])
if opts.home:
cmd.extend(['--home', opts.home])
if opts.devel:
cmd.append('--devel')
if opts.prov:
Expand Down
17 changes: 15 additions & 2 deletions sdk/nodejs/helm/v2/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,16 @@ export class Chart extends yaml.CollectionComponentResource {
const namespaceArg = cfg.namespace
? `--namespace ${shell.quote([cfg.namespace])}`
: "";
let cmd = `helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${namespaceArg}`;

// Use the HELM_HOME environment variable value if set.
const home = process.env.HELM_HOME || undefined;
if (home !== undefined) {
cmd += ` --home ${path.quotePath(home)}`;
}

const yamlStream = execSync(
`helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${namespaceArg}`,
cmd,
{
maxBuffer: 512 * 1024 * 1024 // 512 MB
},
Expand Down Expand Up @@ -394,7 +402,12 @@ export function fetch(chart: string, opts?: ResolvedFetchOpts) {
// Untar by default.
if(opts.untar !== false) { flags.push(`--untar`); }

// For arguments that are not paths to files, it is sufficent to use shell.quote to quote the arguments.
// Fallback to using the HELM_HOME environment variable if opts.home is not set.
if (!opts.home) {
opts.home = process.env.HELM_HOME || undefined;
}

// For arguments that are not paths to files, it is sufficient to use shell.quote to quote the arguments.
// However, for arguments that are actual paths to files we use path.quotePath (note that path here is
// not the node path builtin module). This ensures proper escaping of paths on Windows.
if (opts.version !== undefined) { flags.push(`--version ${shell.quote([opts.version])}`); }
Expand Down
11 changes: 9 additions & 2 deletions sdk/python/pulumi_kubernetes/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,14 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi

namespace_arg = ['--namespace', config.namespace] if config.namespace else []

home = os.environ.get('HELM_HOME')
home_arg = ['--home', home] if home else []

# Use 'helm template' to create a combined YAML manifest.
cmd = ['helm', 'template', chart, '--name-template', release_name,
'--values', default_values, '--values', overrides_filename]
cmd.extend(namespace_arg)
cmd.extend(home_arg)

chart_resources = pulumi.Output.all(cmd, data).apply(_run_helm_cmd)

Expand All @@ -360,6 +364,11 @@ def _fetch(chart: str, opts: FetchOpts) -> None:
if opts.untar is not False:
cmd.append('--untar')

if opts.home:
cmd.extend(['--home', opts.home])
elif os.environ.get('HELM_HOME'):
cmd.extend(['--home', os.environ.get('HELM_HOME')])

if opts.version:
cmd.extend(['--version', opts.version])
if opts.ca_file:
Expand All @@ -380,8 +389,6 @@ def _fetch(chart: str, opts: FetchOpts) -> None:
cmd.extend(['--untardir', opts.untar_dir])
if opts.username:
cmd.extend(['--username', opts.username])
if opts.home:
cmd.extend(['--home', opts.home])
if opts.devel:
cmd.append('--devel')
if opts.prov:
Expand Down