From 394e95a945a98eaa98d57d56fb88efa7ced3989f Mon Sep 17 00:00:00 2001 From: Levi Blackstone Date: Mon, 29 Mar 2021 11:14:57 -0600 Subject: [PATCH] [sdk/ts] Update CustomResource to match current codegen The CustomResource is an overlay (not generated from schema), so we missed an upstream codegen change. Applying this fix manually to avoid mutating the opts structure. Related to https://github.com/pulumi/pulumi/issues/6293 --- CHANGELOG.md | 1 + .../apiextensions/customResource.ts | 23 +++++++++++-------- sdk/nodejs/apiextensions/customResource.ts | 23 +++++++++++-------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0170f159..c1472e02a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## HEAD (Unreleased) - Ensure using `PULUMI_KUBERNETES_MANAGED_BY_LABEL` doesn't cause diffs on further stack updates (https://github.com/pulumi/pulumi-kubernetes/pull/1508) +- [sdk/ts] Update CustomResource to match current codegen (https://github.com/pulumi/pulumi-kubernetes/pull/1510) ## 2.8.3 (March 17, 2021) diff --git a/provider/pkg/gen/nodejs-templates/apiextensions/customResource.ts b/provider/pkg/gen/nodejs-templates/apiextensions/customResource.ts index 663a1ed198..f06aa480d5 100755 --- a/provider/pkg/gen/nodejs-templates/apiextensions/customResource.ts +++ b/provider/pkg/gen/nodejs-templates/apiextensions/customResource.ts @@ -18,7 +18,7 @@ import * as pulumi from "@pulumi/pulumi" import * as inputs from "../types/input"; import * as outputs from "../types/output"; -import { getVersion } from "../utilities"; +import * as utilities from "../utilities"; /** * CustomResource represents an instance of a CustomResourceDefinition (CRD). For example, the @@ -74,18 +74,21 @@ export class CustomResource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: CustomResourceArgs, opts?: pulumi.CustomResourceOptions) { - const props: pulumi.Inputs = {}; - for (const key of Object.keys(args)) { - props[key] = (args as any)[key]; - } - - if (!opts) { - opts = {} + let inputs: pulumi.Inputs = {}; + opts = opts || {}; + if (!opts.id) { + for (const key of Object.keys(args)) { + inputs[key] = (args as any)[key]; + } + } else { + for (const key of Object.keys(args)) { + inputs[key] = undefined; + } } if (!opts.version) { - opts.version = getVersion(); + opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(`kubernetes:${args.apiVersion}:${args.kind}`, name, props, opts); + super(`kubernetes:${args.apiVersion}:${args.kind}`, name, inputs, opts); this.__inputs = args; } } diff --git a/sdk/nodejs/apiextensions/customResource.ts b/sdk/nodejs/apiextensions/customResource.ts index 663a1ed198..f06aa480d5 100644 --- a/sdk/nodejs/apiextensions/customResource.ts +++ b/sdk/nodejs/apiextensions/customResource.ts @@ -18,7 +18,7 @@ import * as pulumi from "@pulumi/pulumi" import * as inputs from "../types/input"; import * as outputs from "../types/output"; -import { getVersion } from "../utilities"; +import * as utilities from "../utilities"; /** * CustomResource represents an instance of a CustomResourceDefinition (CRD). For example, the @@ -74,18 +74,21 @@ export class CustomResource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: CustomResourceArgs, opts?: pulumi.CustomResourceOptions) { - const props: pulumi.Inputs = {}; - for (const key of Object.keys(args)) { - props[key] = (args as any)[key]; - } - - if (!opts) { - opts = {} + let inputs: pulumi.Inputs = {}; + opts = opts || {}; + if (!opts.id) { + for (const key of Object.keys(args)) { + inputs[key] = (args as any)[key]; + } + } else { + for (const key of Object.keys(args)) { + inputs[key] = undefined; + } } if (!opts.version) { - opts.version = getVersion(); + opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(`kubernetes:${args.apiVersion}:${args.kind}`, name, props, opts); + super(`kubernetes:${args.apiVersion}:${args.kind}`, name, inputs, opts); this.__inputs = args; } }