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

[TS] Pass provider to yaml resources #1996

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Unreleased
(None)
- Pass provider options to yaml invokes in TS

## 3.19.2 (May 25, 2022)

Expand Down Expand Up @@ -96,7 +96,7 @@ Note: The `kubernetes:storage.k8s.io/v1alpha1:CSIStorageCapacity` API was remove

- Helm Release: Helm Release imports support (https://github.com/pulumi/pulumi-kubernetes/pull/1818)
- Helm Release: fix username fetch option (https://github.com/pulumi/pulumi-kubernetes/pull/1824)
- Helm Release: Use URN name as base for autonaming, Drop warning, fix default value for
- Helm Release: Use URN name as base for autonaming, Drop warning, fix default value for
keyring (https://github.com/pulumi/pulumi-kubernetes/pull/1826)
- Helm Release: Add support for loading values from yaml files (https://github.com/pulumi/pulumi-kubernetes/pull/1828)

Expand Down
7 changes: 4 additions & 3 deletions sdk/nodejs/helm/v2/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class Chart extends yaml.CollectionComponentResource {
},
).toString();
return this.parseTemplate(
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace);
yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace, opts);
} catch (e: any) {
// Shed stack trace, only emit the error.
throw new pulumi.RunError(e.toString());
Expand All @@ -269,10 +269,11 @@ 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, use the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion(), provider: opts?.provider };

const promise = pulumi.runtime.invoke("kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts);
return pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse(
Expand All @@ -281,7 +282,7 @@ export class Chart extends yaml.CollectionComponentResource {
objs: p.result,
transformations: transformations || [],
},
{ parent: this, dependsOn: dependsOn }
{ parent: this, dependsOn: dependsOn, provider: opts?.provider }
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/helm/v3/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class Chart extends yaml.CollectionComponentResource {
objs: p.result,
transformations,
},
{parent: this}
{ parent: this, provider: opts?.provider }
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/kustomize/kustomize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Directory extends yaml.CollectionComponentResource {

// Rather than using the default provider for the following invoke call, use the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion(), provider: opts?.provider };

const promise = pulumi.runtime.invoke("kubernetes:kustomize:directory", {directory}, invokeOpts);
this.resources = pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse(
Expand All @@ -107,7 +107,7 @@ export class Directory extends yaml.CollectionComponentResource {
objs: p.result,
transformations: config.transformations || [],
},
{ parent: this, dependsOn: opts?.dependsOn }
{ parent: this, dependsOn: opts?.dependsOn, provider: opts?.provider }
));
}
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/nodejs/yaml/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2717,7 +2717,7 @@ export class ConfigGroup extends CollectionComponentResource {
*/
constructor(name: string, config: ConfigGroupOpts, opts?: pulumi.ComponentResourceOptions) {
super("kubernetes:yaml:ConfigGroup", name, config, opts);
this.resources = parse(config, {parent: this});
this.resources = parse(config, { parent: this, provider: opts?.provider });
}
}

Expand Down Expand Up @@ -2809,10 +2809,10 @@ export class ConfigFile extends CollectionComponentResource {
this.resources = pulumi.output(text.then(t => {
try {
return parseYamlDocument({
objs: yamlLoadAll(t),
objs: yamlLoadAll(t, opts),
transformations,
resourcePrefix: config && config.resourcePrefix || undefined
}, {parent: this})
}, { parent: this, provider: opts?.provider })
} catch (e) {
throw Error(`Error fetching YAML file '${fileId}': ${e}`);
}
Expand Down Expand Up @@ -2889,10 +2889,10 @@ export interface ConfigOpts {
resourcePrefix?: string;
}

/** @ignore */ function yamlLoadAll(text: string): Promise<any[]> {
/** @ignore */ function yamlLoadAll(text: string, opts?: pulumi.ComponentResourceOptions): Promise<any[]> {
// Rather than using the default provider for the following invoke call, use the version specified
// in package.json.
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() };
let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion(), provider: opts?.provider };

return pulumi.runtime.invoke("kubernetes:yaml:decode", {text}, invokeOpts)
.then((p => p.result));
Expand Down Expand Up @@ -2958,7 +2958,7 @@ export interface ConfigOpts {

for (const text of yamlTexts) {
const docResources = parseYamlDocument({
objs: yamlLoadAll(text),
objs: yamlLoadAll(text, opts),
transformations,
resourcePrefix: config.resourcePrefix
},
Expand Down