Skip to content

Commit

Permalink
Allow .get with first-class providers
Browse files Browse the repository at this point in the history
Fixes #314.
  • Loading branch information
hausdorff committed Jan 7, 2019
1 parent d4f8be4 commit ddcc953
Show file tree
Hide file tree
Showing 4 changed files with 551 additions and 364 deletions.
2 changes: 1 addition & 1 deletion pkg/gen/nodejs-templates/package.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsc"
},
"dependencies": {
"@pulumi/pulumi": "^0.16.3",
"@pulumi/pulumi": "^0.16.9",
"@types/js-yaml": "^3.11.2",
"js-yaml": "^3.12.0",
"shell-quote": "^1.6.1",
Expand Down
13 changes: 9 additions & 4 deletions pkg/gen/nodejs-templates/provider.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export namespace apiextensions {
* CustomResourceGetOptions uniquely identifies a Kubernetes CustomResource, primarily for use
* in supplied to `apiextensions.CustomResource#get`.
*/
export interface CustomResourceGetOptions {
export interface CustomResourceGetOptions extends pulumi.CustomResourceOptions {
/**
* apiVersion is the API version of the apiExtensions.CustomResource we wish to select,
* as specified by the CustomResourceDefinition that defines it on the API server.
Expand Down Expand Up @@ -407,7 +407,11 @@ export namespace apiextensions {
* @param opts Uniquely specifies a CustomResource to select.
*/
public static get(name: string, opts: CustomResourceGetOptions): CustomResource {
return new CustomResource(name, {apiVersion: opts.apiVersion, kind: opts.kind}, { id: opts.id });
// NOTE: `selectOpts` will be type `pulumi.CustomResource`. If we add a field that does
// not satisfy that interface, it will cause a compilation error in `...selectOpts` in
// the constructor call below.
const {apiVersion, kind, id, ...selectOpts} = opts;
return new CustomResource(name, {apiVersion: apiVersion, kind: kind}, { ...selectOpts, id: id });
}

public getInputs(): CustomResourceArgs { return this.__inputs; }
Expand Down Expand Up @@ -498,9 +502,10 @@ export namespace {{Group}} {
* @param name _Unique_ name used to register this resource with Pulumi.
* @param id An ID for the Kubernetes resource to retrive. Takes the form
* <namespace>/<name> or <name>.
* @param opts Uniquely specifies a CustomResource to select.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>): {{Kind}} {
return new {{Kind}}(name, undefined, { id: id });
public static get(name: string, id: pulumi.Input<pulumi.ID>, opts?: pulumi.CustomResourceOptions): {{Kind}} {
return new {{Kind}}(name, undefined, { ...opts, id: id });
}

public getInputs(): inputApi.{{Group}}.{{Version}}.{{Kind}} { return this.__inputs; }
Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsc"
},
"dependencies": {
"@pulumi/pulumi": "^0.16.3",
"@pulumi/pulumi": "^0.16.9",
"@types/js-yaml": "^3.11.2",
"js-yaml": "^3.12.0",
"shell-quote": "^1.6.1",
Expand Down
Loading

0 comments on commit ddcc953

Please sign in to comment.