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

Update to Pulumi v3.21.0. #63

Merged
merged 2 commits into from
Jan 4, 2022
Merged

Update to Pulumi v3.21.0. #63

merged 2 commits into from
Jan 4, 2022

Conversation

pgavlin
Copy link
Member

@pgavlin pgavlin commented Jan 3, 2022

This brings in many improvements to code generation, including support
for default values for union-typed properties.

This brings in many improvements to code generation, including support
for default values for union-typed properties.
- allow additional package names
- fix a check in the Python generator
@pgavlin
Copy link
Member Author

pgavlin commented Jan 3, 2022

I believe that this will fix #22.

@pgavlin pgavlin merged commit 671bb76 into master Jan 4, 2022
@pulumi-bot pulumi-bot deleted the pgavlin/updatePulumi branch January 4, 2022 17:00
@lblackstone lblackstone mentioned this pull request Jan 4, 2022
@lblackstone
Copy link
Member

I believe that this will fix #22.

I'm still getting an error with this change:

panic: fatal: error An assertion has failed: could not parse Pulumi package. source error: could not import spec: <nil>: #/types/kubernetes:rabbitmq.com%2Fv1beta1:RabbitmqClusterSpec/properties/service/default: type kubernetes:rabbitmq.com/v1beta1:RabbitmqClusterSpecService cannot have a constant value; only booleans, integers, numbers and strings may have constant values; , and 5 other diagnostic(s)

goroutine 1 [running]:
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)
	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.21.0/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.AssertNoErrorf(0x2041820, 0xc000328030, 0x1eac169, 0x1e, 0x0, 0x0, 0x0)
	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.21.0/go/common/util/contract/assert.go:47 +0x1cd
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).SchemaPackage(0xc0005cfa90, 0xc000000180)
	/home/runner/work/crd2pulumi/crd2pulumi/gen/generate.go:237 +0xb6
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).genNodeJSFiles(0xc0005cfa90, 0x1e8ad7e, 0x4, 0xc0005a2240, 0x1, 0x1)
	/home/runner/work/crd2pulumi/crd2pulumi/gen/nodejs.go:39 +0x45
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).genNodeJS(0xc0005cfa90, 0x206b518b8, 0xc, 0x1e8ad7e, 0x4, 0x1, 0xc0005a22c0)
	/home/runner/work/crd2pulumi/crd2pulumi/gen/nodejs.go:30 +0x45
github.com/pulumi/crd2pulumi/gen.Generate(0xc00007ea60, 0x0, 0x0, 0x0, 0x1e8ad7e, 0x4, 0x1e8ad7e, 0x4, 0x1e8ad7e, 0x4, ...)
	/home/runner/work/crd2pulumi/crd2pulumi/gen/generate.go:70 +0x2f7
github.com/pulumi/crd2pulumi/cmd.Execute.func2(0xc0008442c0, 0xc0004bc690, 0x1, 0x3)
	/home/runner/work/crd2pulumi/crd2pulumi/cmd/root.go:158 +0x271
github.com/spf13/cobra.(*Command).execute(0xc0008442c0, 0xc0001ac050, 0x3, 0x3, 0xc0008442c0, 0xc0001ac050)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0008442c0, 0xc0005c3f00, 0x1, 0x1)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/pulumi/crd2pulumi/cmd.Execute(0xc000070748, 0x27380e0)
	/home/runner/work/crd2pulumi/crd2pulumi/cmd/root.go:190 +0x666
main.main()
	/home/runner/work/crd2pulumi/crd2pulumi/main.go:25 +0x26

@pgavlin
Copy link
Member Author

pgavlin commented Jan 5, 2022

@lblackstone would it be easy to boil the repro you have down into a testcase?

@lblackstone
Copy link
Member

@lblackstone would it be easy to boil the repro you have down into a testcase?

Sure, should be easy. Here's the command line output for reference:

crd2pulumi --nodejsPath crd/rabbitmq https://github.com/rabbitmq/cluster-operator/releases/download/v1.4.0/cluster-operator.yml
panic: fatal: error An assertion has failed: could not parse Pulumi package. source error: could not import spec: <nil>: #/types/kubernetes:rabbitmq.com%2Fv1beta1:RabbitmqClusterSpec/properties/resources/default: type kubernetes:rabbitmq.com/v1beta1:RabbitmqClusterSpecResources cannot have a constant value; only booleans, integers, numbers and strings may have constant values; , and 5 other diagnostic(s)

goroutine 1 [running]:
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...)
	/Users/levi/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.21.0/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.AssertNoErrorf({0x103497f60, 0x14000f2ea20}, {0x1030de3cc, 0x1e}, {0x0, 0x0, 0x0})
	/Users/levi/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.21.0/go/common/util/contract/assert.go:47 +0x170
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).SchemaPackage(0x140009dda78)
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/gen/generate.go:237 +0x88
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).genNodeJSFiles(0x140009dda78, {0x1030bc9c3, 0x4})
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/gen/nodejs.go:39 +0x30
github.com/pulumi/crd2pulumi/gen.(*PackageGenerator).genNodeJS(0x140009dda78, {0x16d7936f8, 0xc}, {0x1030bc9c3, 0x4})
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/gen/nodejs.go:30 +0x38
github.com/pulumi/crd2pulumi/gen.Generate({0x14000420820, 0x0, 0x0, 0x0, {0x1030bc9c3, 0x4}, {0x1030bc9c3, 0x4}, {0x1030bc9c3, 0x4}, ...}, ...)
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/gen/generate.go:70 +0x10c
github.com/pulumi/crd2pulumi/cmd.Execute.func2(0x1400003edc0, {0x14000518840, 0x1, 0x3})
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/cmd/root.go:158 +0x118
github.com/spf13/cobra.(*Command).execute(0x1400003edc0, {0x140001b8010, 0x3, 0x3})
	/Users/levi/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x640
github.com/spf13/cobra.(*Command).ExecuteC(0x1400003edc0)
	/Users/levi/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x404
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/levi/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
github.com/pulumi/crd2pulumi/cmd.Execute()
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/cmd/root.go:190 +0x5dc
main.main()
	/Users/levi/go/src/github.com/pulumi/crd2pulumi/main.go:25 +0x20

@pgavlin
Copy link
Member Author

pgavlin commented Jan 6, 2022

Argh, I should have read #22 more closely. My eyes caught on the property definitions, not the defaults definition. We still do not support default values for non-primitive types--that will require new feature work in the schema package and code generators.

@pgavlin
Copy link
Member Author

pgavlin commented Jan 6, 2022

In the meantime, we could at least avoid the panic by either
a. erroring on complex default values, or
b. eliding complex default values, or
c. some combination of the above (e.g. error by default and elide if a flag is passed)

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.

3 participants