Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
4d4ff9f1d6 | |||
2d26cdd9ed | |||
b14bc09b1c | |||
09b7aa9186 | |||
c39343fa3d | |||
4b7985384c | |||
6cb801cf17 | |||
52d01bb915 | |||
c1c82b8317 | |||
e77d780370 | |||
72a4e1fc3f |
|
@ -1,34 +1,12 @@
|
|||
### Improvements
|
||||
|
||||
- [cli] - When running `pulumi new https://github.com/name/repo`, check
|
||||
for branch `main` if branch `master` doesn't exist.
|
||||
[#8463](https://github.com/pulumi/pulumi/pull/8463)
|
||||
|
||||
- [codegen/python] - Program generator now uses `fn_output` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8433](https://github.com/pulumi/pulumi/pull/8433)
|
||||
|
||||
- [codegen/go] - Program generator now uses fnOutput forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8431](https://github.com/pulumi/pulumi/pull/8431)
|
||||
|
||||
- [codegen/dotnet] - Program generator now uses `Invoke` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8432](https://github.com/pulumi/pulumi/pull/8432)
|
||||
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being
|
||||
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of
|
||||
a value--the implementation of `Ptr` types for resources was incorrect, making
|
||||
these types virtually unusable in practice.
|
||||
[#8449](https://github.com/pulumi/pulumi/pull/8449)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [cli/nodejs] - Allow specifying the tsconfig file used in Pulumi.yaml.
|
||||
[#8452](https://github.com/pulumi/pulumi/pull/8452)
|
||||
|
||||
- [codegen/nodejs] - Respect default values in Pulumi object types.
|
||||
[#8400](https://github.com/pulumi/pulumi/pull/8400)
|
||||
|
||||
- [sdk/python] - Correctly handle version checking python virtual environments.
|
||||
[#8465](https://github.com/pulumi/pulumi/pull/8465)
|
||||
|
||||
- [cli] - Catch expected errors in stacks with filestate backends.
|
||||
[#8455](https://github.com/pulumi/pulumi/pull/8455)
|
||||
|
||||
- [sdk/dotnet] - Do not attempt to serialize unknown values.
|
||||
[#8475](https://github.com/pulumi/pulumi/pull/8475)
|
||||
- [codegen/go] - Respect default values in Pulumi object types.
|
||||
[#8411](https://github.com/pulumi/pulumi/pull/8400)
|
||||
|
|
|
@ -22,7 +22,7 @@ To hack on Pulumi, you'll need to get a development environment set up. You'll w
|
|||
You can easily get all required dependencies with brew and npm
|
||||
|
||||
```bash
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl coreutils
|
||||
curl https://raw.githubusercontent.com/Homebrew/homebrew-cask/0272f0d33f/Casks/dotnet-sdk.rb > dotnet-sdk.rb # v3.1.0
|
||||
brew install --HEAD -s dotnet-sdk.rb
|
||||
rm dotnet-sdk.rb
|
||||
|
@ -53,9 +53,10 @@ ulimit -n 5000
|
|||
|
||||
Across our projects, we try to use a regular set of make targets. The ones you'll care most about are:
|
||||
|
||||
0. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make dist`, which just builds and installs the Pulumi CLI
|
||||
1. `make`, which builds Pulumi and runs a quick set of tests
|
||||
2. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
1. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
|
||||
We make heavy use of integration level testing where we invoke `pulumi` to create and then delete cloud resources. This requires you to have a Pulumi account (so [sign up for free](https://pulumi.com) today if you haven't already) and login with `pulumi login`.
|
||||
|
||||
|
|
|
@ -173,8 +173,8 @@ details of the core Pulumi CLI and [programming model concepts](https://www.pulu
|
|||
|
||||
| Architecture | Build Status |
|
||||
| ------------ | ------------ |
|
||||
| Linux/macOS x64 | [![Linux x64 Build Status](https://travis-ci.com/pulumi/pulumi.svg?token=cTUUEgrxaTEGyecqJpDn&branch=master)](https://travis-ci.com/pulumi/pulumi) |
|
||||
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
|
||||
| Linux/macOS x64 | [![Linux x64 Build Status](https://github.com/pulumi/pulumi/actions/workflows/master.yml/badge.svg)](https://github.com/pulumi/pulumi/actions/workflows/master.yml) |
|
||||
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
|
||||
|
||||
### Languages
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@ type pkgContext struct {
|
|||
|
||||
// Determines if we should emit type registration code
|
||||
disableInputTypeRegistrations bool
|
||||
|
||||
// Determines if we should emit object defaults code
|
||||
disableObjectDefaults bool
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
|
||||
|
@ -269,6 +272,7 @@ func rawResourceName(r *schema.Resource) string {
|
|||
return tokenToName(r.Token)
|
||||
}
|
||||
|
||||
// If `nil` is a valid value of type `t`.
|
||||
func isNilType(t schema.Type) bool {
|
||||
switch t := t.(type) {
|
||||
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
|
||||
|
@ -295,23 +299,6 @@ func isNilType(t schema.Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// The default value for a Pulumi primitive type.
|
||||
func primitiveNilValue(t schema.Type) string {
|
||||
contract.Assert(schema.IsPrimitiveType(t))
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
return "false"
|
||||
case schema.IntType:
|
||||
return "0"
|
||||
case schema.NumberType:
|
||||
return "0.0"
|
||||
case schema.StringType:
|
||||
return "\"\""
|
||||
default:
|
||||
return "nil"
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
|
||||
switch t := codegen.SimplifyInputUnion(t).(type) {
|
||||
case *schema.OptionalType:
|
||||
|
@ -513,7 +500,12 @@ func (pkg *pkgContext) typeStringImpl(t schema.Type, argsType bool) string {
|
|||
}
|
||||
|
||||
func (pkg *pkgContext) typeString(t schema.Type) string {
|
||||
return pkg.typeStringImpl(t, false)
|
||||
s := pkg.typeStringImpl(t, false)
|
||||
if s == "pulumi." {
|
||||
return "pulumi.Any"
|
||||
}
|
||||
return s
|
||||
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
|
||||
|
@ -633,6 +625,9 @@ func (pkg *pkgContext) outputType(t schema.Type) string {
|
|||
}
|
||||
// TODO(pdg): union types
|
||||
return "pulumi.AnyOutput"
|
||||
case *schema.InputType:
|
||||
// We can't make output types for input types. We instead strip the input and try again.
|
||||
return pkg.outputType(t.ElementType)
|
||||
default:
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
|
@ -784,16 +779,14 @@ type genInputImplementationArgs struct {
|
|||
elementType string
|
||||
ptrMethods bool
|
||||
toOutputMethods bool
|
||||
resourceType bool
|
||||
}
|
||||
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods, resourceType bool) {
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods bool) {
|
||||
genInputImplementationWithArgs(w, genInputImplementationArgs{
|
||||
name: name,
|
||||
receiverType: receiverType,
|
||||
elementType: elementType,
|
||||
ptrMethods: ptrMethods,
|
||||
resourceType: resourceType,
|
||||
toOutputMethods: true,
|
||||
})
|
||||
}
|
||||
|
@ -802,14 +795,9 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
name := genArgs.name
|
||||
receiverType := genArgs.receiverType
|
||||
elementType := genArgs.elementType
|
||||
resourceType := genArgs.resourceType
|
||||
|
||||
fmt.Fprintf(w, "func (%s) ElementType() reflect.Type {\n", receiverType)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
if genArgs.toOutputMethods {
|
||||
|
@ -837,15 +825,11 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
}
|
||||
}
|
||||
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resourceType bool) {
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
||||
fmt.Fprintf(w, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
|
||||
|
||||
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\n", baseName)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
|
||||
|
@ -869,8 +853,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resour
|
|||
}
|
||||
}
|
||||
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false, resourceType)
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", elementType)
|
||||
|
@ -879,8 +863,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false, resourceType)
|
||||
func genMapOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s{\n", elementType)
|
||||
|
@ -889,8 +873,8 @@ func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool)
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) Elem() %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn o.ApplyT(func(v *%[1]s) %[1]s {\n", baseName)
|
||||
|
@ -956,7 +940,7 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -965,24 +949,24 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
}
|
||||
|
||||
// Generate the array output
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name, false)
|
||||
genArrayOutput(w, name, name)
|
||||
}
|
||||
|
||||
// Generate the map output.
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name, false)
|
||||
genMapOutput(w, name, name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
|
||||
genOutputType(w, name, name, true, false)
|
||||
genOutputType(w, name, name, true)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[3]sOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -1005,7 +989,7 @@ func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, el
|
|||
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
|
||||
fmt.Fprint(w, "}\n\n")
|
||||
|
||||
genPtrOutput(w, name, name, false)
|
||||
genPtrOutput(w, name, name)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) To%[2]sPtrOutput() %[3]sPtrOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -1107,6 +1091,27 @@ func (pkg *pkgContext) genEnumInputFuncs(w io.Writer, typeName string, enum *sch
|
|||
fmt.Fprintln(w)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) assignProperty(w io.Writer, p *schema.Property, object, value string, indirectAssign bool) {
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = ""
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
if t != "" {
|
||||
value = fmt.Sprintf("%s(%s)", t, value)
|
||||
}
|
||||
fmt.Fprintf(w, "\targs.%s = %s\n", Title(p.Name), value)
|
||||
} else if indirectAssign {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s := %s\n", tmpName, value)
|
||||
fmt.Fprintf(w, "%s.%s = &%s\n", object, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s.%s = %s\n", object, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessage string,
|
||||
properties []*schema.Property) {
|
||||
|
||||
|
@ -1119,6 +1124,66 @@ func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessa
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainObjectDefaultFunc(w io.Writer, name string,
|
||||
properties []*schema.Property) error {
|
||||
defaults := []*schema.Property{}
|
||||
for _, p := range properties {
|
||||
if p.DefaultValue != nil || codegen.IsProvideDefaultsFuncRequired(p.Type) {
|
||||
defaults = append(defaults, p)
|
||||
}
|
||||
}
|
||||
|
||||
// There are no defaults, so we don't need to generate a defaults function.
|
||||
if len(defaults) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
printComment(w, fmt.Sprintf("%s sets the appropriate defaults for %s", ProvideDefaultsMethodName, name), false)
|
||||
fmt.Fprintf(w, "func (val *%[1]s) %[2]s() *%[1]s {\n", name, ProvideDefaultsMethodName)
|
||||
fmt.Fprint(w, "if val == nil {\n return nil\n}\n")
|
||||
fmt.Fprint(w, "tmp := *val\n")
|
||||
for _, p := range defaults {
|
||||
if p.DefaultValue != nil {
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "if isZero(tmp.%s) {\n", Title(p.Name))
|
||||
pkg.assignProperty(w, p, "tmp", dv, !p.IsRequired())
|
||||
fmt.Fprintf(w, "}\n")
|
||||
} else if funcName := pkg.provideDefaultsFuncName(p.Type); funcName != "" {
|
||||
var member string
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
f := fmt.Sprintf("func(v %[1]s) %[1]s { return v.%[2]s*() }", name, funcName)
|
||||
member = fmt.Sprintf("tmp.%[1]s.ApplyT(%[2]s)\n", Title(p.Name), f)
|
||||
} else {
|
||||
member = fmt.Sprintf("tmp.%[1]s.%[2]s()\n", Title(p.Name), funcName)
|
||||
}
|
||||
sigil := ""
|
||||
if p.IsRequired() {
|
||||
sigil = "*"
|
||||
}
|
||||
pkg.assignProperty(w, p, "tmp", sigil+member, false)
|
||||
} else {
|
||||
panic(fmt.Sprintf("Property %s[%s] should not be in the default list", p.Name, p.Type.String()))
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "return &tmp\n}\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// The name of the method used to instantiate defaults.
|
||||
const ProvideDefaultsMethodName = "Defaults"
|
||||
|
||||
func (pkg *pkgContext) provideDefaultsFuncName(typ schema.Type) string {
|
||||
if !codegen.IsProvideDefaultsFuncRequired(typ) {
|
||||
return ""
|
||||
}
|
||||
return ProvideDefaultsMethodName
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details *typeDetails) {
|
||||
contract.Assert(t.IsInputShape())
|
||||
|
||||
|
@ -1129,7 +1194,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
pkg.genInputArgsStruct(w, name+"Args", t)
|
||||
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement, false)
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement)
|
||||
|
||||
// Generate the pointer input.
|
||||
if details.ptrElement {
|
||||
|
@ -1143,7 +1208,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false)
|
||||
}
|
||||
|
||||
// Generate the array input.
|
||||
|
@ -1152,7 +1217,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -1161,7 +1226,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1265,6 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
name, /* baseName */
|
||||
name, /* elementType */
|
||||
details.ptrElement, /* ptrMethods */
|
||||
false, /* resourceType */
|
||||
)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
|
@ -1219,7 +1283,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.ptrElement {
|
||||
genPtrOutput(w, name, name, false)
|
||||
genPtrOutput(w, name, name)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
|
||||
|
@ -1252,11 +1316,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name, false)
|
||||
genArrayOutput(w, name, name)
|
||||
}
|
||||
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name, false)
|
||||
genMapOutput(w, name, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1310,6 +1374,11 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
|
|||
return "", err
|
||||
}
|
||||
val = v
|
||||
switch t.(type) {
|
||||
case *schema.EnumType:
|
||||
typeName := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(t)), "Input")
|
||||
val = fmt.Sprintf("%s(%s)", typeName, val)
|
||||
}
|
||||
}
|
||||
|
||||
if len(dv.Environment) > 0 {
|
||||
|
@ -1393,6 +1462,8 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\t}\n\n")
|
||||
|
||||
// Produce the inputs.
|
||||
|
||||
// Check all required inputs are present
|
||||
for _, p := range r.InputProperties {
|
||||
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
|
||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||
|
@ -1401,26 +1472,8 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
}
|
||||
}
|
||||
|
||||
assign := func(p *schema.Property, value string, indentation int) {
|
||||
ind := strings.Repeat("\t", indentation)
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = strings.TrimSuffix(t, "Ptr")
|
||||
}
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, value)
|
||||
} else if isNilType(p.Type) {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s%s := %s\n", ind, tmpName, value)
|
||||
fmt.Fprintf(w, "%sargs.%s = &%s\n", ind, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%sargs.%s = %s\n", ind, Title(p.Name), value)
|
||||
}
|
||||
assign := func(p *schema.Property, value string) {
|
||||
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
|
||||
}
|
||||
|
||||
for _, p := range r.InputProperties {
|
||||
|
@ -1429,19 +1482,51 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assign(p, v, 1)
|
||||
assign(p, v)
|
||||
} else if p.DefaultValue != nil {
|
||||
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defaultComp := "nil"
|
||||
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
|
||||
defaultComp = primitiveNilValue(p.Type)
|
||||
}
|
||||
fmt.Fprintf(w, "\tif args.%s == %s {\n", Title(p.Name), defaultComp)
|
||||
assign(p, v, 2)
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
|
||||
assign(p, dv)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
} else if name := pkg.provideDefaultsFuncName(p.Type); name != "" && !pkg.disableObjectDefaults {
|
||||
var value string
|
||||
var needsNilCheck bool
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
innerFuncType := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(p.Type)), "Args")
|
||||
applyName := fmt.Sprintf("%sApplier", camel(p.Name))
|
||||
fmt.Fprintf(w, "%[3]s := func(v %[1]s) *%[1]s { return v.%[2]s() }\n", innerFuncType, name, applyName)
|
||||
|
||||
outputValue := pkg.convertToOutput(fmt.Sprintf("args.%s", Title(p.Name)), p.Type)
|
||||
outputType := pkg.typeString(p.Type)
|
||||
if strings.HasSuffix(outputType, "Input") {
|
||||
outputType = strings.TrimSuffix(outputType, "Input") + "Output"
|
||||
}
|
||||
|
||||
// Because applies return pointers, we need to convert to PtrOutput and then call .Elem().
|
||||
var tail string
|
||||
if !strings.HasSuffix(outputType, "PtrOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
tail = ".Elem()"
|
||||
}
|
||||
needsNilCheck = !p.IsRequired()
|
||||
value = fmt.Sprintf("%s.ApplyT(%s).(%s)%s", outputValue, applyName, outputType, tail)
|
||||
} else {
|
||||
value = fmt.Sprintf("args.%[1]s.%[2]s()", Title(p.Name), name)
|
||||
}
|
||||
v := func() {
|
||||
fmt.Fprintf(w, "args.%[1]s = %s\n", Title(p.Name), value)
|
||||
}
|
||||
if needsNilCheck {
|
||||
fmt.Fprintf(w, "if args.%s != nil {\n", Title(p.Name))
|
||||
v()
|
||||
fmt.Fprint(w, "}\n")
|
||||
} else {
|
||||
v()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1708,42 +1793,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, true)
|
||||
genInputImplementation(w, name, "*"+name, "*"+name, false)
|
||||
|
||||
if generateResourceContainerTypes {
|
||||
// Emit the resource pointer input type.
|
||||
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.Input\n\n")
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
ptrTypeName := camel(name) + "PtrType"
|
||||
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false)
|
||||
|
||||
if !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false, false)
|
||||
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false, false)
|
||||
}
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false)
|
||||
}
|
||||
|
||||
// Emit the resource output type.
|
||||
genOutputType(w, name, name, generateResourceContainerTypes, true)
|
||||
genOutputType(w, name, "*"+name, false)
|
||||
|
||||
if generateResourceContainerTypes {
|
||||
genPtrOutput(w, name, name, true)
|
||||
|
||||
if !r.IsProvider {
|
||||
genArrayOutput(w, name, name, true)
|
||||
genMapOutput(w, name, name, true)
|
||||
}
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
genArrayOutput(w, name, "*"+name)
|
||||
genMapOutput(w, name, "*"+name)
|
||||
}
|
||||
|
||||
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
|
||||
|
@ -1751,6 +1820,30 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
return nil
|
||||
}
|
||||
|
||||
// Takes an expression and type, and returns a string that converts that expression to an Output type.
|
||||
//
|
||||
// Examples:
|
||||
// ("bar", Foo of ObjectType) => "bar.ToFooOutput()"
|
||||
// ("id", FooOutput) => "id"
|
||||
// ("ptr", FooInput of ObjectType) => "ptr.ToFooPtrOutput().Elem()"
|
||||
func (pkg *pkgContext) convertToOutput(expr string, typ schema.Type) string {
|
||||
elemConversion := ""
|
||||
switch typ.(type) {
|
||||
case *schema.OptionalType:
|
||||
elemConversion = ".Elem()"
|
||||
}
|
||||
outputType := pkg.outputType(typ)
|
||||
// Remove any element before the last .
|
||||
outputType = outputType[strings.LastIndex(outputType, ".")+1:]
|
||||
if strings.HasSuffix(outputType, "ArgsOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "ArgsOutput") + "Output"
|
||||
}
|
||||
if elemConversion != "" {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
}
|
||||
return fmt.Sprintf("%s.To%s()%s", expr, outputType, elemConversion)
|
||||
}
|
||||
|
||||
func NeedsGoOutputVersion(f *schema.Function) bool {
|
||||
fPkg := f.Package
|
||||
|
||||
|
@ -1768,7 +1861,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
|
|||
return f.NeedsOutputVersion()
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
||||
importsAndAliases := map[string]string{}
|
||||
pkg.getImports(f, importsAndAliases)
|
||||
buffer := &bytes.Buffer{}
|
||||
|
@ -1779,12 +1872,14 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
|
|||
}
|
||||
|
||||
pkg.genHeader(buffer, imports, importsAndAliases)
|
||||
pkg.genFunction(buffer, f)
|
||||
if err := pkg.genFunction(buffer, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
pkg.genFunctionOutputVersion(buffer, f)
|
||||
return buffer.String()
|
||||
return buffer.String(), nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
||||
name := pkg.functionName(f)
|
||||
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
|
||||
|
||||
|
@ -1805,6 +1900,8 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
|
|||
var inputsVar string
|
||||
if f.Inputs == nil {
|
||||
inputsVar = "nil"
|
||||
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
inputsVar = "args.Defaults()"
|
||||
} else {
|
||||
inputsVar = "args"
|
||||
}
|
||||
|
@ -1828,19 +1925,38 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
|
|||
fmt.Fprintf(w, "\t}\n")
|
||||
|
||||
// Return the result.
|
||||
fmt.Fprintf(w, "\treturn &rv, nil\n")
|
||||
var retValue string
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
retValue = "rv.Defaults()"
|
||||
} else {
|
||||
retValue = "&rv"
|
||||
}
|
||||
fmt.Fprintf(w, "\treturn %s, nil\n", retValue)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// If there are argument and/or return types, emit them.
|
||||
if f.Inputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
fnInputsName := pkg.functionArgsTypeName(f)
|
||||
pkg.genPlainType(w, fnInputsName, f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnInputsName, f.Inputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
fnOutputsName := pkg.functionResultTypeName(f)
|
||||
pkg.genPlainType(w, fnOutputsName, f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnOutputsName, f.Outputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) functionName(f *schema.Function) string {
|
||||
|
@ -2019,16 +2135,24 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
|
|||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) error {
|
||||
contract.Assert(!obj.IsInputShape())
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
plainName := pkg.tokenToType(obj.Token)
|
||||
pkg.genPlainType(w, plainName, obj.Comment, "", obj.Properties)
|
||||
if !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, plainName, obj.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
pkg.genPlainType(w, pkg.tokenToType(obj.Token), obj.Comment, "", obj.Properties)
|
||||
pkg.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
|
||||
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
|
||||
|
@ -2100,16 +2224,16 @@ func (pkg *pkgContext) genNestedCollectionTypes(w io.Writer, types map[string]ma
|
|||
names = append(names, name)
|
||||
if strings.HasSuffix(name, "Array") {
|
||||
fmt.Fprintf(w, "type %s []%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName, false)
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName)
|
||||
}
|
||||
|
||||
if strings.HasSuffix(name, "Map") {
|
||||
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName, false)
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName)
|
||||
}
|
||||
pkg.genInputInterface(w, name)
|
||||
}
|
||||
|
@ -2236,18 +2360,13 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
name)
|
||||
if generateResourceContainerTypes {
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
name)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Register all output types
|
||||
|
@ -2262,12 +2381,9 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
}
|
||||
}
|
||||
|
||||
if generateResourceContainerTypes {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
}
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
@ -2670,6 +2786,7 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
packages: packages,
|
||||
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
|
||||
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
|
||||
disableObjectDefaults: goInfo.DisableObjectDefaults,
|
||||
}
|
||||
packages[mod] = pack
|
||||
}
|
||||
|
@ -2993,8 +3110,10 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
pkg.functions = append(pkg.functions, f)
|
||||
|
||||
name := tokenToName(f.Token)
|
||||
originalName := name
|
||||
if pkg.names.Has(name) {
|
||||
|
||||
if pkg.names.Has(name) ||
|
||||
pkg.names.Has(name+"Args") ||
|
||||
pkg.names.Has(name+"Result") {
|
||||
switch {
|
||||
case strings.HasPrefix(name, "New"):
|
||||
name = "Create" + name[3:]
|
||||
|
@ -3007,15 +3126,9 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
|
||||
if f.Inputs != nil {
|
||||
pkg.names.Add(name + "Args")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Args"] = name + "Args"
|
||||
}
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
pkg.names.Add(name + "Result")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Result"] = name + "Result"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3204,7 +3317,10 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
}
|
||||
|
||||
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
||||
code := pkg.genFunctionCodeFile(f)
|
||||
code, err := pkg.genFunctionCodeFile(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
setFile(fileName, code)
|
||||
}
|
||||
|
||||
|
@ -3244,7 +3360,9 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
|
||||
|
||||
for _, t := range pkg.types {
|
||||
pkg.genType(buffer, t)
|
||||
if err := pkg.genType(buffer, t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
delete(knownTypes, t)
|
||||
}
|
||||
|
||||
|
@ -3380,4 +3498,12 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %%s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
`
|
||||
|
|
|
@ -43,7 +43,9 @@ func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error
|
|||
|
||||
if len(pkg.types) > 0 {
|
||||
for _, t := range pkg.types {
|
||||
pkg.genType(buffer, t)
|
||||
if err := pkg.genType(buffer, t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
pkg.genTypeRegistrations(buffer, pkg.types)
|
||||
}
|
||||
|
|
|
@ -60,6 +60,10 @@ type GoPackageInfo struct {
|
|||
// Feature flag to disable generating input type registration. This is a
|
||||
// space saving measure.
|
||||
DisableInputTypeRegistrations bool `json:"disableInputTypeRegistrations,omitempty"`
|
||||
|
||||
// Feature flag to disable generating Pulumi object default functions. This is a
|
||||
// space saving measure.
|
||||
DisableObjectDefaults bool `json:"disableObjectDefaults,omitempty"`
|
||||
}
|
||||
|
||||
// Importer implements schema.Language for Go.
|
||||
|
|
|
@ -192,11 +192,22 @@ var sdkTests = []sdkTest{
|
|||
SkipCompileCheck: codegen.NewStringSet(nodejs),
|
||||
},
|
||||
{
|
||||
Directory: "env-helper",
|
||||
Description: "Ensure that eviromental helpers are generated (repro #8132)",
|
||||
Directory: "plain-object-defaults",
|
||||
Description: "Ensure that object defaults are generated (repro #8132)",
|
||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet),
|
||||
},
|
||||
{
|
||||
Directory: "plain-object-disable-defaults",
|
||||
Description: "Ensure that we can still compile safely when defaults are disabled",
|
||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet),
|
||||
},
|
||||
{
|
||||
Directory: "regress-8403",
|
||||
Description: "Regress pulumi/pulumi#8403",
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet, python, nodejs),
|
||||
},
|
||||
}
|
||||
|
||||
var genSDKOnly bool
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ type ModuleResourceInput interface {
|
|||
}
|
||||
|
||||
func (*ModuleResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
@ -90,7 +90,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
|
|||
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"plant-provider/tree/v1/init.go",
|
||||
"plant-provider/tree/v1/nursery.go",
|
||||
"plant-provider/tree/v1/pulumiEnums.go",
|
||||
"plant-provider/tree/v1/pulumiUtilities.go",
|
||||
"plant-provider/tree/v1/rubberTree.go"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -17,6 +17,19 @@ type Container struct {
|
|||
Size ContainerSize `pulumi:"size"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for Container
|
||||
func (val *Container) Defaults() *Container {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Brightness) {
|
||||
brightness_ := ContainerBrightness(1.0)
|
||||
tmp.Brightness = &brightness_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// ContainerInput is an input type that accepts ContainerArgs and ContainerOutput values.
|
||||
// You can construct a concrete instance of `ContainerInput` via:
|
||||
//
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ type NurseryInput interface {
|
|||
}
|
||||
|
||||
func (*Nursery) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Nursery)(nil))
|
||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Nursery) ToNurseryOutput() NurseryOutput {
|
||||
|
@ -97,7 +97,7 @@ func (i *Nursery) ToNurseryOutputWithContext(ctx context.Context) NurseryOutput
|
|||
type NurseryOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (NurseryOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Nursery)(nil))
|
||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type envParser func(v string) interface{}
|
||||
|
||||
func parseEnvBool(v string) interface{} {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func parseEnvInt(v string) interface{} {
|
||||
i, err := strconv.ParseInt(v, 0, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func parseEnvFloat(v string) interface{} {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func parseEnvStringArray(v string) interface{} {
|
||||
var result pulumi.StringArray
|
||||
for _, item := range strings.Split(v, ";") {
|
||||
result = append(result, pulumi.String(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
|
||||
for _, v := range vars {
|
||||
if value := os.Getenv(v); value != "" {
|
||||
if parser != nil {
|
||||
return parser(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// PkgVersion uses reflection to determine the version of the current package.
|
||||
func PkgVersion() (semver.Version, error) {
|
||||
type sentinal struct{}
|
||||
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
|
||||
re := regexp.MustCompile("^.*/pulumi-plant/sdk(/v\\d+)?")
|
||||
if match := re.FindStringSubmatch(pkgPath); match != nil {
|
||||
vStr := match[1]
|
||||
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
|
||||
return semver.Version{Major: 1}, nil
|
||||
}
|
||||
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
|
||||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
|
@ -29,16 +29,20 @@ func NewRubberTree(ctx *pulumi.Context,
|
|||
return nil, errors.New("missing one or more required arguments")
|
||||
}
|
||||
|
||||
if args.Diameter == nil {
|
||||
containerApplier := func(v plantprovider.Container) *plantprovider.Container { return v.Defaults() }
|
||||
if args.Container != nil {
|
||||
args.Container = args.Container.ToContainerPtrOutput().Elem().ApplyT(containerApplier).(plantprovider.ContainerPtrOutput)
|
||||
}
|
||||
if isZero(args.Diameter) {
|
||||
args.Diameter = Diameter(6.0)
|
||||
}
|
||||
if args.Farm == nil {
|
||||
if isZero(args.Farm) {
|
||||
args.Farm = pulumi.StringPtr("(unknown)")
|
||||
}
|
||||
if args.Size == nil {
|
||||
if isZero(args.Size) {
|
||||
args.Size = TreeSize("medium")
|
||||
}
|
||||
if args.Type == nil {
|
||||
if isZero(args.Type) {
|
||||
args.Type = RubberTreeVariety("Burgundy")
|
||||
}
|
||||
var resource RubberTree
|
||||
|
@ -103,7 +107,7 @@ type RubberTreeInput interface {
|
|||
}
|
||||
|
||||
func (*RubberTree) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*RubberTree)(nil))
|
||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
|
||||
|
@ -117,7 +121,7 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
|
|||
type RubberTreeOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RubberTreeOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*RubberTree)(nil))
|
||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {
|
||||
|
|
|
@ -77,7 +77,7 @@ type CatInput interface {
|
|||
}
|
||||
|
||||
func (*Cat) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Cat)(nil))
|
||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatOutput() CatOutput {
|
||||
|
@ -88,35 +88,6 @@ func (i *Cat) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
|||
return pulumi.ToOutputWithContext(ctx, i).(CatOutput)
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatPtrOutput() CatPtrOutput {
|
||||
return i.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
|
||||
}
|
||||
|
||||
type CatPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToCatPtrOutput() CatPtrOutput
|
||||
ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput
|
||||
}
|
||||
|
||||
type catPtrType CatArgs
|
||||
|
||||
func (*catPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil))
|
||||
}
|
||||
|
||||
func (i *catPtrType) ToCatPtrOutput() CatPtrOutput {
|
||||
return i.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *catPtrType) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
|
||||
}
|
||||
|
||||
// CatArrayInput is an input type that accepts CatArray and CatArrayOutput values.
|
||||
// You can construct a concrete instance of `CatArrayInput` via:
|
||||
//
|
||||
|
@ -170,7 +141,7 @@ func (i CatMap) ToCatMapOutputWithContext(ctx context.Context) CatMapOutput {
|
|||
type CatOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Cat)(nil))
|
||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatOutput() CatOutput {
|
||||
|
@ -181,44 +152,10 @@ func (o CatOutput) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatPtrOutput() CatPtrOutput {
|
||||
return o.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Cat) *Cat {
|
||||
return &v
|
||||
}).(CatPtrOutput)
|
||||
}
|
||||
|
||||
type CatPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil))
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) ToCatPtrOutput() CatPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) Elem() CatOutput {
|
||||
return o.ApplyT(func(v *Cat) Cat {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Cat
|
||||
return ret
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
type CatArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]Cat)(nil))
|
||||
return reflect.TypeOf((*[]*Cat)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o CatArrayOutput) ToCatArrayOutput() CatArrayOutput {
|
||||
|
@ -230,15 +167,15 @@ func (o CatArrayOutput) ToCatArrayOutputWithContext(ctx context.Context) CatArra
|
|||
}
|
||||
|
||||
func (o CatArrayOutput) Index(i pulumi.IntInput) CatOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Cat {
|
||||
return vs[0].([]Cat)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Cat {
|
||||
return vs[0].([]*Cat)[vs[1].(int)]
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
type CatMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]Cat)(nil))
|
||||
return reflect.TypeOf((*map[string]*Cat)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o CatMapOutput) ToCatMapOutput() CatMapOutput {
|
||||
|
@ -250,18 +187,16 @@ func (o CatMapOutput) ToCatMapOutputWithContext(ctx context.Context) CatMapOutpu
|
|||
}
|
||||
|
||||
func (o CatMapOutput) MapIndex(k pulumi.StringInput) CatOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Cat {
|
||||
return vs[0].(map[string]Cat)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Cat {
|
||||
return vs[0].(map[string]*Cat)[vs[1].(string)]
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatInput)(nil)).Elem(), &Cat{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatPtrInput)(nil)).Elem(), &Cat{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatArrayInput)(nil)).Elem(), CatArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatMapInput)(nil)).Elem(), CatMap{})
|
||||
pulumi.RegisterOutputType(CatOutput{})
|
||||
pulumi.RegisterOutputType(CatPtrOutput{})
|
||||
pulumi.RegisterOutputType(CatArrayOutput{})
|
||||
pulumi.RegisterOutputType(CatMapOutput{})
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ type ComponentInput interface {
|
|||
}
|
||||
|
||||
func (*Component) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Component)(nil))
|
||||
return reflect.TypeOf((**Component)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentOutput() ComponentOutput {
|
||||
|
@ -112,35 +112,6 @@ func (i *Component) ToComponentOutputWithContext(ctx context.Context) ComponentO
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput)
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return i.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
type ComponentPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToComponentPtrOutput() ComponentPtrOutput
|
||||
ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput
|
||||
}
|
||||
|
||||
type componentPtrType ComponentArgs
|
||||
|
||||
func (*componentPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil))
|
||||
}
|
||||
|
||||
func (i *componentPtrType) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return i.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *componentPtrType) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
// ComponentArrayInput is an input type that accepts ComponentArray and ComponentArrayOutput values.
|
||||
// You can construct a concrete instance of `ComponentArrayInput` via:
|
||||
//
|
||||
|
@ -194,7 +165,7 @@ func (i ComponentMap) ToComponentMapOutputWithContext(ctx context.Context) Compo
|
|||
type ComponentOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Component)(nil))
|
||||
return reflect.TypeOf((**Component)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentOutput() ComponentOutput {
|
||||
|
@ -205,44 +176,10 @@ func (o ComponentOutput) ToComponentOutputWithContext(ctx context.Context) Compo
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return o.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Component) *Component {
|
||||
return &v
|
||||
}).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
type ComponentPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil))
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) Elem() ComponentOutput {
|
||||
return o.ApplyT(func(v *Component) Component {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Component
|
||||
return ret
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
type ComponentArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]Component)(nil))
|
||||
return reflect.TypeOf((*[]*Component)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput {
|
||||
|
@ -254,15 +191,15 @@ func (o ComponentArrayOutput) ToComponentArrayOutputWithContext(ctx context.Cont
|
|||
}
|
||||
|
||||
func (o ComponentArrayOutput) Index(i pulumi.IntInput) ComponentOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Component {
|
||||
return vs[0].([]Component)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Component {
|
||||
return vs[0].([]*Component)[vs[1].(int)]
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
type ComponentMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]Component)(nil))
|
||||
return reflect.TypeOf((*map[string]*Component)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput {
|
||||
|
@ -274,18 +211,16 @@ func (o ComponentMapOutput) ToComponentMapOutputWithContext(ctx context.Context)
|
|||
}
|
||||
|
||||
func (o ComponentMapOutput) MapIndex(k pulumi.StringInput) ComponentOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Component {
|
||||
return vs[0].(map[string]Component)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Component {
|
||||
return vs[0].(map[string]*Component)[vs[1].(string)]
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentPtrInput)(nil)).Elem(), &Component{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentArrayInput)(nil)).Elem(), ComponentArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentMapInput)(nil)).Elem(), ComponentMap{})
|
||||
pulumi.RegisterOutputType(ComponentOutput{})
|
||||
pulumi.RegisterOutputType(ComponentPtrOutput{})
|
||||
pulumi.RegisterOutputType(ComponentArrayOutput{})
|
||||
pulumi.RegisterOutputType(ComponentMapOutput{})
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -59,39 +59,10 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderPtrOutput() ProviderPtrOutput
|
||||
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
|
||||
}
|
||||
|
||||
type providerPtrType ProviderArgs
|
||||
|
||||
func (*providerPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
@ -102,43 +73,7 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
|
||||
return &v
|
||||
}).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) Elem() ProviderOutput {
|
||||
return o.ApplyT(func(v *Provider) Provider {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Provider
|
||||
return ret
|
||||
}).(ProviderOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
pulumi.RegisterOutputType(ProviderPtrOutput{})
|
||||
}
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ type WorkloadInput interface {
|
|||
}
|
||||
|
||||
func (*Workload) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Workload)(nil))
|
||||
return reflect.TypeOf((**Workload)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadOutput() WorkloadOutput {
|
||||
|
@ -85,35 +85,6 @@ func (i *Workload) ToWorkloadOutputWithContext(ctx context.Context) WorkloadOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadOutput)
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return i.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
type WorkloadPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToWorkloadPtrOutput() WorkloadPtrOutput
|
||||
ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput
|
||||
}
|
||||
|
||||
type workloadPtrType WorkloadArgs
|
||||
|
||||
func (*workloadPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil))
|
||||
}
|
||||
|
||||
func (i *workloadPtrType) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return i.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *workloadPtrType) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
// WorkloadArrayInput is an input type that accepts WorkloadArray and WorkloadArrayOutput values.
|
||||
// You can construct a concrete instance of `WorkloadArrayInput` via:
|
||||
//
|
||||
|
@ -167,7 +138,7 @@ func (i WorkloadMap) ToWorkloadMapOutputWithContext(ctx context.Context) Workloa
|
|||
type WorkloadOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Workload)(nil))
|
||||
return reflect.TypeOf((**Workload)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadOutput() WorkloadOutput {
|
||||
|
@ -178,44 +149,10 @@ func (o WorkloadOutput) ToWorkloadOutputWithContext(ctx context.Context) Workloa
|
|||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return o.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Workload) *Workload {
|
||||
return &v
|
||||
}).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
type WorkloadPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil))
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) Elem() WorkloadOutput {
|
||||
return o.ApplyT(func(v *Workload) Workload {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Workload
|
||||
return ret
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
type WorkloadArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]Workload)(nil))
|
||||
return reflect.TypeOf((*[]*Workload)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o WorkloadArrayOutput) ToWorkloadArrayOutput() WorkloadArrayOutput {
|
||||
|
@ -227,15 +164,15 @@ func (o WorkloadArrayOutput) ToWorkloadArrayOutputWithContext(ctx context.Contex
|
|||
}
|
||||
|
||||
func (o WorkloadArrayOutput) Index(i pulumi.IntInput) WorkloadOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Workload {
|
||||
return vs[0].([]Workload)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Workload {
|
||||
return vs[0].([]*Workload)[vs[1].(int)]
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
type WorkloadMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]Workload)(nil))
|
||||
return reflect.TypeOf((*map[string]*Workload)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o WorkloadMapOutput) ToWorkloadMapOutput() WorkloadMapOutput {
|
||||
|
@ -247,18 +184,16 @@ func (o WorkloadMapOutput) ToWorkloadMapOutputWithContext(ctx context.Context) W
|
|||
}
|
||||
|
||||
func (o WorkloadMapOutput) MapIndex(k pulumi.StringInput) WorkloadOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Workload {
|
||||
return vs[0].(map[string]Workload)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Workload {
|
||||
return vs[0].(map[string]*Workload)[vs[1].(string)]
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadInput)(nil)).Elem(), &Workload{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadPtrInput)(nil)).Elem(), &Workload{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadArrayInput)(nil)).Elem(), WorkloadArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadMapInput)(nil)).Elem(), WorkloadMap{})
|
||||
pulumi.RegisterOutputType(WorkloadOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadPtrOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadArrayOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadMapOutput{})
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -59,39 +59,10 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderPtrOutput() ProviderPtrOutput
|
||||
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
|
||||
}
|
||||
|
||||
type providerPtrType ProviderArgs
|
||||
|
||||
func (*providerPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
@ -102,43 +73,7 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
|
||||
return &v
|
||||
}).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) Elem() ProviderOutput {
|
||||
return o.ApplyT(func(v *Provider) Provider {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Provider
|
||||
return ret
|
||||
}).(ProviderOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
pulumi.RegisterOutputType(ProviderPtrOutput{})
|
||||
}
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ type RegistryGeoReplicationInput interface {
|
|||
}
|
||||
|
||||
func (*RegistryGeoReplication) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*RegistryGeoReplication)(nil))
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
|
||||
|
@ -76,35 +76,6 @@ func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutputWithContext(ctx c
|
|||
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationOutput)
|
||||
}
|
||||
|
||||
func (i *RegistryGeoReplication) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
|
||||
return i.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *RegistryGeoReplication) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationPtrOutput)
|
||||
}
|
||||
|
||||
type RegistryGeoReplicationPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput
|
||||
ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput
|
||||
}
|
||||
|
||||
type registryGeoReplicationPtrType RegistryGeoReplicationArgs
|
||||
|
||||
func (*registryGeoReplicationPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (i *registryGeoReplicationPtrType) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
|
||||
return i.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *registryGeoReplicationPtrType) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationPtrOutput)
|
||||
}
|
||||
|
||||
// RegistryGeoReplicationArrayInput is an input type that accepts RegistryGeoReplicationArray and RegistryGeoReplicationArrayOutput values.
|
||||
// You can construct a concrete instance of `RegistryGeoReplicationArrayInput` via:
|
||||
//
|
||||
|
@ -158,7 +129,7 @@ func (i RegistryGeoReplicationMap) ToRegistryGeoReplicationMapOutputWithContext(
|
|||
type RegistryGeoReplicationOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RegistryGeoReplicationOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*RegistryGeoReplication)(nil))
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
|
||||
|
@ -169,44 +140,10 @@ func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutputWithContext(
|
|||
return o
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
|
||||
return o.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v RegistryGeoReplication) *RegistryGeoReplication {
|
||||
return &v
|
||||
}).(RegistryGeoReplicationPtrOutput)
|
||||
}
|
||||
|
||||
type RegistryGeoReplicationPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RegistryGeoReplicationPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationPtrOutput) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationPtrOutput) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationPtrOutput) Elem() RegistryGeoReplicationOutput {
|
||||
return o.ApplyT(func(v *RegistryGeoReplication) RegistryGeoReplication {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret RegistryGeoReplication
|
||||
return ret
|
||||
}).(RegistryGeoReplicationOutput)
|
||||
}
|
||||
|
||||
type RegistryGeoReplicationArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RegistryGeoReplicationArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]RegistryGeoReplication)(nil))
|
||||
return reflect.TypeOf((*[]*RegistryGeoReplication)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutput() RegistryGeoReplicationArrayOutput {
|
||||
|
@ -218,15 +155,15 @@ func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutputWi
|
|||
}
|
||||
|
||||
func (o RegistryGeoReplicationArrayOutput) Index(i pulumi.IntInput) RegistryGeoReplicationOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) RegistryGeoReplication {
|
||||
return vs[0].([]RegistryGeoReplication)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RegistryGeoReplication {
|
||||
return vs[0].([]*RegistryGeoReplication)[vs[1].(int)]
|
||||
}).(RegistryGeoReplicationOutput)
|
||||
}
|
||||
|
||||
type RegistryGeoReplicationMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RegistryGeoReplicationMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]RegistryGeoReplication)(nil))
|
||||
return reflect.TypeOf((*map[string]*RegistryGeoReplication)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutput() RegistryGeoReplicationMapOutput {
|
||||
|
@ -238,18 +175,16 @@ func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutputWithCo
|
|||
}
|
||||
|
||||
func (o RegistryGeoReplicationMapOutput) MapIndex(k pulumi.StringInput) RegistryGeoReplicationOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) RegistryGeoReplication {
|
||||
return vs[0].(map[string]RegistryGeoReplication)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RegistryGeoReplication {
|
||||
return vs[0].(map[string]*RegistryGeoReplication)[vs[1].(string)]
|
||||
}).(RegistryGeoReplicationOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationInput)(nil)).Elem(), &RegistryGeoReplication{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationPtrInput)(nil)).Elem(), &RegistryGeoReplication{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationArrayInput)(nil)).Elem(), RegistryGeoReplicationArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationMapInput)(nil)).Elem(), RegistryGeoReplicationMap{})
|
||||
pulumi.RegisterOutputType(RegistryGeoReplicationOutput{})
|
||||
pulumi.RegisterOutputType(RegistryGeoReplicationPtrOutput{})
|
||||
pulumi.RegisterOutputType(RegistryGeoReplicationArrayOutput{})
|
||||
pulumi.RegisterOutputType(RegistryGeoReplicationMapOutput{})
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Resource) ToResourceOutput() ResourceOutput {
|
||||
|
@ -87,7 +87,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
|
|||
type ResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -73,7 +73,7 @@ type ResourceInputResourceInput interface {
|
|||
}
|
||||
|
||||
func (*ResourceInputResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceInputResource)(nil))
|
||||
return reflect.TypeOf((**ResourceInputResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *ResourceInputResource) ToResourceInputResourceOutput() ResourceInputResourceOutput {
|
||||
|
@ -87,7 +87,7 @@ func (i *ResourceInputResource) ToResourceInputResourceOutputWithContext(ctx con
|
|||
type ResourceInputResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceInputResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceInputResource)(nil))
|
||||
return reflect.TypeOf((**ResourceInputResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceInputResourceOutput) ToResourceInputResourceOutput() ResourceInputResourceOutput {
|
||||
|
|
|
@ -82,7 +82,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Resource) ToResourceOutput() ResourceOutput {
|
||||
|
@ -96,7 +96,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
|
|||
type ResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Resource) ToResourceOutput() ResourceOutput {
|
||||
|
@ -96,7 +96,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
|
|||
type ResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ func (mocks) NewResource(args pulumi.MockResourceArgs) (string, resource.Propert
|
|||
}
|
||||
|
||||
func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
||||
if args.Token == "mypkg::listStorageAccountKeys" {
|
||||
|
||||
switch args.Token {
|
||||
case "mypkg::listStorageAccountKeys":
|
||||
targs := mypkg.ListStorageAccountKeysArgs{}
|
||||
for k, v := range args.Args {
|
||||
switch k {
|
||||
|
@ -72,12 +72,11 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
|||
"keys": result.Keys,
|
||||
}
|
||||
return resource.NewPropertyMapFromMap(outputs), nil
|
||||
}
|
||||
|
||||
if args.Token == "mypkg::funcWithDefaultValue" ||
|
||||
args.Token == "mypkg::funcWithAllOptionalInputs" ||
|
||||
args.Token == "mypkg::funcWithListParam" ||
|
||||
args.Token == "mypkg::funcWithDictParam" {
|
||||
case "mypkg::funcWithDefaultValue",
|
||||
"mypkg::funcWithAllOptionalInputs",
|
||||
"mypkg::funcWithListParam",
|
||||
"mypkg::funcWithDictParam":
|
||||
result := mypkg.FuncWithDefaultValueResult{
|
||||
R: fmt.Sprintf("%v", args.Args),
|
||||
}
|
||||
|
@ -85,9 +84,8 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
|||
"r": result.R,
|
||||
}
|
||||
return resource.NewPropertyMapFromMap(outputs), nil
|
||||
}
|
||||
|
||||
if args.Token == "mypkg::getIntegrationRuntimeObjectMetadatum" {
|
||||
case "mypkg::getIntegrationRuntimeObjectMetadatum":
|
||||
targs := mypkg.GetIntegrationRuntimeObjectMetadatumArgs{}
|
||||
for k, v := range args.Args {
|
||||
switch k {
|
||||
|
@ -151,16 +149,13 @@ func TestListStorageAccountKeysOutput(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO[pulumi/pulumi#7811]: it seems that default values are not
|
||||
// supported by Go codegen yet, hence we do not observe "B" populated
|
||||
// to default at all here.
|
||||
func TestFuncWithDefaultValueOutput(t *testing.T) {
|
||||
pulumiTest(t, func(ctx *pulumi.Context) error {
|
||||
output := mypkg.FuncWithDefaultValueOutput(ctx, mypkg.FuncWithDefaultValueOutputArgs{
|
||||
A: pulumi.String("my-a"),
|
||||
})
|
||||
r := waitOut(t, output.R())
|
||||
assert.Equal(t, "map[a:{my-a}]", r)
|
||||
assert.Equal(t, "map[a:{my-a} b:{b-default}]", r)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
// Check codegen of functions with default values.
|
||||
func FuncWithDefaultValue(ctx *pulumi.Context, args *FuncWithDefaultValueArgs, opts ...pulumi.InvokeOption) (*FuncWithDefaultValueResult, error) {
|
||||
var rv FuncWithDefaultValueResult
|
||||
err := ctx.Invoke("mypkg::funcWithDefaultValue", args, &rv, opts...)
|
||||
err := ctx.Invoke("mypkg::funcWithDefaultValue", args.Defaults(), &rv, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -25,6 +25,19 @@ type FuncWithDefaultValueArgs struct {
|
|||
B *string `pulumi:"b"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for FuncWithDefaultValueArgs
|
||||
func (val *FuncWithDefaultValueArgs) Defaults() *FuncWithDefaultValueArgs {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.B) {
|
||||
b_ := "b-default"
|
||||
tmp.B = &b_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
type FuncWithDefaultValueResult struct {
|
||||
R string `pulumi:"r"`
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -22,53 +22,53 @@ func NewModuleResource(ctx *pulumi.Context,
|
|||
return nil, errors.New("missing one or more required arguments")
|
||||
}
|
||||
|
||||
if args.Optional_bool == nil {
|
||||
if isZero(args.Optional_bool) {
|
||||
args.Optional_bool = pulumi.BoolPtr(true)
|
||||
}
|
||||
args.Optional_const = pulumi.StringPtr("val")
|
||||
if args.Optional_enum == nil {
|
||||
if isZero(args.Optional_enum) {
|
||||
args.Optional_enum = EnumThing(8)
|
||||
}
|
||||
if args.Optional_number == nil {
|
||||
if isZero(args.Optional_number) {
|
||||
args.Optional_number = pulumi.Float64Ptr(42.0)
|
||||
}
|
||||
if args.Optional_string == nil {
|
||||
if isZero(args.Optional_string) {
|
||||
args.Optional_string = pulumi.StringPtr("buzzer")
|
||||
}
|
||||
if args.Plain_optional_bool == nil {
|
||||
if isZero(args.Plain_optional_bool) {
|
||||
plain_optional_bool_ := true
|
||||
args.Plain_optional_bool = &plain_optional_bool_
|
||||
}
|
||||
plain_optional_const_ := "val"
|
||||
args.Plain_optional_const = &plain_optional_const_
|
||||
if args.Plain_optional_number == nil {
|
||||
if isZero(args.Plain_optional_number) {
|
||||
plain_optional_number_ := 42.0
|
||||
args.Plain_optional_number = &plain_optional_number_
|
||||
}
|
||||
if args.Plain_optional_string == nil {
|
||||
if isZero(args.Plain_optional_string) {
|
||||
plain_optional_string_ := "buzzer"
|
||||
args.Plain_optional_string = &plain_optional_string_
|
||||
}
|
||||
if args.Plain_required_bool == false {
|
||||
if isZero(args.Plain_required_bool) {
|
||||
args.Plain_required_bool = true
|
||||
}
|
||||
args.Plain_required_const = "val"
|
||||
if args.Plain_required_number == 0.0 {
|
||||
if isZero(args.Plain_required_number) {
|
||||
args.Plain_required_number = 42.0
|
||||
}
|
||||
if args.Plain_required_string == "" {
|
||||
if isZero(args.Plain_required_string) {
|
||||
args.Plain_required_string = "buzzer"
|
||||
}
|
||||
if args.Required_bool == nil {
|
||||
if isZero(args.Required_bool) {
|
||||
args.Required_bool = pulumi.Bool(true)
|
||||
}
|
||||
if args.Required_enum == nil {
|
||||
if isZero(args.Required_enum) {
|
||||
args.Required_enum = EnumThing(4)
|
||||
}
|
||||
if args.Required_number == nil {
|
||||
if isZero(args.Required_number) {
|
||||
args.Required_number = pulumi.Float64(42.0)
|
||||
}
|
||||
if args.Required_string == nil {
|
||||
if isZero(args.Required_string) {
|
||||
args.Required_string = pulumi.String("buzzer")
|
||||
}
|
||||
var resource ModuleResource
|
||||
|
@ -155,7 +155,7 @@ type ModuleResourceInput interface {
|
|||
}
|
||||
|
||||
func (*ModuleResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
@ -169,7 +169,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
|
|||
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
26
pkg/codegen/internal/test/testdata/plain-object-defaults/dotnet/Mod1/Inputs/TypArgs.cs
vendored
Normal file
26
pkg/codegen/internal/test/testdata/plain-object-defaults/dotnet/Mod1/Inputs/TypArgs.cs
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Pulumi.Serialization;
|
||||
|
||||
namespace Pulumi.Example.Mod1.Inputs
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// A test for namespaces (mod 1)
|
||||
/// </summary>
|
||||
public sealed class TypArgs : Pulumi.ResourceArgs
|
||||
{
|
||||
[Input("val")]
|
||||
public Input<string>? Val { get; set; }
|
||||
|
||||
public TypArgs()
|
||||
{
|
||||
Val = Utilities.GetEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") ?? "mod1";
|
||||
}
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
118
pkg/codegen/internal/test/testdata/plain-object-defaults/go-extras/tests/codegen_test.go
vendored
Normal file
118
pkg/codegen/internal/test/testdata/plain-object-defaults/go-extras/tests/codegen_test.go
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package codegentest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
|
||||
"plain-object-defaults/example"
|
||||
)
|
||||
|
||||
type mocks int
|
||||
|
||||
// We assert that default values were passed to our constuctor
|
||||
func (mocks) NewResource(args pulumi.MockResourceArgs) (string, resource.PropertyMap, error) {
|
||||
checkFloat64 := func(v resource.PropertyValue, k string, expected float64) {
|
||||
m := v.V.(resource.PropertyMap)
|
||||
if m[resource.PropertyKey(k)].V.(float64) != expected {
|
||||
panic(fmt.Sprintf("Expected %s to have value %.2f", k, expected))
|
||||
}
|
||||
}
|
||||
for k, v := range args.Inputs {
|
||||
switch k {
|
||||
case "kubeClientSettings":
|
||||
checkFloat64(v, "burst", 42)
|
||||
case "backupKubeClientSettings":
|
||||
checkFloat64(v, "qps", 7)
|
||||
}
|
||||
}
|
||||
return args.Name, args.Inputs.Copy(), nil
|
||||
}
|
||||
|
||||
func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
||||
panic("Call not supported")
|
||||
}
|
||||
|
||||
func TestObjectDefaults(t *testing.T) {
|
||||
path := "thePath"
|
||||
defaultDriver := "secret"
|
||||
kcs := example.HelmReleaseSettings{
|
||||
PluginsPath: &path,
|
||||
RequiredArg: "This is required",
|
||||
}
|
||||
withDefaults := kcs.Defaults()
|
||||
assert.Equal(t, kcs.RequiredArg, withDefaults.RequiredArg)
|
||||
assert.Equal(t, kcs.PluginsPath, withDefaults.PluginsPath)
|
||||
assert.Nil(t, kcs.Driver)
|
||||
assert.Equal(t, withDefaults.Driver, &defaultDriver)
|
||||
}
|
||||
|
||||
func TestTransitiveObjectDefaults(t *testing.T) {
|
||||
layered := example.LayeredType{
|
||||
Other: example.HelmReleaseSettings{},
|
||||
}
|
||||
withDefaults := layered.Defaults()
|
||||
assert.Equal(t, "secret", *withDefaults.Other.Driver)
|
||||
}
|
||||
|
||||
// We already have that defaults for resources. We test that they translate through objects.
|
||||
func TestDefaultResource(t *testing.T) {
|
||||
os.Setenv("PULUMI_K8S_CLIENT_BURST", "42")
|
||||
pulumi.Run(func(ctx *pulumi.Context) error {
|
||||
_, err := example.NewFoo(ctx, "foo", &example.FooArgs{
|
||||
KubeClientSettings: example.KubeClientSettingsPtr(&example.KubeClientSettingsArgs{}),
|
||||
BackupKubeClientSettings: &example.KubeClientSettingsArgs{Qps: pulumi.Float64(7)},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
return nil
|
||||
}, pulumi.WithMocks("example", "stack", mocks(0)))
|
||||
}
|
||||
|
||||
func waitOut(t *testing.T, output pulumi.Output) interface{} {
|
||||
result, err := waitOutput(output, 1*time.Second)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func waitOutput(output pulumi.Output, timeout time.Duration) (interface{}, error) {
|
||||
c := make(chan interface{}, 2)
|
||||
output.ApplyT(func(v interface{}) interface{} {
|
||||
c <- v
|
||||
return v
|
||||
})
|
||||
var timeoutMarker *int = new(int)
|
||||
go func() {
|
||||
time.Sleep(timeout)
|
||||
c <- timeoutMarker
|
||||
}()
|
||||
|
||||
result := <-c
|
||||
if result == timeoutMarker {
|
||||
return nil, fmt.Errorf("Timed out waiting for pulumi.Output after %v", timeout)
|
||||
} else {
|
||||
return result, nil
|
||||
}
|
||||
}
|
16
pkg/codegen/internal/test/testdata/plain-object-defaults/go/codegen-manifest.json
vendored
Normal file
16
pkg/codegen/internal/test/testdata/plain-object-defaults/go/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"example/doc.go",
|
||||
"example/foo.go",
|
||||
"example/funcWithAllOptionalInputs.go",
|
||||
"example/init.go",
|
||||
"example/mod1/pulumiTypes.go",
|
||||
"example/mod1/pulumiUtilities.go",
|
||||
"example/mod2/pulumiTypes.go",
|
||||
"example/mod2/pulumiUtilities.go",
|
||||
"example/moduleTest.go",
|
||||
"example/provider.go",
|
||||
"example/pulumiTypes.go",
|
||||
"example/pulumiUtilities.go"
|
||||
]
|
||||
}
|
134
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/foo.go
vendored
Normal file
134
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/foo.go
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
// test new feature with resoruces
|
||||
type Foo struct {
|
||||
pulumi.CustomResourceState
|
||||
|
||||
// A test for plain types
|
||||
DefaultKubeClientSettings KubeClientSettingsPtrOutput `pulumi:"defaultKubeClientSettings"`
|
||||
}
|
||||
|
||||
// NewFoo registers a new resource with the given unique name, arguments, and options.
|
||||
func NewFoo(ctx *pulumi.Context,
|
||||
name string, args *FooArgs, opts ...pulumi.ResourceOption) (*Foo, error) {
|
||||
if args == nil {
|
||||
return nil, errors.New("missing one or more required arguments")
|
||||
}
|
||||
|
||||
if args.BackupKubeClientSettings == nil {
|
||||
return nil, errors.New("invalid value for required argument 'BackupKubeClientSettings'")
|
||||
}
|
||||
backupKubeClientSettingsApplier := func(v KubeClientSettings) *KubeClientSettings { return v.Defaults() }
|
||||
args.BackupKubeClientSettings = args.BackupKubeClientSettings.ToKubeClientSettingsOutput().ApplyT(backupKubeClientSettingsApplier).(KubeClientSettingsPtrOutput).Elem()
|
||||
kubeClientSettingsApplier := func(v KubeClientSettings) *KubeClientSettings { return v.Defaults() }
|
||||
if args.KubeClientSettings != nil {
|
||||
args.KubeClientSettings = args.KubeClientSettings.ToKubeClientSettingsPtrOutput().Elem().ApplyT(kubeClientSettingsApplier).(KubeClientSettingsPtrOutput)
|
||||
}
|
||||
settingsApplier := func(v LayeredType) *LayeredType { return v.Defaults() }
|
||||
if args.Settings != nil {
|
||||
args.Settings = args.Settings.ToLayeredTypePtrOutput().Elem().ApplyT(settingsApplier).(LayeredTypePtrOutput)
|
||||
}
|
||||
var resource Foo
|
||||
err := ctx.RegisterResource("example:index:Foo", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// GetFoo gets an existing Foo resource's state with the given name, ID, and optional
|
||||
// state properties that are used to uniquely qualify the lookup (nil if not required).
|
||||
func GetFoo(ctx *pulumi.Context,
|
||||
name string, id pulumi.IDInput, state *FooState, opts ...pulumi.ResourceOption) (*Foo, error) {
|
||||
var resource Foo
|
||||
err := ctx.ReadResource("example:index:Foo", name, id, state, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// Input properties used for looking up and filtering Foo resources.
|
||||
type fooState struct {
|
||||
}
|
||||
|
||||
type FooState struct {
|
||||
}
|
||||
|
||||
func (FooState) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*fooState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type fooArgs struct {
|
||||
Argument *string `pulumi:"argument"`
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
BackupKubeClientSettings KubeClientSettings `pulumi:"backupKubeClientSettings"`
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
KubeClientSettings *KubeClientSettings `pulumi:"kubeClientSettings"`
|
||||
// describing things
|
||||
Settings *LayeredType `pulumi:"settings"`
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a Foo resource.
|
||||
type FooArgs struct {
|
||||
Argument *string
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
BackupKubeClientSettings KubeClientSettingsInput
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
KubeClientSettings KubeClientSettingsPtrInput
|
||||
// describing things
|
||||
Settings LayeredTypePtrInput
|
||||
}
|
||||
|
||||
func (FooArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*fooArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type FooInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToFooOutput() FooOutput
|
||||
ToFooOutputWithContext(ctx context.Context) FooOutput
|
||||
}
|
||||
|
||||
func (*Foo) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Foo) ToFooOutput() FooOutput {
|
||||
return i.ToFooOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Foo) ToFooOutputWithContext(ctx context.Context) FooOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(FooOutput)
|
||||
}
|
||||
|
||||
type FooOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (FooOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o FooOutput) ToFooOutput() FooOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o FooOutput) ToFooOutputWithContext(ctx context.Context) FooOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*FooInput)(nil)).Elem(), &Foo{})
|
||||
pulumi.RegisterOutputType(FooOutput{})
|
||||
}
|
89
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/funcWithAllOptionalInputs.go
vendored
Normal file
89
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/funcWithAllOptionalInputs.go
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
// Check codegen of functions with all optional inputs.
|
||||
func FuncWithAllOptionalInputs(ctx *pulumi.Context, args *FuncWithAllOptionalInputsArgs, opts ...pulumi.InvokeOption) (*FuncWithAllOptionalInputsResult, error) {
|
||||
var rv FuncWithAllOptionalInputsResult
|
||||
err := ctx.Invoke("mypkg::funcWithAllOptionalInputs", args.Defaults(), &rv, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rv, nil
|
||||
}
|
||||
|
||||
type FuncWithAllOptionalInputsArgs struct {
|
||||
// Property A
|
||||
A *HelmReleaseSettings `pulumi:"a"`
|
||||
// Property B
|
||||
B *string `pulumi:"b"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for FuncWithAllOptionalInputsArgs
|
||||
func (val *FuncWithAllOptionalInputsArgs) Defaults() *FuncWithAllOptionalInputsArgs {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
tmp.A = tmp.A.Defaults()
|
||||
|
||||
if isZero(tmp.B) {
|
||||
b_ := "defValue"
|
||||
tmp.B = &b_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
type FuncWithAllOptionalInputsResult struct {
|
||||
R string `pulumi:"r"`
|
||||
}
|
||||
|
||||
func FuncWithAllOptionalInputsOutput(ctx *pulumi.Context, args FuncWithAllOptionalInputsOutputArgs, opts ...pulumi.InvokeOption) FuncWithAllOptionalInputsResultOutput {
|
||||
return pulumi.ToOutputWithContext(context.Background(), args).
|
||||
ApplyT(func(v interface{}) (FuncWithAllOptionalInputsResult, error) {
|
||||
args := v.(FuncWithAllOptionalInputsArgs)
|
||||
r, err := FuncWithAllOptionalInputs(ctx, &args, opts...)
|
||||
return *r, err
|
||||
}).(FuncWithAllOptionalInputsResultOutput)
|
||||
}
|
||||
|
||||
type FuncWithAllOptionalInputsOutputArgs struct {
|
||||
// Property A
|
||||
A HelmReleaseSettingsPtrInput `pulumi:"a"`
|
||||
// Property B
|
||||
B pulumi.StringPtrInput `pulumi:"b"`
|
||||
}
|
||||
|
||||
func (FuncWithAllOptionalInputsOutputArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*FuncWithAllOptionalInputsArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type FuncWithAllOptionalInputsResultOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (FuncWithAllOptionalInputsResultOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*FuncWithAllOptionalInputsResult)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o FuncWithAllOptionalInputsResultOutput) ToFuncWithAllOptionalInputsResultOutput() FuncWithAllOptionalInputsResultOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o FuncWithAllOptionalInputsResultOutput) ToFuncWithAllOptionalInputsResultOutputWithContext(ctx context.Context) FuncWithAllOptionalInputsResultOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o FuncWithAllOptionalInputsResultOutput) R() pulumi.StringOutput {
|
||||
return o.ApplyT(func(v FuncWithAllOptionalInputsResult) string { return v.R }).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(FuncWithAllOptionalInputsResultOutput{})
|
||||
}
|
167
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod1/pulumiTypes.go
vendored
Normal file
167
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod1/pulumiTypes.go
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mod1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
// A test for namespaces (mod 1)
|
||||
type Typ struct {
|
||||
Val *string `pulumi:"val"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for Typ
|
||||
func (val *Typ) Defaults() *Typ {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Val) {
|
||||
val_ := getEnvOrDefault("mod1", nil, "PULUMI_EXAMPLE_MOD1_DEFAULT").(string)
|
||||
tmp.Val = &val_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// TypInput is an input type that accepts TypArgs and TypOutput values.
|
||||
// You can construct a concrete instance of `TypInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
type TypInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypOutput() TypOutput
|
||||
ToTypOutputWithContext(context.Context) TypOutput
|
||||
}
|
||||
|
||||
// A test for namespaces (mod 1)
|
||||
type TypArgs struct {
|
||||
Val pulumi.StringPtrInput `pulumi:"val"`
|
||||
}
|
||||
|
||||
func (TypArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutput() TypOutput {
|
||||
return i.ToTypOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput)
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values.
|
||||
// You can construct a concrete instance of `TypPtrInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type TypPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypPtrOutput() TypPtrOutput
|
||||
ToTypPtrOutputWithContext(context.Context) TypPtrOutput
|
||||
}
|
||||
|
||||
type typPtrType TypArgs
|
||||
|
||||
func TypPtr(v *TypArgs) TypPtrInput {
|
||||
return (*typPtrType)(v)
|
||||
}
|
||||
|
||||
func (*typPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput)
|
||||
}
|
||||
|
||||
// A test for namespaces (mod 1)
|
||||
type TypOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutput() TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ {
|
||||
return &v
|
||||
}).(TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type TypPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Elem() TypOutput {
|
||||
return o.ApplyT(func(v *Typ) Typ {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Typ
|
||||
return ret
|
||||
}).(TypOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Val
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterOutputType(TypOutput{})
|
||||
pulumi.RegisterOutputType(TypPtrOutput{})
|
||||
}
|
85
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod1/pulumiUtilities.go
vendored
Normal file
85
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod1/pulumiUtilities.go
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mod1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type envParser func(v string) interface{}
|
||||
|
||||
func parseEnvBool(v string) interface{} {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func parseEnvInt(v string) interface{} {
|
||||
i, err := strconv.ParseInt(v, 0, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func parseEnvFloat(v string) interface{} {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func parseEnvStringArray(v string) interface{} {
|
||||
var result pulumi.StringArray
|
||||
for _, item := range strings.Split(v, ";") {
|
||||
result = append(result, pulumi.String(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
|
||||
for _, v := range vars {
|
||||
if value := os.Getenv(v); value != "" {
|
||||
if parser != nil {
|
||||
return parser(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// PkgVersion uses reflection to determine the version of the current package.
|
||||
func PkgVersion() (semver.Version, error) {
|
||||
type sentinal struct{}
|
||||
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
|
||||
re := regexp.MustCompile("^.*/pulumi-example/sdk(/v\\d+)?")
|
||||
if match := re.FindStringSubmatch(pkgPath); match != nil {
|
||||
vStr := match[1]
|
||||
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
|
||||
return semver.Version{Major: 1}, nil
|
||||
}
|
||||
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
|
||||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
185
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod2/pulumiTypes.go
vendored
Normal file
185
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod2/pulumiTypes.go
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mod2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-defaults/example/mod1"
|
||||
)
|
||||
|
||||
// A test for namespaces (mod 2)
|
||||
type Typ struct {
|
||||
Mod1 *mod1.Typ `pulumi:"mod1"`
|
||||
Val *string `pulumi:"val"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for Typ
|
||||
func (val *Typ) Defaults() *Typ {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
tmp.Mod1 = tmp.Mod1.Defaults()
|
||||
|
||||
if isZero(tmp.Val) {
|
||||
val_ := "mod2"
|
||||
tmp.Val = &val_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// TypInput is an input type that accepts TypArgs and TypOutput values.
|
||||
// You can construct a concrete instance of `TypInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
type TypInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypOutput() TypOutput
|
||||
ToTypOutputWithContext(context.Context) TypOutput
|
||||
}
|
||||
|
||||
// A test for namespaces (mod 2)
|
||||
type TypArgs struct {
|
||||
Mod1 mod1.TypPtrInput `pulumi:"mod1"`
|
||||
Val pulumi.StringPtrInput `pulumi:"val"`
|
||||
}
|
||||
|
||||
func (TypArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutput() TypOutput {
|
||||
return i.ToTypOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput)
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values.
|
||||
// You can construct a concrete instance of `TypPtrInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type TypPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypPtrOutput() TypPtrOutput
|
||||
ToTypPtrOutputWithContext(context.Context) TypPtrOutput
|
||||
}
|
||||
|
||||
type typPtrType TypArgs
|
||||
|
||||
func TypPtr(v *TypArgs) TypPtrInput {
|
||||
return (*typPtrType)(v)
|
||||
}
|
||||
|
||||
func (*typPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput)
|
||||
}
|
||||
|
||||
// A test for namespaces (mod 2)
|
||||
type TypOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutput() TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ {
|
||||
return &v
|
||||
}).(TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Mod1() mod1.TypPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *mod1.Typ { return v.Mod1 }).(mod1.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type TypPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Elem() TypOutput {
|
||||
return o.ApplyT(func(v *Typ) Typ {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Typ
|
||||
return ret
|
||||
}).(TypOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Mod1() mod1.TypPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *mod1.Typ {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Mod1
|
||||
}).(mod1.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Val
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterOutputType(TypOutput{})
|
||||
pulumi.RegisterOutputType(TypPtrOutput{})
|
||||
}
|
85
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod2/pulumiUtilities.go
vendored
Normal file
85
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod2/pulumiUtilities.go
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package mod2
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type envParser func(v string) interface{}
|
||||
|
||||
func parseEnvBool(v string) interface{} {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func parseEnvInt(v string) interface{} {
|
||||
i, err := strconv.ParseInt(v, 0, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func parseEnvFloat(v string) interface{} {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func parseEnvStringArray(v string) interface{} {
|
||||
var result pulumi.StringArray
|
||||
for _, item := range strings.Split(v, ";") {
|
||||
result = append(result, pulumi.String(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
|
||||
for _, v := range vars {
|
||||
if value := os.Getenv(v); value != "" {
|
||||
if parser != nil {
|
||||
return parser(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// PkgVersion uses reflection to determine the version of the current package.
|
||||
func PkgVersion() (semver.Version, error) {
|
||||
type sentinal struct{}
|
||||
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
|
||||
re := regexp.MustCompile("^.*/pulumi-example/sdk(/v\\d+)?")
|
||||
if match := re.FindStringSubmatch(pkgPath); match != nil {
|
||||
vStr := match[1]
|
||||
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
|
||||
return semver.Version{Major: 1}, nil
|
||||
}
|
||||
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
|
||||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
115
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/moduleTest.go
vendored
Normal file
115
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/moduleTest.go
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-defaults/example/mod1"
|
||||
)
|
||||
|
||||
type ModuleTest struct {
|
||||
pulumi.CustomResourceState
|
||||
}
|
||||
|
||||
// NewModuleTest registers a new resource with the given unique name, arguments, and options.
|
||||
func NewModuleTest(ctx *pulumi.Context,
|
||||
name string, args *ModuleTestArgs, opts ...pulumi.ResourceOption) (*ModuleTest, error) {
|
||||
if args == nil {
|
||||
args = &ModuleTestArgs{}
|
||||
}
|
||||
|
||||
mod1Applier := func(v mod1.Typ) *mod1.Typ { return v.Defaults() }
|
||||
if args.Mod1 != nil {
|
||||
args.Mod1 = args.Mod1.ToTypPtrOutput().Elem().ApplyT(mod1Applier).(mod1.TypPtrOutput)
|
||||
}
|
||||
valApplier := func(v Typ) *Typ { return v.Defaults() }
|
||||
if args.Val != nil {
|
||||
args.Val = args.Val.ToTypPtrOutput().Elem().ApplyT(valApplier).(TypPtrOutput)
|
||||
}
|
||||
var resource ModuleTest
|
||||
err := ctx.RegisterResource("example:index:moduleTest", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// GetModuleTest gets an existing ModuleTest resource's state with the given name, ID, and optional
|
||||
// state properties that are used to uniquely qualify the lookup (nil if not required).
|
||||
func GetModuleTest(ctx *pulumi.Context,
|
||||
name string, id pulumi.IDInput, state *ModuleTestState, opts ...pulumi.ResourceOption) (*ModuleTest, error) {
|
||||
var resource ModuleTest
|
||||
err := ctx.ReadResource("example:index:moduleTest", name, id, state, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// Input properties used for looking up and filtering ModuleTest resources.
|
||||
type moduleTestState struct {
|
||||
}
|
||||
|
||||
type ModuleTestState struct {
|
||||
}
|
||||
|
||||
func (ModuleTestState) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*moduleTestState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type moduleTestArgs struct {
|
||||
Mod1 *mod1.Typ `pulumi:"mod1"`
|
||||
Val *Typ `pulumi:"val"`
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a ModuleTest resource.
|
||||
type ModuleTestArgs struct {
|
||||
Mod1 mod1.TypPtrInput
|
||||
Val TypPtrInput
|
||||
}
|
||||
|
||||
func (ModuleTestArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*moduleTestArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ModuleTestInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToModuleTestOutput() ModuleTestOutput
|
||||
ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput
|
||||
}
|
||||
|
||||
func (*ModuleTest) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
|
||||
return i.ToModuleTestOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ModuleTestOutput)
|
||||
}
|
||||
|
||||
type ModuleTestOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleTestOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ModuleTestOutput) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ModuleTestInput)(nil)).Elem(), &ModuleTest{})
|
||||
pulumi.RegisterOutputType(ModuleTestOutput{})
|
||||
}
|
88
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/provider.go
vendored
Normal file
88
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/provider.go
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
// The provider type for the kubernetes package.
|
||||
type Provider struct {
|
||||
pulumi.ProviderResourceState
|
||||
}
|
||||
|
||||
// NewProvider registers a new resource with the given unique name, arguments, and options.
|
||||
func NewProvider(ctx *pulumi.Context,
|
||||
name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {
|
||||
if args == nil {
|
||||
args = &ProviderArgs{}
|
||||
}
|
||||
|
||||
helmReleaseSettingsApplier := func(v HelmReleaseSettings) *HelmReleaseSettings { return v.Defaults() }
|
||||
if args.HelmReleaseSettings != nil {
|
||||
args.HelmReleaseSettings = args.HelmReleaseSettings.ToHelmReleaseSettingsPtrOutput().Elem().ApplyT(helmReleaseSettingsApplier).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
var resource Provider
|
||||
err := ctx.RegisterResource("pulumi:providers:example", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
type providerArgs struct {
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
||||
HelmReleaseSettings *HelmReleaseSettings `pulumi:"helmReleaseSettings"`
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a Provider resource.
|
||||
type ProviderArgs struct {
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
||||
HelmReleaseSettings HelmReleaseSettingsPtrInput
|
||||
}
|
||||
|
||||
func (ProviderArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*providerArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ProviderInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderOutput() ProviderOutput
|
||||
ToProviderOutputWithContext(ctx context.Context) ProviderOutput
|
||||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
return i.ToProviderOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
}
|
856
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/pulumiTypes.go
vendored
Normal file
856
pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/pulumiTypes.go
vendored
Normal file
|
@ -0,0 +1,856 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-defaults/example/mod1"
|
||||
"plain-object-defaults/example/mod2"
|
||||
)
|
||||
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
||||
type HelmReleaseSettings struct {
|
||||
// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
Driver *string `pulumi:"driver"`
|
||||
// The path to the helm plugins directory.
|
||||
PluginsPath *string `pulumi:"pluginsPath"`
|
||||
// to test required args
|
||||
RequiredArg string `pulumi:"requiredArg"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for HelmReleaseSettings
|
||||
func (val *HelmReleaseSettings) Defaults() *HelmReleaseSettings {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Driver) {
|
||||
driver_ := getEnvOrDefault("secret", nil, "PULUMI_K8S_HELM_DRIVER").(string)
|
||||
tmp.Driver = &driver_
|
||||
}
|
||||
if isZero(tmp.PluginsPath) {
|
||||
pluginsPath_ := getEnvOrDefault("", nil, "PULUMI_K8S_HELM_PLUGINS_PATH").(string)
|
||||
tmp.PluginsPath = &pluginsPath_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// HelmReleaseSettingsInput is an input type that accepts HelmReleaseSettingsArgs and HelmReleaseSettingsOutput values.
|
||||
// You can construct a concrete instance of `HelmReleaseSettingsInput` via:
|
||||
//
|
||||
// HelmReleaseSettingsArgs{...}
|
||||
type HelmReleaseSettingsInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput
|
||||
ToHelmReleaseSettingsOutputWithContext(context.Context) HelmReleaseSettingsOutput
|
||||
}
|
||||
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
||||
type HelmReleaseSettingsArgs struct {
|
||||
// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
Driver pulumi.StringPtrInput `pulumi:"driver"`
|
||||
// The path to the helm plugins directory.
|
||||
PluginsPath pulumi.StringPtrInput `pulumi:"pluginsPath"`
|
||||
// to test required args
|
||||
RequiredArg pulumi.StringInput `pulumi:"requiredArg"`
|
||||
}
|
||||
|
||||
func (HelmReleaseSettingsArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*HelmReleaseSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput {
|
||||
return i.ToHelmReleaseSettingsOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsOutputWithContext(ctx context.Context) HelmReleaseSettingsOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsOutput)
|
||||
}
|
||||
|
||||
func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput {
|
||||
return i.ToHelmReleaseSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsOutput).ToHelmReleaseSettingsPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// HelmReleaseSettingsPtrInput is an input type that accepts HelmReleaseSettingsArgs, HelmReleaseSettingsPtr and HelmReleaseSettingsPtrOutput values.
|
||||
// You can construct a concrete instance of `HelmReleaseSettingsPtrInput` via:
|
||||
//
|
||||
// HelmReleaseSettingsArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type HelmReleaseSettingsPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput
|
||||
ToHelmReleaseSettingsPtrOutputWithContext(context.Context) HelmReleaseSettingsPtrOutput
|
||||
}
|
||||
|
||||
type helmReleaseSettingsPtrType HelmReleaseSettingsArgs
|
||||
|
||||
func HelmReleaseSettingsPtr(v *HelmReleaseSettingsArgs) HelmReleaseSettingsPtrInput {
|
||||
return (*helmReleaseSettingsPtrType)(v)
|
||||
}
|
||||
|
||||
func (*helmReleaseSettingsPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**HelmReleaseSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *helmReleaseSettingsPtrType) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput {
|
||||
return i.ToHelmReleaseSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *helmReleaseSettingsPtrType) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
||||
type HelmReleaseSettingsOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (HelmReleaseSettingsOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*HelmReleaseSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsOutputWithContext(ctx context.Context) HelmReleaseSettingsOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput {
|
||||
return o.ToHelmReleaseSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v HelmReleaseSettings) *HelmReleaseSettings {
|
||||
return &v
|
||||
}).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
func (o HelmReleaseSettingsOutput) Driver() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v HelmReleaseSettings) *string { return v.Driver }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// The path to the helm plugins directory.
|
||||
func (o HelmReleaseSettingsOutput) PluginsPath() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v HelmReleaseSettings) *string { return v.PluginsPath }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// to test required args
|
||||
func (o HelmReleaseSettingsOutput) RequiredArg() pulumi.StringOutput {
|
||||
return o.ApplyT(func(v HelmReleaseSettings) string { return v.RequiredArg }).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
type HelmReleaseSettingsPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (HelmReleaseSettingsPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**HelmReleaseSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsPtrOutput) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsPtrOutput) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o HelmReleaseSettingsPtrOutput) Elem() HelmReleaseSettingsOutput {
|
||||
return o.ApplyT(func(v *HelmReleaseSettings) HelmReleaseSettings {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret HelmReleaseSettings
|
||||
return ret
|
||||
}).(HelmReleaseSettingsOutput)
|
||||
}
|
||||
|
||||
// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
func (o HelmReleaseSettingsPtrOutput) Driver() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *HelmReleaseSettings) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Driver
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// The path to the helm plugins directory.
|
||||
func (o HelmReleaseSettingsPtrOutput) PluginsPath() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *HelmReleaseSettings) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.PluginsPath
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// to test required args
|
||||
func (o HelmReleaseSettingsPtrOutput) RequiredArg() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *HelmReleaseSettings) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return &v.RequiredArg
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
type KubeClientSettings struct {
|
||||
// Maximum burst for throttle. Default value is 10.
|
||||
Burst *int `pulumi:"burst"`
|
||||
// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
|
||||
Qps *float64 `pulumi:"qps"`
|
||||
RecTest *KubeClientSettings `pulumi:"recTest"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for KubeClientSettings
|
||||
func (val *KubeClientSettings) Defaults() *KubeClientSettings {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Burst) {
|
||||
burst_ := getEnvOrDefault(0, parseEnvInt, "PULUMI_K8S_CLIENT_BURST").(int)
|
||||
tmp.Burst = &burst_
|
||||
}
|
||||
if isZero(tmp.Qps) {
|
||||
qps_ := getEnvOrDefault(0.0, parseEnvFloat, "PULUMI_K8S_CLIENT_QPS").(float64)
|
||||
tmp.Qps = &qps_
|
||||
}
|
||||
tmp.RecTest = tmp.RecTest.Defaults()
|
||||
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// KubeClientSettingsInput is an input type that accepts KubeClientSettingsArgs and KubeClientSettingsOutput values.
|
||||
// You can construct a concrete instance of `KubeClientSettingsInput` via:
|
||||
//
|
||||
// KubeClientSettingsArgs{...}
|
||||
type KubeClientSettingsInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToKubeClientSettingsOutput() KubeClientSettingsOutput
|
||||
ToKubeClientSettingsOutputWithContext(context.Context) KubeClientSettingsOutput
|
||||
}
|
||||
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
type KubeClientSettingsArgs struct {
|
||||
// Maximum burst for throttle. Default value is 10.
|
||||
Burst pulumi.IntPtrInput `pulumi:"burst"`
|
||||
// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
|
||||
Qps pulumi.Float64PtrInput `pulumi:"qps"`
|
||||
RecTest KubeClientSettingsPtrInput `pulumi:"recTest"`
|
||||
}
|
||||
|
||||
func (KubeClientSettingsArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*KubeClientSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i KubeClientSettingsArgs) ToKubeClientSettingsOutput() KubeClientSettingsOutput {
|
||||
return i.ToKubeClientSettingsOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i KubeClientSettingsArgs) ToKubeClientSettingsOutputWithContext(ctx context.Context) KubeClientSettingsOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsOutput)
|
||||
}
|
||||
|
||||
func (i KubeClientSettingsArgs) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput {
|
||||
return i.ToKubeClientSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i KubeClientSettingsArgs) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsOutput).ToKubeClientSettingsPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// KubeClientSettingsPtrInput is an input type that accepts KubeClientSettingsArgs, KubeClientSettingsPtr and KubeClientSettingsPtrOutput values.
|
||||
// You can construct a concrete instance of `KubeClientSettingsPtrInput` via:
|
||||
//
|
||||
// KubeClientSettingsArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type KubeClientSettingsPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput
|
||||
ToKubeClientSettingsPtrOutputWithContext(context.Context) KubeClientSettingsPtrOutput
|
||||
}
|
||||
|
||||
type kubeClientSettingsPtrType KubeClientSettingsArgs
|
||||
|
||||
func KubeClientSettingsPtr(v *KubeClientSettingsArgs) KubeClientSettingsPtrInput {
|
||||
return (*kubeClientSettingsPtrType)(v)
|
||||
}
|
||||
|
||||
func (*kubeClientSettingsPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**KubeClientSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *kubeClientSettingsPtrType) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput {
|
||||
return i.ToKubeClientSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *kubeClientSettingsPtrType) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// Options for tuning the Kubernetes client used by a Provider.
|
||||
type KubeClientSettingsOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (KubeClientSettingsOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*KubeClientSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsOutput) ToKubeClientSettingsOutput() KubeClientSettingsOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsOutput) ToKubeClientSettingsOutputWithContext(ctx context.Context) KubeClientSettingsOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsOutput) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput {
|
||||
return o.ToKubeClientSettingsPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsOutput) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v KubeClientSettings) *KubeClientSettings {
|
||||
return &v
|
||||
}).(KubeClientSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// Maximum burst for throttle. Default value is 10.
|
||||
func (o KubeClientSettingsOutput) Burst() pulumi.IntPtrOutput {
|
||||
return o.ApplyT(func(v KubeClientSettings) *int { return v.Burst }).(pulumi.IntPtrOutput)
|
||||
}
|
||||
|
||||
// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
|
||||
func (o KubeClientSettingsOutput) Qps() pulumi.Float64PtrOutput {
|
||||
return o.ApplyT(func(v KubeClientSettings) *float64 { return v.Qps }).(pulumi.Float64PtrOutput)
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsOutput) RecTest() KubeClientSettingsPtrOutput {
|
||||
return o.ApplyT(func(v KubeClientSettings) *KubeClientSettings { return v.RecTest }).(KubeClientSettingsPtrOutput)
|
||||
}
|
||||
|
||||
type KubeClientSettingsPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (KubeClientSettingsPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**KubeClientSettings)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsPtrOutput) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsPtrOutput) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsPtrOutput) Elem() KubeClientSettingsOutput {
|
||||
return o.ApplyT(func(v *KubeClientSettings) KubeClientSettings {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret KubeClientSettings
|
||||
return ret
|
||||
}).(KubeClientSettingsOutput)
|
||||
}
|
||||
|
||||
// Maximum burst for throttle. Default value is 10.
|
||||
func (o KubeClientSettingsPtrOutput) Burst() pulumi.IntPtrOutput {
|
||||
return o.ApplyT(func(v *KubeClientSettings) *int {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Burst
|
||||
}).(pulumi.IntPtrOutput)
|
||||
}
|
||||
|
||||
// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
|
||||
func (o KubeClientSettingsPtrOutput) Qps() pulumi.Float64PtrOutput {
|
||||
return o.ApplyT(func(v *KubeClientSettings) *float64 {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Qps
|
||||
}).(pulumi.Float64PtrOutput)
|
||||
}
|
||||
|
||||
func (o KubeClientSettingsPtrOutput) RecTest() KubeClientSettingsPtrOutput {
|
||||
return o.ApplyT(func(v *KubeClientSettings) *KubeClientSettings {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.RecTest
|
||||
}).(KubeClientSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// Make sure that defaults propagate through types
|
||||
type LayeredType struct {
|
||||
// The answer to the question
|
||||
Answer *float64 `pulumi:"answer"`
|
||||
Other HelmReleaseSettings `pulumi:"other"`
|
||||
// Test how plain types interact
|
||||
PlainOther *HelmReleaseSettings `pulumi:"plainOther"`
|
||||
// The question already answered
|
||||
Question *string `pulumi:"question"`
|
||||
Recursive *LayeredType `pulumi:"recursive"`
|
||||
// To ask and answer
|
||||
Thinker string `pulumi:"thinker"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for LayeredType
|
||||
func (val *LayeredType) Defaults() *LayeredType {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Answer) {
|
||||
answer_ := 42.0
|
||||
tmp.Answer = &answer_
|
||||
}
|
||||
tmp.Other = *tmp.Other.Defaults()
|
||||
|
||||
tmp.PlainOther = tmp.PlainOther.Defaults()
|
||||
|
||||
if isZero(tmp.Question) {
|
||||
question_ := getEnvOrDefault("<unknown>", nil, "PULUMI_THE_QUESTION").(string)
|
||||
tmp.Question = &question_
|
||||
}
|
||||
tmp.Recursive = tmp.Recursive.Defaults()
|
||||
|
||||
if isZero(tmp.Thinker) {
|
||||
tmp.Thinker = "not a good interaction"
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// LayeredTypeInput is an input type that accepts LayeredTypeArgs and LayeredTypeOutput values.
|
||||
// You can construct a concrete instance of `LayeredTypeInput` via:
|
||||
//
|
||||
// LayeredTypeArgs{...}
|
||||
type LayeredTypeInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToLayeredTypeOutput() LayeredTypeOutput
|
||||
ToLayeredTypeOutputWithContext(context.Context) LayeredTypeOutput
|
||||
}
|
||||
|
||||
// Make sure that defaults propagate through types
|
||||
type LayeredTypeArgs struct {
|
||||
// The answer to the question
|
||||
Answer pulumi.Float64PtrInput `pulumi:"answer"`
|
||||
Other HelmReleaseSettingsInput `pulumi:"other"`
|
||||
// Test how plain types interact
|
||||
PlainOther *HelmReleaseSettingsArgs `pulumi:"plainOther"`
|
||||
// The question already answered
|
||||
Question pulumi.StringPtrInput `pulumi:"question"`
|
||||
Recursive LayeredTypePtrInput `pulumi:"recursive"`
|
||||
// To ask and answer
|
||||
Thinker pulumi.StringInput `pulumi:"thinker"`
|
||||
}
|
||||
|
||||
func (LayeredTypeArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*LayeredType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i LayeredTypeArgs) ToLayeredTypeOutput() LayeredTypeOutput {
|
||||
return i.ToLayeredTypeOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i LayeredTypeArgs) ToLayeredTypeOutputWithContext(ctx context.Context) LayeredTypeOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(LayeredTypeOutput)
|
||||
}
|
||||
|
||||
func (i LayeredTypeArgs) ToLayeredTypePtrOutput() LayeredTypePtrOutput {
|
||||
return i.ToLayeredTypePtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i LayeredTypeArgs) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(LayeredTypeOutput).ToLayeredTypePtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// LayeredTypePtrInput is an input type that accepts LayeredTypeArgs, LayeredTypePtr and LayeredTypePtrOutput values.
|
||||
// You can construct a concrete instance of `LayeredTypePtrInput` via:
|
||||
//
|
||||
// LayeredTypeArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type LayeredTypePtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToLayeredTypePtrOutput() LayeredTypePtrOutput
|
||||
ToLayeredTypePtrOutputWithContext(context.Context) LayeredTypePtrOutput
|
||||
}
|
||||
|
||||
type layeredTypePtrType LayeredTypeArgs
|
||||
|
||||
func LayeredTypePtr(v *LayeredTypeArgs) LayeredTypePtrInput {
|
||||
return (*layeredTypePtrType)(v)
|
||||
}
|
||||
|
||||
func (*layeredTypePtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**LayeredType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *layeredTypePtrType) ToLayeredTypePtrOutput() LayeredTypePtrOutput {
|
||||
return i.ToLayeredTypePtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *layeredTypePtrType) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(LayeredTypePtrOutput)
|
||||
}
|
||||
|
||||
// Make sure that defaults propagate through types
|
||||
type LayeredTypeOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (LayeredTypeOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*LayeredType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) ToLayeredTypeOutput() LayeredTypeOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) ToLayeredTypeOutputWithContext(ctx context.Context) LayeredTypeOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) ToLayeredTypePtrOutput() LayeredTypePtrOutput {
|
||||
return o.ToLayeredTypePtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v LayeredType) *LayeredType {
|
||||
return &v
|
||||
}).(LayeredTypePtrOutput)
|
||||
}
|
||||
|
||||
// The answer to the question
|
||||
func (o LayeredTypeOutput) Answer() pulumi.Float64PtrOutput {
|
||||
return o.ApplyT(func(v LayeredType) *float64 { return v.Answer }).(pulumi.Float64PtrOutput)
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) Other() HelmReleaseSettingsOutput {
|
||||
return o.ApplyT(func(v LayeredType) HelmReleaseSettings { return v.Other }).(HelmReleaseSettingsOutput)
|
||||
}
|
||||
|
||||
// Test how plain types interact
|
||||
func (o LayeredTypeOutput) PlainOther() HelmReleaseSettingsPtrOutput {
|
||||
return o.ApplyT(func(v LayeredType) *HelmReleaseSettings { return v.PlainOther }).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// The question already answered
|
||||
func (o LayeredTypeOutput) Question() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v LayeredType) *string { return v.Question }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func (o LayeredTypeOutput) Recursive() LayeredTypePtrOutput {
|
||||
return o.ApplyT(func(v LayeredType) *LayeredType { return v.Recursive }).(LayeredTypePtrOutput)
|
||||
}
|
||||
|
||||
// To ask and answer
|
||||
func (o LayeredTypeOutput) Thinker() pulumi.StringOutput {
|
||||
return o.ApplyT(func(v LayeredType) string { return v.Thinker }).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
type LayeredTypePtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (LayeredTypePtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**LayeredType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o LayeredTypePtrOutput) ToLayeredTypePtrOutput() LayeredTypePtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o LayeredTypePtrOutput) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o LayeredTypePtrOutput) Elem() LayeredTypeOutput {
|
||||
return o.ApplyT(func(v *LayeredType) LayeredType {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret LayeredType
|
||||
return ret
|
||||
}).(LayeredTypeOutput)
|
||||
}
|
||||
|
||||
// The answer to the question
|
||||
func (o LayeredTypePtrOutput) Answer() pulumi.Float64PtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *float64 {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Answer
|
||||
}).(pulumi.Float64PtrOutput)
|
||||
}
|
||||
|
||||
func (o LayeredTypePtrOutput) Other() HelmReleaseSettingsPtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *HelmReleaseSettings {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return &v.Other
|
||||
}).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// Test how plain types interact
|
||||
func (o LayeredTypePtrOutput) PlainOther() HelmReleaseSettingsPtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *HelmReleaseSettings {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.PlainOther
|
||||
}).(HelmReleaseSettingsPtrOutput)
|
||||
}
|
||||
|
||||
// The question already answered
|
||||
func (o LayeredTypePtrOutput) Question() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Question
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func (o LayeredTypePtrOutput) Recursive() LayeredTypePtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *LayeredType {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Recursive
|
||||
}).(LayeredTypePtrOutput)
|
||||
}
|
||||
|
||||
// To ask and answer
|
||||
func (o LayeredTypePtrOutput) Thinker() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *LayeredType) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return &v.Thinker
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// A test for namespaces (mod main)
|
||||
type Typ struct {
|
||||
Mod1 *mod1.Typ `pulumi:"mod1"`
|
||||
Mod2 *mod2.Typ `pulumi:"mod2"`
|
||||
Val *string `pulumi:"val"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for Typ
|
||||
func (val *Typ) Defaults() *Typ {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
tmp.Mod1 = tmp.Mod1.Defaults()
|
||||
|
||||
tmp.Mod2 = tmp.Mod2.Defaults()
|
||||
|
||||
if isZero(tmp.Val) {
|
||||
val_ := "mod main"
|
||||
tmp.Val = &val_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// TypInput is an input type that accepts TypArgs and TypOutput values.
|
||||
// You can construct a concrete instance of `TypInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
type TypInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypOutput() TypOutput
|
||||
ToTypOutputWithContext(context.Context) TypOutput
|
||||
}
|
||||
|
||||
// A test for namespaces (mod main)
|
||||
type TypArgs struct {
|
||||
Mod1 mod1.TypPtrInput `pulumi:"mod1"`
|
||||
Mod2 mod2.TypPtrInput `pulumi:"mod2"`
|
||||
Val pulumi.StringPtrInput `pulumi:"val"`
|
||||
}
|
||||
|
||||
func (TypArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutput() TypOutput {
|
||||
return i.ToTypOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput)
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values.
|
||||
// You can construct a concrete instance of `TypPtrInput` via:
|
||||
//
|
||||
// TypArgs{...}
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// nil
|
||||
type TypPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToTypPtrOutput() TypPtrOutput
|
||||
ToTypPtrOutputWithContext(context.Context) TypPtrOutput
|
||||
}
|
||||
|
||||
type typPtrType TypArgs
|
||||
|
||||
func TypPtr(v *TypArgs) TypPtrInput {
|
||||
return (*typPtrType)(v)
|
||||
}
|
||||
|
||||
func (*typPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutput() TypPtrOutput {
|
||||
return i.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput)
|
||||
}
|
||||
|
||||
// A test for namespaces (mod main)
|
||||
type TypOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutput() TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o.ToTypPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ {
|
||||
return &v
|
||||
}).(TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Mod1() mod1.TypPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *mod1.Typ { return v.Mod1 }).(mod1.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Mod2() mod2.TypPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *mod2.Typ { return v.Mod2 }).(mod2.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type TypPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (TypPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Typ)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Elem() TypOutput {
|
||||
return o.ApplyT(func(v *Typ) Typ {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Typ
|
||||
return ret
|
||||
}).(TypOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Mod1() mod1.TypPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *mod1.Typ {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Mod1
|
||||
}).(mod1.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Mod2() mod2.TypPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *mod2.Typ {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Mod2
|
||||
}).(mod2.TypPtrOutput)
|
||||
}
|
||||
|
||||
func (o TypPtrOutput) Val() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v *Typ) *string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
return v.Val
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*HelmReleaseSettingsInput)(nil)).Elem(), HelmReleaseSettingsArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*HelmReleaseSettingsPtrInput)(nil)).Elem(), HelmReleaseSettingsArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*KubeClientSettingsInput)(nil)).Elem(), KubeClientSettingsArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*KubeClientSettingsPtrInput)(nil)).Elem(), KubeClientSettingsArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*LayeredTypeInput)(nil)).Elem(), LayeredTypeArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*LayeredTypePtrInput)(nil)).Elem(), LayeredTypeArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{})
|
||||
pulumi.RegisterOutputType(HelmReleaseSettingsOutput{})
|
||||
pulumi.RegisterOutputType(HelmReleaseSettingsPtrOutput{})
|
||||
pulumi.RegisterOutputType(KubeClientSettingsOutput{})
|
||||
pulumi.RegisterOutputType(KubeClientSettingsPtrOutput{})
|
||||
pulumi.RegisterOutputType(LayeredTypeOutput{})
|
||||
pulumi.RegisterOutputType(LayeredTypePtrOutput{})
|
||||
pulumi.RegisterOutputType(TypOutput{})
|
||||
pulumi.RegisterOutputType(TypPtrOutput{})
|
||||
}
|
|
@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
184
pkg/codegen/internal/test/testdata/plain-object-defaults/nodejs/types/input.ts
vendored
Normal file
184
pkg/codegen/internal/test/testdata/plain-object-defaults/nodejs/types/input.ts
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import { input as inputs, output as outputs } from "../types";
|
||||
|
||||
import * as utilities from "../utilities";
|
||||
|
||||
/**
|
||||
* BETA FEATURE - Options to configure the Helm Release resource.
|
||||
*/
|
||||
export interface HelmReleaseSettings {
|
||||
/**
|
||||
* The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
*/
|
||||
driver?: string;
|
||||
/**
|
||||
* The path to the helm plugins directory.
|
||||
*/
|
||||
pluginsPath?: string;
|
||||
/**
|
||||
* to test required args
|
||||
*/
|
||||
requiredArg: string;
|
||||
}
|
||||
/**
|
||||
* helmReleaseSettingsProvideDefaults sets the appropriate defaults for HelmReleaseSettings
|
||||
*/
|
||||
export function helmReleaseSettingsProvideDefaults(val: HelmReleaseSettings): HelmReleaseSettings {
|
||||
return {
|
||||
...val,
|
||||
driver: (val.driver) ?? (utilities.getEnv("PULUMI_K8S_HELM_DRIVER") || "secret"),
|
||||
pluginsPath: (val.pluginsPath) ?? utilities.getEnv("PULUMI_K8S_HELM_PLUGINS_PATH"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* BETA FEATURE - Options to configure the Helm Release resource.
|
||||
*/
|
||||
export interface HelmReleaseSettingsArgs {
|
||||
/**
|
||||
* The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
|
||||
*/
|
||||
driver?: pulumi.Input<string>;
|
||||
/**
|
||||
* The path to the helm plugins directory.
|
||||
*/
|
||||
pluginsPath?: pulumi.Input<string>;
|
||||
/**
|
||||
* to test required args
|
||||
*/
|
||||
requiredArg: pulumi.Input<string>;
|
||||
}
|
||||
/**
|
||||
* helmReleaseSettingsArgsProvideDefaults sets the appropriate defaults for HelmReleaseSettingsArgs
|
||||
*/
|
||||
export function helmReleaseSettingsArgsProvideDefaults(val: HelmReleaseSettingsArgs): HelmReleaseSettingsArgs {
|
||||
return {
|
||||
...val,
|
||||
driver: (val.driver) ?? (utilities.getEnv("PULUMI_K8S_HELM_DRIVER") || "secret"),
|
||||
pluginsPath: (val.pluginsPath) ?? utilities.getEnv("PULUMI_K8S_HELM_PLUGINS_PATH"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for tuning the Kubernetes client used by a Provider.
|
||||
*/
|
||||
export interface KubeClientSettingsArgs {
|
||||
/**
|
||||
* Maximum burst for throttle. Default value is 10.
|
||||
*/
|
||||
burst?: pulumi.Input<number>;
|
||||
/**
|
||||
* Maximum queries per second (QPS) to the API server from this client. Default value is 5.
|
||||
*/
|
||||
qps?: pulumi.Input<number>;
|
||||
recTest?: pulumi.Input<inputs.KubeClientSettingsArgs>;
|
||||
}
|
||||
/**
|
||||
* kubeClientSettingsArgsProvideDefaults sets the appropriate defaults for KubeClientSettingsArgs
|
||||
*/
|
||||
export function kubeClientSettingsArgsProvideDefaults(val: KubeClientSettingsArgs): KubeClientSettingsArgs {
|
||||
return {
|
||||
...val,
|
||||
burst: (val.burst) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_BURST"),
|
||||
qps: (val.qps) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_QPS"),
|
||||
recTest: (val.recTest ? pulumi.output(val.recTest).apply(inputs.kubeClientSettingsArgsProvideDefaults) : undefined),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that defaults propagate through types
|
||||
*/
|
||||
export interface LayeredTypeArgs {
|
||||
/**
|
||||
* The answer to the question
|
||||
*/
|
||||
answer?: pulumi.Input<number>;
|
||||
other: pulumi.Input<inputs.HelmReleaseSettingsArgs>;
|
||||
/**
|
||||
* Test how plain types interact
|
||||
*/
|
||||
plainOther?: inputs.HelmReleaseSettingsArgs;
|
||||
/**
|
||||
* The question already answered
|
||||
*/
|
||||
question?: pulumi.Input<string>;
|
||||
recursive?: pulumi.Input<inputs.LayeredTypeArgs>;
|
||||
/**
|
||||
* To ask and answer
|
||||
*/
|
||||
thinker: pulumi.Input<string>;
|
||||
}
|
||||
/**
|
||||
* layeredTypeArgsProvideDefaults sets the appropriate defaults for LayeredTypeArgs
|
||||
*/
|
||||
export function layeredTypeArgsProvideDefaults(val: LayeredTypeArgs): LayeredTypeArgs {
|
||||
return {
|
||||
...val,
|
||||
answer: (val.answer) ?? 42,
|
||||
other: pulumi.output(val.other).apply(inputs.helmReleaseSettingsArgsProvideDefaults),
|
||||
plainOther: (val.plainOther ? inputs.helmReleaseSettingsArgsProvideDefaults(val.plainOther) : undefined),
|
||||
question: (val.question) ?? (utilities.getEnv("PULUMI_THE_QUESTION") || "<unknown>"),
|
||||
recursive: (val.recursive ? pulumi.output(val.recursive).apply(inputs.layeredTypeArgsProvideDefaults) : undefined),
|
||||
thinker: (val.thinker) ?? "not a good interaction",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A test for namespaces (mod main)
|
||||
*/
|
||||
export interface TypArgs {
|
||||
mod1?: pulumi.Input<inputs.mod1.TypArgs>;
|
||||
mod2?: pulumi.Input<inputs.mod2.TypArgs>;
|
||||
val?: pulumi.Input<string>;
|
||||
}
|
||||
/**
|
||||
* typArgsProvideDefaults sets the appropriate defaults for TypArgs
|
||||
*/
|
||||
export function typArgsProvideDefaults(val: TypArgs): TypArgs {
|
||||
return {
|
||||
...val,
|
||||
mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined),
|
||||
mod2: (val.mod2 ? pulumi.output(val.mod2).apply(inputs.mod2.typArgsProvideDefaults) : undefined),
|
||||
val: (val.val) ?? "mod main",
|
||||
};
|
||||
}
|
||||
export namespace mod1 {
|
||||
/**
|
||||
* A test for namespaces (mod 1)
|
||||
*/
|
||||
export interface TypArgs {
|
||||
val?: pulumi.Input<string>;
|
||||
}
|
||||
/**
|
||||
* typArgsProvideDefaults sets the appropriate defaults for TypArgs
|
||||
*/
|
||||
export function typArgsProvideDefaults(val: TypArgs): TypArgs {
|
||||
return {
|
||||
...val,
|
||||
val: (val.val) ?? (utilities.getEnv("PULUMI_EXAMPLE_MOD1_DEFAULT") || "mod1"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export namespace mod2 {
|
||||
/**
|
||||
* A test for namespaces (mod 2)
|
||||
*/
|
||||
export interface TypArgs {
|
||||
mod1?: pulumi.Input<inputs.mod1.TypArgs>;
|
||||
val?: pulumi.Input<string>;
|
||||
}
|
||||
/**
|
||||
* typArgsProvideDefaults sets the appropriate defaults for TypArgs
|
||||
*/
|
||||
export function typArgsProvideDefaults(val: TypArgs): TypArgs {
|
||||
return {
|
||||
...val,
|
||||
mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined),
|
||||
val: (val.val) ?? "mod2",
|
||||
};
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue