diff --git a/.changes/unreleased/Bug Fixes-664.yaml b/.changes/unreleased/Bug Fixes-664.yaml new file mode 100644 index 00000000..ee5084d9 --- /dev/null +++ b/.changes/unreleased/Bug Fixes-664.yaml @@ -0,0 +1,6 @@ +component: runtime +kind: Bug Fixes +body: Fix potential panic when using fn::secret on a resource +time: 2024-10-14T17:31:02.140545881+02:00 +custom: + PR: "664" diff --git a/pkg/pulumiyaml/run.go b/pkg/pulumiyaml/run.go index 764eded0..209e5eab 100644 --- a/pkg/pulumiyaml/run.go +++ b/pkg/pulumiyaml/run.go @@ -582,7 +582,7 @@ func (st *lateboundCustomResourceState) ProviderResource() *pulumi.ProviderResou } func (*lateboundCustomResourceState) ElementType() reflect.Type { - return reflect.TypeOf((*lateboundResource)(nil)).Elem() + return reflect.TypeOf((**lateboundCustomResourceState)(nil)).Elem() } func (st *lateboundCustomResourceState) GetRawOutputs() pulumi.Output { @@ -625,7 +625,7 @@ func (st *lateboundProviderResourceState) ProviderResource() *pulumi.ProviderRes } func (*lateboundProviderResourceState) ElementType() reflect.Type { - return reflect.TypeOf((*lateboundResource)(nil)).Elem() + return reflect.TypeOf((**lateboundProviderResourceState)(nil)).Elem() } func (st *lateboundProviderResourceState) GetRawOutputs() pulumi.Output { @@ -866,7 +866,8 @@ func (r *Runner) Evaluate(ctx *pulumi.Context) syntax.Diagnostics { return r.Run(programEvaluator{ evalContext: eCtx, pulumiCtx: ctx, - packageRefs: packageRefs}) + packageRefs: packageRefs, + }) } func getConfNodesFromMap(project string, configPropertyMap resource.PropertyMap) []configNode { diff --git a/pkg/tests/integration_test.go b/pkg/tests/integration_test.go index 3795b215..4c348d04 100644 --- a/pkg/tests/integration_test.go +++ b/pkg/tests/integration_test.go @@ -170,3 +170,10 @@ func TestResourceOrderingWithDefaultProvider(t *testing.T) { SkipEmptyPreviewUpdate: true, }) } + +//nolint:paralleltest // uses parallel programtest +func TestResourceSecret(t *testing.T) { + integration.ProgramTest(t, &integration.ProgramTestOptions{ + Dir: filepath.Join("testdata", "resource-secret"), + }) +} diff --git a/pkg/tests/testdata/resource-secret/Pulumi.yaml b/pkg/tests/testdata/resource-secret/Pulumi.yaml new file mode 100644 index 00000000..36ae2707 --- /dev/null +++ b/pkg/tests/testdata/resource-secret/Pulumi.yaml @@ -0,0 +1,15 @@ +name: resource-secret +runtime: + name: yaml +resources: + randomPassword: + type: random:RandomPassword + properties: + length: 16 + lower: true + upper: true + numeric: true + special: true +outputs: + superSecret: + fn::secret: ${randomPassword}