pulumi/pkg/codegen/testing/test/testdata
Aaron Friel 695360ac19 fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments
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)
        }
```
2022-12-16 17:27:10 -08:00
..
assets-archives-pp Don't import types referenced from local variables 2022-11-22 16:35:00 -08:00
aws-eks-pp Parenthesize lambda generation 2022-11-23 19:19:08 -08:00
aws-fargate-pp Convert invoke results to ouputs when needed 2022-11-28 16:14:07 -08:00
aws-iam-policy-pp feat(ci): Enable fully offline codegen tests with versioned plugins 2022-10-11 05:16:23 -07:00
aws-lambda-pp Update test results 2022-09-27 17:15:10 -07:00
aws-optionals-pp feat(ci): Enable fully offline codegen tests with versioned plugins 2022-10-11 05:16:23 -07:00
aws-resource-options-4.26-pp feat(ci): Enable fully offline codegen tests with versioned plugins 2022-10-11 05:16:23 -07:00
aws-resource-options-5.16.2-pp feat(ci): Enable fully offline codegen tests with versioned plugins 2022-10-11 05:16:23 -07:00
aws-s3-folder-pp Fix capitalization for generated `fs.readdirSync` 2022-11-28 11:26:32 -08:00
aws-s3-logging-pp Check for optional/ Ptr types within Unions [go/programgen] 2022-12-12 15:49:20 -08:00
aws-secret-pp Fix Python codegen for secret() intrinsic 2022-12-11 05:07:18 -08:00
aws-webserver-pp Mark external modules as forign 2022-11-22 13:46:18 -08:00
azure-native-nested-types Remove dotnet 2022-12-13 16:13:53 +00:00
azure-native-pp Update test results 2022-09-27 17:15:10 -07:00
azure-sa-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
cyclic-types Remove dotnet 2022-12-13 16:13:53 +00:00
dash-named-schema Remove dotnet 2022-12-13 16:13:53 +00:00
dashed-import-schema Remove dotnet 2022-12-13 16:13:53 +00:00
different-enum remove slash from resource options anchors 2022-12-07 10:43:26 -08:00
different-package-name-conflict Remove dotnet 2022-12-13 16:13:53 +00:00
discriminated-union-pp Enable resolving discriminated unions when the discriminator is a string pointer 2022-09-22 14:50:20 -07:00
enum-reference Remove dotnet 2022-12-13 16:13:53 +00:00
external-enum Remove dotnet 2022-12-13 16:13:53 +00:00
external-go-import-aliases codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
external-node-compatibility Revert "Merge #10831" 2022-12-05 10:19:41 -08:00
external-python-same-module-name [codegen/python] Implement deep merge on resource and invoke options, matching other SDKs (#9856) 2022-06-14 16:52:24 -07:00
external-resource-schema Remove dotnet 2022-12-13 16:13:53 +00:00
functions-pp Add test for error initialization [go/codegen] 2022-12-14 12:41:11 -08:00
functions-secrets Remove dotnet 2022-12-13 16:13:53 +00:00
go-nested-collections codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
go-plain-ref-repro codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
hyphen-url Remove dotnet 2022-12-13 16:13:53 +00:00
hyphenated-symbols codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
internal-dependencies-go codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
invalid-go-sprintf-pp Handle long traversals in a nicer way (#9726) 2022-06-02 09:36:33 -07:00
kubernetes-operator-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
kubernetes-pod-pp Don't emit missing var errors for const vars 2022-11-21 17:20:54 -08:00
kubernetes-template-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
logical-name-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
modpath-pp Add `modulePath` to go 2022-10-10 16:01:53 -07:00
naming-collisions Remove dotnet 2022-12-13 16:13:53 +00:00
nested-module fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
nested-module-thirdparty fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
other-owned Remove dotnet 2022-12-13 16:13:53 +00:00
output-funcs Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
output-funcs-aws-pp feat(ci): Enable fully offline codegen tests with versioned plugins 2022-10-11 05:16:23 -07:00
output-funcs-edgeorder Remove dotnet 2022-12-13 16:13:53 +00:00
output-funcs-tfbridge20 Remove dotnet 2022-12-13 16:13:53 +00:00
plain-and-default Remove dotnet 2022-12-13 16:13:53 +00:00
plain-object-defaults Remove dotnet 2022-12-13 16:13:53 +00:00
plain-object-disable-defaults Remove dotnet 2022-12-13 16:13:53 +00:00
plain-schema-gh6957 Remove dotnet 2022-12-13 16:13:53 +00:00
provider-config-schema fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
pulumi-stack-reference-pp Fix StackReference code gen (#10419) 2022-08-19 10:27:05 -07:00
python-regress-10914-pp recursively annotate expressions under invoke calls with their associated schema types 2022-10-07 14:02:12 +02:00
python-resource-names-pp [import/python] use init param name for programgen (#9359) 2022-04-07 12:00:19 +02:00
random-pet-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
read-file-func-pp Missing default case handling for local variables 2022-10-09 16:48:16 +02:00
regress-8403 Remove dotnet 2022-12-13 16:13:53 +00:00
regress-go-8664 codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
regress-go-10527 codegen/go: Remove superfluous newline in doc.go 2022-11-30 14:17:13 +00:00
regress-node-8110 Remove dotnet 2022-12-13 16:13:53 +00:00
regress-py-tfbridge-611 Accept codegen demonstrating the fix 2022-10-05 15:34:17 -04:00
replace-on-change Remove dotnet 2022-12-13 16:13:53 +00:00
resource-args-python Remove dotnet 2022-12-13 16:13:53 +00:00
resource-args-python-case-insensitive Remove dotnet 2022-12-13 16:13:53 +00:00
resource-property-overlap Remove dotnet 2022-12-13 16:13:53 +00:00
schema Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
secrets fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
simple-enum-schema Remove dotnet 2022-12-13 16:13:53 +00:00
simple-methods-schema Remove dotnet 2022-12-13 16:13:53 +00:00
simple-methods-schema-single-value-returns Remove dotnet 2022-12-13 16:13:53 +00:00
simple-plain-schema Remove dotnet 2022-12-13 16:13:53 +00:00
simple-plain-schema-with-root-package Remove dotnet 2022-12-13 16:13:53 +00:00
simple-range-pp Fix PCL binding of options.range = number 2022-12-07 19:47:44 +00:00
simple-resource-schema fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
simple-resource-schema-custom-pypackage-name Remove dotnet 2022-12-13 16:13:53 +00:00
simple-yaml-schema fix(sdkgen/go): illegal cast in resource constructors when secret-wrapping input arguments 2022-12-16 17:27:10 -08:00
simplified-invokes Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
simplified-invokes-pp Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
synthetic-resource-properties-pp Check for optional/ Ptr types within Unions [go/programgen] 2022-12-12 15:49:20 -08:00
third-party-package-pp Add `modulePath` to go 2022-10-10 16:01:53 -07:00
transpiled_examples Fix Python codegen for secret() intrinsic 2022-12-11 05:07:18 -08:00
traverse-union-repro-pp Remove traverse errors on dynamic types 2022-11-16 14:41:30 -08:00
typed-enum-pp dotnet program-gen now targets .NET 6 (#10143) 2022-07-21 21:04:02 +02:00
.gitignore [codegen/python] fix invalid codegen on empty outputs functions (#9649) 2022-05-23 14:43:38 -07:00
aws-4.15.0.json Standardize pkg loading for TestReferenceRenderer 2022-11-03 16:46:41 -07:00
aws-4.26.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
aws-4.36.0.json Add missing schemas 2022-10-24 16:47:54 -07:00
aws-4.37.1.json Add missing schemas 2022-10-24 16:47:54 -07:00
aws-5.4.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
aws-5.16.2.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
aws-native-0.13.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
awsx-1.0.0-beta.5.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
azure-4.18.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
azure-native-1.28.0.json Add missing schemas 2022-10-24 16:47:54 -07:00
azure-native-1.29.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
azure-native-1.56.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
docker-3.1.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
eks-0.37.1.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
eks-0.40.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
google-native-0.18.2.json Add missing schemas 2022-10-24 16:47:54 -07:00
kubernetes-3.0.0.json Test YAML PCL examples 2022-10-24 10:33:48 -07:00
kubernetes-3.7.0.json Add missing schemas 2022-10-24 16:47:54 -07:00
kubernetes-3.7.2.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
other-0.1.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
random-4.2.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
random-4.3.1.json Add missing schemas 2022-10-24 16:47:54 -07:00
std-1.0.0.json Initial implementation of simplified invokes for dotnet and nodejs 2022-12-16 13:39:03 +01:00
synthetic-1.0.0.json feat(ci): Enable fully offline codegen tests with versioned plugins cont'deleted 2022-10-11 05:16:46 -07:00
types.json modify codegen/python to generate valid python code for non-string secrets 2022-12-07 11:36:15 -08:00