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

Support setting version option in codegen #16217

Open
6 tasks
t0yv0 opened this issue May 16, 2024 · 0 comments
Open
6 tasks

Support setting version option in codegen #16217

t0yv0 opened this issue May 16, 2024 · 0 comments
Labels
kind/enhancement Improvements or new features

Comments

@t0yv0
Copy link
Member

t0yv0 commented May 16, 2024

As a provider author I would like to be able to specify auto-populating the "version" ResourceOption. The scenario
where this helps: a new major version v2 is being released where my.Resource can no longer be supported in the provider
and is now deprecated. Automatically setting "version" will allow end-user programs to upgrade to v2 without changes
while serving the resource with the older retained version of the provider.

I have tested this change by modifying the generated aws.s3.Bucket constructor to add a few lines:

   opts.version = "6.33.0";
   opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
   console.log("setting version to 6.33.0");
   console.log(opts.version);

And it does seem to afford the flexibility of seamless upgrades while dropping a resource implementation.

This functionality complements the ability of the provider to set a default Type alias which simplifies upgrades when
the token is changing.

The work here is likely a minimal extension of codegen but needs to be carried out for each language with tests:

  • typescript
  • python
  • go
  • dotnet
  • java
  • yaml

A provider author utilizing this feature would need to retain a frozen copy of the resource schema to continue passing
it to the resource generator. A more general alternative of this work would make that easier, that is, it would support
a form of #5331 for resource specs and automate locating the schema from the
given version so that the provider can forget the schema and simply leave a stub pointer:

Resources: map[string]ResourceSpec{          // informs actual schema and implementation -----v
  "aws:s3/bucket:LegacyBucket": ResourceSpec{Ref: "/provider/v6.35.0/schema.json#aws:s3/bucket:Bucket"}
  //              ^--- informs which type to place this into
}

This sounds a little more involved though and in terms of impact providers will be likely very happy with just the
version support.

@t0yv0 t0yv0 added the kind/enhancement Improvements or new features label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

1 participant