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

Make apiVersion and kind typing more precise #341

Merged
merged 3 commits into from
Jan 8, 2019

Conversation

hausdorff
Copy link
Contributor

In Kubernetes resource implementations of pulumi.CustomResource, every
top-level resource type has two fields:

apiVersion?: pulumi.Input<string>
kind?: pulumi.Input<string>

These types could be more correct. For example, in the case of
apps/v1/Deployment, we might instead write:

apiVersion?: pulumi.Input<'apps/v1'>
kind?: pulumi.Input<'Deployment'>

This commit does exactly this.

Fixes #315.

@hausdorff
Copy link
Contributor Author

The first time around on this, I missed some of the properties that are exceptions -- e.g., autoscaling/v1/CrossVersionObjectReference has both apiVersion and kind, but is not a top-level resource type, and therefore should not have the more specific typing scheme described above.

@lblackstone please do double check this to make sure I'm not missing any other exceptions to this rule... I'm leaving the second commit as a standalone for now, rather than squashing it with the previous so you can take a look.

Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming I understand what you mean by "top-level resource type", there are a few types here that appear to be nested fields (i.e. can't create these resources directly with the API).

  • DeploymentRollback
  • Scale
  • APIGroup
  • APIResourceList
  • APIVersions
  • DeleteOptions
  • Status
  • Eviction

pkg/gen/typegen.go Show resolved Hide resolved
pkg/gen/typegen.go Show resolved Hide resolved
pkg/gen/typegen.go Show resolved Hide resolved
pkg/gen/typegen.go Show resolved Hide resolved
sdk/nodejs/provider.ts Outdated Show resolved Hide resolved
sdk/nodejs/provider.ts Outdated Show resolved Hide resolved
sdk/nodejs/provider.ts Outdated Show resolved Hide resolved
sdk/nodejs/provider.ts Outdated Show resolved Hide resolved
sdk/nodejs/provider.ts Show resolved Hide resolved
sdk/nodejs/provider.ts Outdated Show resolved Hide resolved
In Kubernetes resource implementations of `pulumi.CustomResource`, every
top-level resource type has two fields:

    apiVersion?: pulumi.Input<string>
    kind?: pulumi.Input<string>

These types could be more correct. For example, in the case of
apps/v1/Deployment, we might instead write:

    apiVersion?: pulumi.Input<'apps/v1'>
    kind?: pulumi.Input<'Deployment'>

This commit does exactly this.

Fixes #315.
@hausdorff
Copy link
Contributor Author

We've agreed to keep "%s" instead of %q for code generation.

@hausdorff hausdorff merged commit 69d6a81 into master Jan 8, 2019
@pulumi-bot pulumi-bot deleted the hausdorff/typed-defaults branch January 8, 2019 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants