Skip to content

Commit

Permalink
Change invoke call to always use latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed Feb 11, 2020
1 parent 5714a10 commit bfbf679
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## HEAD (Unreleased)

### Bug fixes

- Change invoke call to always use latest version. (https://github.com/pulumi/pulumi-kubernetes/pull/987).

## 1.5.2 (February 10, 2020)

### Improvements
Expand Down
13 changes: 3 additions & 10 deletions pkg/gen/nodejs-templates/helm/v2/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class Chart extends yaml.CollectionComponentResource {
},
).toString();
return this.parseTemplate(
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace, opts);
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace);
} catch (e) {
// Shed stack trace, only emit the error.
throw new pulumi.RunError(e.toString());
Expand All @@ -236,20 +236,13 @@ export class Chart extends yaml.CollectionComponentResource {
resourcePrefix: string | undefined,
dependsOn: pulumi.Resource[],
defaultNamespace: string | undefined,
opts?: pulumi.ComponentResourceOptions,
): pulumi.Output<{ [key: string]: pulumi.CustomResource }> {
// Rather than using the default provider for the following invoke call, determine the
// provider from the parent if specified, or fallback to using the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = {async: true};
if (opts?.parent) {
invokeOpts = {...invokeOpts, parent: opts.parent};
} else {
invokeOpts = {...invokeOpts, version: getVersion()};
}
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };

const promise = pulumi.runtime.invoke(
"kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts);
const promise = pulumi.runtime.invoke("kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts);
return pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse(
{
resourcePrefix: resourcePrefix,
Expand Down
13 changes: 4 additions & 9 deletions pkg/gen/nodejs-templates/yaml.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,11 @@ import * as outputs from "../types/output";
resourcePrefix?: string;
}

function yamlLoadAll(text: string, opts?: pulumi.CustomResourceOptions): Promise<any[]> {
function yamlLoadAll(text: string): Promise<any[]> {
// Rather than using the default provider for the following invoke call, determine the
// provider from the parent if specified, or fallback to using the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = {async: true};
if (opts?.parent) {
invokeOpts = {...invokeOpts, parent: opts.parent};
} else {
invokeOpts = {...invokeOpts, version: getVersion()};
}
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };

return pulumi.runtime.invoke("kubernetes:yaml:decode", {text}, invokeOpts)
.then((p => p.result));
Expand Down Expand Up @@ -183,7 +178,7 @@ import * as outputs from "../types/output";

for (const text of yamlTexts) {
const docResources = parseYamlDocument({
objs: yamlLoadAll(text, opts),
objs: yamlLoadAll(text),
transformations: config.transformations,
resourcePrefix: config.resourcePrefix
},
Expand Down Expand Up @@ -331,7 +326,7 @@ import * as outputs from "../types/output";
this.resources = pulumi.output(text.then(t => {
try {
return parseYamlDocument({
objs: yamlLoadAll(t, opts),
objs: yamlLoadAll(t),
transformations: config && config.transformations || [],
resourcePrefix: config && config.resourcePrefix || undefined
}, {parent: this})
Expand Down
6 changes: 1 addition & 5 deletions pkg/gen/python-templates/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi
# Rather than using the default provider for the following invoke call, determine the
# provider from the parent if specified, or fallback to using the version specified
# in package.json.
invoke_opts = pulumi.InvokeOptions()
if opts.parent is not None:
invoke_opts.parent = opts.parent
else:
invoke_opts.version = get_version()
invoke_opts = pulumi.InvokeOptions(version=get_version())

objects = chart_resources.apply(
lambda text: pulumi.runtime.invoke('kubernetes:yaml:decode', {
Expand Down
6 changes: 1 addition & 5 deletions pkg/gen/python-templates/yaml.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ class ConfigFile(pulumi.ComponentResource):
# Rather than using the default provider for the following invoke call, determine the
# provider from the parent if specified, or fallback to using the version specified
# in package.json.
invoke_opts = pulumi.InvokeOptions()
if opts.parent is not None:
invoke_opts.parent = opts.parent
else:
invoke_opts.version = get_version()
invoke_opts = pulumi.InvokeOptions(version=get_version())

__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']

Expand Down
13 changes: 3 additions & 10 deletions sdk/nodejs/helm/v2/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class Chart extends yaml.CollectionComponentResource {
},
).toString();
return this.parseTemplate(
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace, opts);
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace);
} catch (e) {
// Shed stack trace, only emit the error.
throw new pulumi.RunError(e.toString());
Expand All @@ -236,20 +236,13 @@ export class Chart extends yaml.CollectionComponentResource {
resourcePrefix: string | undefined,
dependsOn: pulumi.Resource[],
defaultNamespace: string | undefined,
opts?: pulumi.ComponentResourceOptions,
): pulumi.Output<{ [key: string]: pulumi.CustomResource }> {
// Rather than using the default provider for the following invoke call, determine the
// provider from the parent if specified, or fallback to using the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = {async: true};
if (opts?.parent) {
invokeOpts = {...invokeOpts, parent: opts.parent};
} else {
invokeOpts = {...invokeOpts, version: getVersion()};
}
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };

const promise = pulumi.runtime.invoke(
"kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts);
const promise = pulumi.runtime.invoke("kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts);
return pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse(
{
resourcePrefix: resourcePrefix,
Expand Down
13 changes: 4 additions & 9 deletions sdk/nodejs/yaml/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,11 @@ import * as outputs from "../types/output";
resourcePrefix?: string;
}

function yamlLoadAll(text: string, opts?: pulumi.CustomResourceOptions): Promise<any[]> {
function yamlLoadAll(text: string): Promise<any[]> {
// Rather than using the default provider for the following invoke call, determine the
// provider from the parent if specified, or fallback to using the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = {async: true};
if (opts?.parent) {
invokeOpts = {...invokeOpts, parent: opts.parent};
} else {
invokeOpts = {...invokeOpts, version: getVersion()};
}
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };

return pulumi.runtime.invoke("kubernetes:yaml:decode", {text}, invokeOpts)
.then((p => p.result));
Expand Down Expand Up @@ -183,7 +178,7 @@ import * as outputs from "../types/output";

for (const text of yamlTexts) {
const docResources = parseYamlDocument({
objs: yamlLoadAll(text, opts),
objs: yamlLoadAll(text),
transformations: config.transformations,
resourcePrefix: config.resourcePrefix
},
Expand Down Expand Up @@ -2473,7 +2468,7 @@ import * as outputs from "../types/output";
this.resources = pulumi.output(text.then(t => {
try {
return parseYamlDocument({
objs: yamlLoadAll(t, opts),
objs: yamlLoadAll(t),
transformations: config && config.transformations || [],
resourcePrefix: config && config.resourcePrefix || undefined
}, {parent: this})
Expand Down
6 changes: 1 addition & 5 deletions sdk/python/pulumi_kubernetes/helm/v2/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,7 @@ def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi
# Rather than using the default provider for the following invoke call, determine the
# provider from the parent if specified, or fallback to using the version specified
# in package.json.
invoke_opts = pulumi.InvokeOptions()
if opts.parent is not None:
invoke_opts.parent = opts.parent
else:
invoke_opts.version = get_version()
invoke_opts = pulumi.InvokeOptions(version=get_version())

objects = chart_resources.apply(
lambda text: pulumi.runtime.invoke('kubernetes:yaml:decode', {
Expand Down
6 changes: 1 addition & 5 deletions sdk/python/pulumi_kubernetes/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ def __init__(self, name, file_id, opts=None, transformations=None, resource_pref
# Rather than using the default provider for the following invoke call, determine the
# provider from the parent if specified, or fallback to using the version specified
# in package.json.
invoke_opts = pulumi.InvokeOptions()
if opts.parent is not None:
invoke_opts.parent = opts.parent
else:
invoke_opts.version = get_version()
invoke_opts = pulumi.InvokeOptions(version=get_version())

__ret__ = pulumi.runtime.invoke('kubernetes:yaml:decode', {'text': text}, invoke_opts).value['result']

Expand Down

0 comments on commit bfbf679

Please sign in to comment.