Skip to content

Commit

Permalink
Don't generate .status in input types
Browse files Browse the repository at this point in the history
Fixes #444.
  • Loading branch information
hausdorff committed Jul 16, 2019
1 parent 6e78ccf commit 236068c
Show file tree
Hide file tree
Showing 227 changed files with 335 additions and 563 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(https://github.com/pulumi/pulumi-kubernetes/pull/637).
- Allow `.metadata.namespace` to take `string | core.v1.Namespace` on all top-level API resources.
(https://github.com/pulumi/pulumi-kubernetes/pull/635)
- Don't populate `.status` in input types (https://github.com/pulumi/pulumi-kubernetes/pull/635).

## 0.25.2 (July 11, 2019)

Expand Down
8 changes: 6 additions & 2 deletions pkg/gen/nodejs-templates/kind.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
{{#Properties}}
{{#RequiredInputProperties}}
inputs["{{Name}}"] = {{{DefaultValue}}};
{{/Properties}}
{{/RequiredInputProperties}}

{{#OptionalInputProperties}}
inputs["{{Name}}"] = {{{DefaultValue}}};
{{/OptionalInputProperties}}

if (!opts) {
opts = {};
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/nodejs-templates/typesInput.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export namespace {{Group}} {
{{#Kinds}}
{{{Comment}}}
export interface {{Kind}} {
{{#RequiredProperties}}
{{#RequiredInputProperties}}
{{{Comment}}}
{{Name}}: {{{PropType}}}

{{/RequiredProperties}}
{{#OptionalProperties}}
{{/RequiredInputProperties}}
{{#OptionalInputProperties}}
{{{Comment}}}
{{Name}}?: {{{PropType}}}

{{/OptionalProperties}}
{{/OptionalInputProperties}}
}
{{{TypeGuard}}}

Expand Down
14 changes: 8 additions & 6 deletions pkg/gen/nodejs.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ func NodeJSClient(swagger map[string]interface{}, templateDir string,
}
kindts, err := mustache.RenderFile(fmt.Sprintf("%s/kind.ts.mustache", templateDir),
map[string]interface{}{
"Comment": kind.Comment(),
"Group": group.Group(),
"Kind": kind.Kind(),
"Properties": kind.Properties(),
"URNAPIVersion": kind.URNAPIVersion(),
"Version": version.Version(),
"Comment": kind.Comment(),
"Group": group.Group(),
"Kind": kind.Kind(),
"Properties": kind.Properties(),
"RequiredInputProperties": kind.RequiredInputProperties(),
"OptionalInputProperties": kind.OptionalInputProperties(),
"URNAPIVersion": kind.URNAPIVersion(),
"Version": version.Version(),
})
if err != nil {
return "", "", "", "", "", nil, err
Expand Down
8 changes: 4 additions & 4 deletions pkg/gen/python-templates/kind.py.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class {{Kind}}(pulumi.CustomResource):

__props__['apiVersion'] = '{{RawAPIVersion}}'
__props__['kind'] = '{{Kind}}'
{{#RequiredProperties}}
{{#RequiredInputProperties}}
if {{LanguageName}} is None:
raise TypeError('Missing required property {{LanguageName}}')
__props__['{{Name}}'] = {{LanguageName}}
{{/RequiredProperties}}
{{#OptionalProperties}}
{{/RequiredInputProperties}}
{{#OptionalInputProperties}}
__props__['{{Name}}'] = {{LanguageName}}
{{/OptionalProperties}}
{{/OptionalInputProperties}}

if __opts__ is None:
__opts__ = pulumi.ResourceOptions()
Expand Down
50 changes: 24 additions & 26 deletions pkg/gen/typegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ func (vc *VersionConfig) RawAPIVersion() string { return vc.rawAPIVersion }
// KindConfig represents a Kubernetes API kind (e.g., the `Deployment` type in
// `apps/v1beta1/Deployment`).
type KindConfig struct {
kind string
comment string
properties []*Property
requiredProperties []*Property
optionalProperties []*Property
kind string
comment string
properties []*Property
requiredInputProperties []*Property
optionalInputProperties []*Property

gvk *schema.GroupVersionKind // Used for sorting.
apiVersion string
Expand All @@ -147,15 +147,13 @@ func (kc *KindConfig) Comment() string { return kc.comment }
// that we will want to `.` into, like `thing.apiVersion`, `thing.kind`, `thing.metadata`, etc.).
func (kc *KindConfig) Properties() []*Property { return kc.properties }

// RequiredProperties returns the list of properties that are required to exist on some Kubernetes
// API kind (i.e., things that we will want to `.` into, like `thing.apiVersion`, `thing.kind`,
// `thing.metadata`, etc.).
func (kc *KindConfig) RequiredProperties() []*Property { return kc.requiredProperties }
// RequiredInputProperties returns the list of properties that are required input properties on some
// Kubernetes API kind (i.e., things that we will want to provide, like `thing.metadata`, etc.).
func (kc *KindConfig) RequiredInputProperties() []*Property { return kc.requiredInputProperties }

// OptionalProperties returns the list of properties that are optional on some Kubernetes API kind
// (i.e., things that we will want to `.` into, like `thing.apiVersion`, `thing.kind`,
// `thing.metadata`, etc.).
func (kc *KindConfig) OptionalProperties() []*Property { return kc.optionalProperties }
// OptionalInputProperties returns the list of properties that are optional input properties on some
// Kubernetes API kind (i.e., things that we will want to provide, like `thing.metadata`, etc.).
func (kc *KindConfig) OptionalInputProperties() []*Property { return kc.optionalInputProperties }

// APIVersion returns the fully-qualified apiVersion (e.g., `storage.k8s.io/v1` for storage, etc.)
func (kc *KindConfig) APIVersion() string { return kc.apiVersion }
Expand Down Expand Up @@ -643,19 +641,19 @@ func createGroups(definitionsJSON map[string]interface{}, opts groupOpts) []*Gro
}
}

requiredProperties := []*Property{}
requiredInputProperties := []*Property{}
ps.
WhereT(func(p *Property) bool {
return reqdProps.Has(p.name)
}).
ToSlice(&requiredProperties)
ToSlice(&requiredInputProperties)

optionalProperties := []*Property{}
optionalInputProperties := []*Property{}
ps.
WhereT(func(p *Property) bool {
return !reqdProps.Has(p.name)
return !reqdProps.Has(p.name) && p.name != "status"
}).
ToSlice(&optionalProperties)
ToSlice(&optionalInputProperties)

if len(properties) == 0 {
return linq.From([]*KindConfig{})
Expand All @@ -680,14 +678,14 @@ func createGroups(definitionsJSON map[string]interface{}, opts groupOpts) []*Gro
kind: d.gvk.Kind,
// NOTE: This transformation assumes git users on Windows to set
// the "check in with UNIX line endings" setting.
comment: fmtComment(d.data["description"], " ", opts),
properties: properties,
requiredProperties: requiredProperties,
optionalProperties: optionalProperties,
gvk: &d.gvk,
apiVersion: fqGroupVersion,
rawAPIVersion: defaultGroupVersion,
typeGuard: typeGuard,
comment: fmtComment(d.data["description"], " ", opts),
properties: properties,
requiredInputProperties: requiredInputProperties,
optionalInputProperties: optionalInputProperties,
gvk: &d.gvk,
apiVersion: fqGroupVersion,
rawAPIVersion: defaultGroupVersion,
typeGuard: typeGuard,
},
})
}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["kind"] = "MutatingWebhookConfiguration";
inputs["metadata"] = args && args.metadata || undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["kind"] = "MutatingWebhookConfigurationList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["kind"] = "ValidatingWebhookConfiguration";
inputs["metadata"] = args && args.metadata || undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "admissionregistration.k8s.io/v1beta1";
inputs["kind"] = "ValidatingWebhookConfigurationList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
4 changes: 2 additions & 2 deletions sdk/nodejs/apiextensions/v1beta1/CustomResourceDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["spec"] = args && args.spec || undefined;

inputs["apiVersion"] = "apiextensions.k8s.io/v1beta1";
inputs["kind"] = "CustomResourceDefinition";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apiextensions.k8s.io/v1beta1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apiextensions.k8s.io/v1beta1";
inputs["kind"] = "CustomResourceDefinitionList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apiregistration/v1/APIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apiregistration.k8s.io/v1";
inputs["kind"] = "APIService";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apiregistration/v1/APIServiceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apiregistration.k8s.io/v1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apiregistration.k8s.io/v1";
inputs["kind"] = "APIServiceList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apiregistration/v1beta1/APIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apiregistration.k8s.io/v1beta1";
inputs["kind"] = "APIService";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apiregistration/v1beta1/APIServiceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apiregistration.k8s.io/v1beta1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apiregistration.k8s.io/v1beta1";
inputs["kind"] = "APIServiceList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apps/v1/ControllerRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["revision"] = args && args.revision || undefined;

inputs["apiVersion"] = "apps/v1";
inputs["data"] = args && args.data || undefined;
inputs["kind"] = "ControllerRevision";
inputs["metadata"] = args && args.metadata || undefined;
inputs["revision"] = args && args.revision || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apps/v1/ControllerRevisionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apps/v1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "ControllerRevisionList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apps/v1/DaemonSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "DaemonSet";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apps/v1/DaemonSetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apps/v1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "DaemonSetList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apps/v1/Deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "Deployment";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apps/v1/DeploymentList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apps/v1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "DeploymentList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apps/v1/ReplicaSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "ReplicaSet";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
3 changes: 2 additions & 1 deletion sdk/nodejs/apps/v1/ReplicaSetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};
inputs["apiVersion"] = "apps/v1";
inputs["items"] = args && args.items || undefined;

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "ReplicaSetList";
inputs["metadata"] = args && args.metadata || undefined;

Expand Down
2 changes: 1 addition & 1 deletion sdk/nodejs/apps/v1/StatefulSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ import { getVersion } from "../../version";
}

let inputs: pulumi.Inputs = {};

inputs["apiVersion"] = "apps/v1";
inputs["kind"] = "StatefulSet";
inputs["metadata"] = args && args.metadata || undefined;
inputs["spec"] = args && args.spec || undefined;
inputs["status"] = args && args.status || undefined;

if (!opts) {
opts = {};
Expand Down
Loading

0 comments on commit 236068c

Please sign in to comment.