mirror of https://github.com/pulumi/pulumi.git
695360ac19
Codegen for wrapping input properties as secrets performed an incorrect cast, as seen in Pulumi's AWS classic SDK. Using the sample program and the resource constructor described in #11664 as our test case, from `pulumi-aws/sdk/v5/go/aws/secretmanager/secretVersion.go`: ```go func NewSecretVersion(ctx *pulumi.Context, name string, args *SecretVersionArgs, opts ...pulumi.ResourceOption) (*SecretVersion, error) { if args == nil { return nil, errors.New("missing one or more required arguments") } if args.SecretId == nil { return nil, errors.New("invalid value for required argument 'SecretId'") } if args.SecretBinary != nil { 82: args.SecretBinary = pulumi.ToSecret(args.SecretBinary).(pulumi.StringPtrOutput) } if args.SecretString != nil { 85: args.SecretString = pulumi.ToSecret(args.SecretString).(pulumi.StringPtrOutput) } ``` `args.SecretBinary` is of type `pulumi.StringPtrInput` and `pulumi.ToSecret` returns `pulumi.Output` returns its input as an Output-wrapped value marked secret. As `StringPtrInput` is an interface accepting multiple input types, the return value would be either `pulumi.StringOutput` `pulumi.StringPtrOutput`. These are both concrete types, and casting to the incorrect one would panic. Fortunately we can cast back to the arg's type, as verified by building the new codegen and testing the Pulumi program in #11664. This should handle regular inputs and plain inputs. The new codegen below converts an input type `T` to `pulumi.Output`, then casts back to `T`. ```go func NewSecretVersion(ctx *pulumi.Context, // ... if args.SecretBinary != nil { 82: args.SecretBinary = pulumi.ToSecret(args.SecretBinary).(pulumi.StringPtrInput) } if args.SecretString != nil { 85: args.SecretString = pulumi.ToSecret(args.SecretString).(pulumi.StringPtrInput) } ``` |
||
---|---|---|
.. | ||
foo | ||
codegen-manifest.json |