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
Add pulumi package
with subcommands gen-sdk
and get-schema
#10711
Conversation
Please view the results of the Downstream Codegen Tests Here |
Please view the results of the Downstream Codegen Tests Here |
Changelog[uncommitted] (2022-09-15)Features
|
Please view the results of the Downstream Codegen Tests Here |
|
||
func newExtractSchemaCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "get-schema <schema_source>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't there a proposal to offer CLI commands for invoking other plugin gRPC methods? If we're considering that, where would this command fit-in? cc: @Frassle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That proposal, AFAIK, was to directly call the provider commands, and print the output. This command (while very similar) does a little more than that. It verifies the schema is valid, round tripping it through our parsed representation, then formatting the output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with Ian, those commands are more intended for provider debugging, not for general user usage and while we would probably have a get-schema command under there as well for completeness it would just be a raw echo of the string sent back over grpc.
func genSDK(language, out string, pkg *schema.Package) error { | ||
var f func(string, *schema.Package, map[string][]byte) (map[string][]byte, error) | ||
switch language { | ||
case "csharp", "c#", "dotnet": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we accepting these additional names like "csharp" and "c#"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a set of names for the folders we generate our SDKs into (nodejs
, dotnet
, python
go
, java
) and a set of names we accept for pulumi convert
(csharp
, c#
, go
typescript
, python
, java
). I'm accepting the union to avoid being confusing, but we will only emit our standard folders (dotnet correction, nodejs correction).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason I asked is because we'll have to accommodate these various names when trying to select the right plugin when we move to a plugin model.
But if we're already doing it in pulumi convert
, we'll have to be able to support these additional "aliases" there anyway, so no concern doing it here as well.
|
||
func genSDK(language, out string, pkg *schema.Package) error { | ||
var f func(string, *schema.Package, map[string][]byte) (map[string][]byte, error) | ||
switch language { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this functionality should live in the language plugins. Then we wouldn't need to hard code this switch
, we'd just load up the requested language plugin and call it over gRPC to do the SDK codegen, similar in spirit to #9294. The benefit being that if we add more languages in the future, we wouldn't necessarily have to touch this code again.
Not sure what that means for all
, though, other than enumerating all available language plugins and invoking the appropriate gRPC method for each one.
Though, I can also understand possible pushback to this suggestion: that the codegen functionality doesn't really belong in the language plugins because their purpose (right now) is only about running Pulumi programs in the given language -- not about codegen. If others share this concern, we could consider another kind of plugin, maybe "codegen" (e.g. pulumi-codegen-nodejs
, pulumi-codegen-python
, etc.) that would be exclusively meant to handle codegen tasks (perhaps both sdkgen and programgen).
Of course, we could always hard code in a switch
for now for expediency, and move to language plugin in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codegen can and should be pluginafied, but that is out of scope of this PR. Were hardcoding for now, but that is not the desired end goal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this functionality should live in the language plugins.
It should! We have discussed this multiple times, we will do this but it's probably tricky so keeps being put off.
var language string | ||
var out string | ||
cmd := &cobra.Command{ | ||
Use: "gen-sdk <schema_source>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gen-sdk
is probably the best verb I do wonder, though, if there are any other names we should consider like just generate
or gen
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered generate
, but it wasn't clear what was being generated (sdk, schema, binary, ...). I'm open to other suggestions though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate-sdk? I'd rather be clear here it's not like this is a command where terseness is really needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with gen-sdk
. Looking over existing commands, we already have gen-markdown
and gen-completion
so there is precedent with just gen-
(though, these are hidden).
Please view the results of the Downstream Codegen Tests Here |
Please view the results of the Downstream Codegen Tests Here |
I'm adding a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bors r+ |
10711: Add `pulumi package` with subcommands `gen-sdk` and `get-schema` r=iwahbe a=iwahbe <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes #10693 This PR adds two commands that are vital to developing Pulumi packages without intermediary artifact and boilerplate. - `gen-sdk`: Takes either a package name, plugin path, or schema file and generates the associated SDK. - `get-schema`: Takes the same input as `gen-sdk`. It prints the schema out to stdout. ## Checklist <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Service, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. --> 10763: ci: Fix make brew r=AaronFriel a=AaronFriel This enables `make brew` to run as before, accounting for directory changes. The prep-for-goreleaser script places artifacts in `./bin/` now. `make brew` now succeeds. Fixes #10735 10767: [yaml] Update Pulumi YAML to 0.5.7 r=AaronFriel a=AaronFriel Co-authored-by: Ian Wahbe <ian@wahbe.com> Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
Build failed (retrying...): |
10711: Add `pulumi package` with subcommands `gen-sdk` and `get-schema` r=iwahbe a=iwahbe <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes #10693 This PR adds two commands that are vital to developing Pulumi packages without intermediary artifact and boilerplate. - `gen-sdk`: Takes either a package name, plugin path, or schema file and generates the associated SDK. - `get-schema`: Takes the same input as `gen-sdk`. It prints the schema out to stdout. ## Checklist <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have updated the [CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md) file with my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Service, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. --> 10772: Freeze `3.40.1` draft release. r=dixler a=dixler <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description Bumping `.version` freezes the draft release. Fixes # (issue) ## Checklist <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Service, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Service API version <!-- `@Pulumi` employees: If yes, you must submit corresponding changes in the service repo. --> Co-authored-by: Ian Wahbe <ian@wahbe.com> Co-authored-by: Kyle Dixler <kyle@pulumi.com>
Build failed (retrying...): |
Build succeeded: |
Description
Fixes #10693
This PR adds two commands that are vital to developing Pulumi packages without intermediary artifact and boilerplate.
gen-sdk
: Takes either a package name, plugin path, or schema file and generates the associated SDK.get-schema
: Takes the same input asgen-sdk
. It prints the schema out to stdout.Checklist