From 2cda20ad7d5a60f033b663770ea42b5039f85f1b Mon Sep 17 00:00:00 2001 From: Bryce Lampe Date: Thu, 26 May 2022 23:01:01 -0700 Subject: [PATCH] [TS] Pass provider to yaml resources --- CHANGELOG.md | 4 ++-- sdk/nodejs/helm/v2/helm.ts | 7 ++++--- sdk/nodejs/helm/v3/helm.ts | 2 +- sdk/nodejs/kustomize/kustomize.ts | 4 ++-- sdk/nodejs/yaml/yaml.ts | 12 ++++++------ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8d1c8f65..50a06f09fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## Unreleased -(None) +- Pass provider options to yaml invokes in TS ## 3.19.2 (May 25, 2022) @@ -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) diff --git a/sdk/nodejs/helm/v2/helm.ts b/sdk/nodejs/helm/v2/helm.ts index c0e467aa22..5fda87a795 100644 --- a/sdk/nodejs/helm/v2/helm.ts +++ b/sdk/nodejs/helm/v2/helm.ts @@ -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()); @@ -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( @@ -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 } )); } } diff --git a/sdk/nodejs/helm/v3/helm.ts b/sdk/nodejs/helm/v3/helm.ts index 83df6cf27c..91cdaffce8 100644 --- a/sdk/nodejs/helm/v3/helm.ts +++ b/sdk/nodejs/helm/v3/helm.ts @@ -240,7 +240,7 @@ export class Chart extends yaml.CollectionComponentResource { objs: p.result, transformations, }, - {parent: this} + { parent: this, provider: opts?.provider } )); } } diff --git a/sdk/nodejs/kustomize/kustomize.ts b/sdk/nodejs/kustomize/kustomize.ts index f9d8b9d51a..1fc3467c00 100644 --- a/sdk/nodejs/kustomize/kustomize.ts +++ b/sdk/nodejs/kustomize/kustomize.ts @@ -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( @@ -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 } )); } } diff --git a/sdk/nodejs/yaml/yaml.ts b/sdk/nodejs/yaml/yaml.ts index c4cd7c8073..57b52dafc7 100644 --- a/sdk/nodejs/yaml/yaml.ts +++ b/sdk/nodejs/yaml/yaml.ts @@ -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 }); } } @@ -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}`); } @@ -2889,10 +2889,10 @@ export interface ConfigOpts { resourcePrefix?: string; } -/** @ignore */ function yamlLoadAll(text: string): Promise { +/** @ignore */ function yamlLoadAll(text: string, opts?: pulumi.ComponentResourceOptions): Promise { // 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)); @@ -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 },