Skip to content

Commit

Permalink
return correct element types for latebound resources
Browse files Browse the repository at this point in the history
We currently return a pointer to the interface for latebound resources
from their ElementType methods.  However pulumi expects pointers to
the concrete type here, so it can create it and assign values to the
created object.  Fix that.
  • Loading branch information
tgummerer committed Oct 14, 2024
1 parent 43dbcc8 commit c3d4490
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/pulumiyaml/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
}
15 changes: 15 additions & 0 deletions pkg/tests/testdata/resource-secret/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit c3d4490

Please sign in to comment.