Compare commits

..

8 commits

Author SHA1 Message Date
Ian Wahbe bd7a89af9f Satisfy linter 2021-11-19 16:23:02 -08:00
Ian Wahbe 3a80b48874 Merge branch 'master' into iwahbe/8308/forbid-nonsensical-schema-flag-combinations 2021-11-19 16:19:24 -08:00
Ian Wahbe a9b899df5d Update codegen output 2021-11-19 16:17:46 -08:00
Ian Wahbe c4784a518a Merge branch 'master' into iwahbe/8308/forbid-nonsensical-schema-flag-combinations 2021-11-19 16:10:41 -08:00
Ian Wahbe b30ce26d8c Update tests 2021-11-08 15:43:36 -08:00
Ian Wahbe 5ad57d543b Add to changelog 2021-11-08 09:45:27 -08:00
Ian Wahbe 9208ea2aef Merge branch 'master' into iwahbe/8308/forbid-nonsensical-schema-flag-combinations 2021-11-08 09:43:58 -08:00
Ian Wahbe 420f9546f0 Forbid bad interactions 2021-11-06 20:25:54 -07:00
342 changed files with 2615 additions and 11128 deletions

View file

@ -1,43 +1,6 @@
CHANGELOG
=========
## 3.18.1 (2021-11-22)
### 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)
### 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)
## 3.18.0 (2021-11-17)
### Improvements

View file

@ -1,12 +1,31 @@
### Improvements
- [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)
- [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)
### Bug Fixes
- [codegen/go] - Respect default values in Pulumi object types.
[#8411](https://github.com/pulumi/pulumi/pull/8400)
- [codegen/typescript] - Respect default values in Pulumi object types.
[#8400](https://github.com/pulumi/pulumi/pull/8400)
- [codegen] - Forbid nonsensical combinations of schema property flags.
[#8373](https://github.com/pulumi/pulumi/pull/8373)
- [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)

View file

@ -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 coreutils
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl
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,10 +53,9 @@ ulimit -n 5000
Across our projects, we try to use a regular set of make targets. The ones you'll care most about are:
1. `make ensure`, which restores/installs any build dependencies
1. `make dist`, which just builds and installs the Pulumi CLI
0. `make ensure`, which restores/installs any build dependencies
1. `make`, which builds Pulumi and runs a quick set of tests
1. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
2. `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`.

View file

@ -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://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) |
| 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) |
### Languages

View file

@ -114,9 +114,6 @@ 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 {
@ -272,7 +269,6 @@ 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:
@ -299,6 +295,23 @@ 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:
@ -500,12 +513,7 @@ func (pkg *pkgContext) typeStringImpl(t schema.Type, argsType bool) string {
}
func (pkg *pkgContext) typeString(t schema.Type) string {
s := pkg.typeStringImpl(t, false)
if s == "pulumi." {
return "pulumi.Any"
}
return s
return pkg.typeStringImpl(t, false)
}
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
@ -625,9 +633,6 @@ 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:
@ -779,14 +784,16 @@ type genInputImplementationArgs struct {
elementType string
ptrMethods bool
toOutputMethods bool
resourceType bool
}
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods bool) {
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods, resourceType bool) {
genInputImplementationWithArgs(w, genInputImplementationArgs{
name: name,
receiverType: receiverType,
elementType: elementType,
ptrMethods: ptrMethods,
resourceType: resourceType,
toOutputMethods: true,
})
}
@ -795,9 +802,14 @@ 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)
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
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, "}\n\n")
if genArgs.toOutputMethods {
@ -825,11 +837,15 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
}
}
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resourceType bool) {
fmt.Fprintf(w, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\n", baseName)
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
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, "}\n\n")
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
@ -853,8 +869,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
}
}
func genArrayOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Array", "[]"+elementType, false)
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Array", "[]"+elementType, false, resourceType)
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)
@ -863,8 +879,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string) {
fmt.Fprintf(w, "}\n\n")
}
func genMapOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Map", "map[string]"+elementType, false, resourceType)
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)
@ -873,8 +889,8 @@ func genMapOutput(w io.Writer, baseName, elementType string) {
fmt.Fprintf(w, "}\n\n")
}
func genPtrOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
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)
@ -940,7 +956,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)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
}
// Generate the map input.
@ -949,24 +965,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)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
}
// Generate the array output
if details.arrayElement {
genArrayOutput(w, name, name)
genArrayOutput(w, name, name, false)
}
// Generate the map output.
if details.mapElement {
genMapOutput(w, name, name)
genMapOutput(w, name, name, false)
}
return nil
}
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
genOutputType(w, name, name, true)
genOutputType(w, name, name, true, false)
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)
@ -989,7 +1005,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)
genPtrOutput(w, name, name, false)
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)
@ -1091,27 +1107,6 @@ 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) {
@ -1124,66 +1119,6 @@ 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())
@ -1194,7 +1129,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)
genInputImplementation(w, name, name+"Args", name, details.ptrElement, false)
// Generate the pointer input.
if details.ptrElement {
@ -1208,7 +1143,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)
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
}
// Generate the array input.
@ -1217,7 +1152,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)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
}
// Generate the map input.
@ -1226,7 +1161,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)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
}
}
@ -1265,6 +1200,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
name, /* baseName */
name, /* elementType */
details.ptrElement, /* ptrMethods */
false, /* resourceType */
)
for _, p := range t.Properties {
@ -1283,7 +1219,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
}
if details.ptrElement {
genPtrOutput(w, name, name)
genPtrOutput(w, name, name, false)
for _, p := range t.Properties {
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
@ -1316,11 +1252,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
}
if details.arrayElement {
genArrayOutput(w, name, name)
genArrayOutput(w, name, name, false)
}
if details.mapElement {
genMapOutput(w, name, name)
genMapOutput(w, name, name, false)
}
}
@ -1374,11 +1310,6 @@ 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 {
@ -1462,8 +1393,6 @@ 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))
@ -1472,8 +1401,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
}
}
assign := func(p *schema.Property, value string) {
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
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)
}
}
for _, p := range r.InputProperties {
@ -1482,51 +1429,19 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
if err != nil {
return err
}
assign(p, v)
assign(p, v, 1)
} else if p.DefaultValue != nil {
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
if err != nil {
return err
}
pkg.needsUtils = true
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
assign(p, dv)
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)
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()
}
}
}
@ -1793,26 +1708,42 @@ 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, false)
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, 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 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)
// 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)
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)
}
}
// Emit the resource output type.
genOutputType(w, name, "*"+name, false)
genOutputType(w, name, name, generateResourceContainerTypes, true)
if generateResourceContainerTypes && !r.IsProvider {
genArrayOutput(w, name, "*"+name)
genMapOutput(w, name, "*"+name)
if generateResourceContainerTypes {
genPtrOutput(w, name, name, true)
if !r.IsProvider {
genArrayOutput(w, name, name, true)
genMapOutput(w, name, name, true)
}
}
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
@ -1820,30 +1751,6 @@ 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
@ -1861,7 +1768,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
return f.NeedsOutputVersion()
}
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
importsAndAliases := map[string]string{}
pkg.getImports(f, importsAndAliases)
buffer := &bytes.Buffer{}
@ -1872,14 +1779,12 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
}
pkg.genHeader(buffer, imports, importsAndAliases)
if err := pkg.genFunction(buffer, f); err != nil {
return "", err
}
pkg.genFunction(buffer, f)
pkg.genFunctionOutputVersion(buffer, f)
return buffer.String(), nil
return buffer.String()
}
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
name := pkg.functionName(f)
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
@ -1900,8 +1805,6 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
var inputsVar string
if f.Inputs == nil {
inputsVar = "nil"
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
inputsVar = "args.Defaults()"
} else {
inputsVar = "args"
}
@ -1925,38 +1828,19 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
fmt.Fprintf(w, "\t}\n")
// Return the result.
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, "\treturn &rv, nil\n")
}
fmt.Fprintf(w, "}\n")
// If there are argument and/or return types, emit them.
if f.Inputs != nil {
fmt.Fprintf(w, "\n")
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
}
}
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
}
if f.Outputs != nil {
fmt.Fprintf(w, "\n")
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
}
}
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
}
return nil
}
func (pkg *pkgContext) functionName(f *schema.Function) string {
@ -2135,24 +2019,16 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
}
}
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) error {
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
contract.Assert(!obj.IsInputShape())
if obj.IsOverlay {
// This type is generated by the provider, so no further action is required.
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
}
return
}
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 {
@ -2224,16 +2100,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)
genInputImplementation(w, name, name, elementTypeName, false, false)
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName)
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName, false)
}
if strings.HasSuffix(name, "Map") {
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
genInputImplementation(w, name, name, elementTypeName, false)
genInputImplementation(w, name, name, elementTypeName, false, false)
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName)
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName, false)
}
pkg.genInputInterface(w, name)
}
@ -2360,13 +2236,18 @@ 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 && !r.IsProvider {
if generateResourceContainerTypes {
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",
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\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
@ -2381,9 +2262,12 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
}
}
if generateResourceContainerTypes && !r.IsProvider {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
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)
}
}
fmt.Fprintf(w, "}\n\n")
}
@ -2786,7 +2670,6 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
packages: packages,
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
disableObjectDefaults: goInfo.DisableObjectDefaults,
}
packages[mod] = pack
}
@ -3110,10 +2993,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
pkg.functions = append(pkg.functions, f)
name := tokenToName(f.Token)
if pkg.names.Has(name) ||
pkg.names.Has(name+"Args") ||
pkg.names.Has(name+"Result") {
originalName := name
if pkg.names.Has(name) {
switch {
case strings.HasPrefix(name, "New"):
name = "Create" + name[3:]
@ -3126,9 +3007,15 @@ 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"
}
}
}
@ -3317,10 +3204,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
}
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
code, err := pkg.genFunctionCodeFile(f)
if err != nil {
return nil, err
}
code := pkg.genFunctionCodeFile(f)
setFile(fileName, code)
}
@ -3360,9 +3244,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
for _, t := range pkg.types {
if err := pkg.genType(buffer, t); err != nil {
return nil, err
}
pkg.genType(buffer, t)
delete(knownTypes, t)
}
@ -3498,12 +3380,4 @@ 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()
}
`

View file

@ -43,9 +43,7 @@ func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error
if len(pkg.types) > 0 {
for _, t := range pkg.types {
if err := pkg.genType(buffer, t); err != nil {
return nil, err
}
pkg.genType(buffer, t)
}
pkg.genTypeRegistrations(buffer, pkg.types)
}

View file

@ -60,10 +60,6 @@ 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.

View file

@ -60,7 +60,8 @@ var sdkTests = []sdkTest{
Directory: "external-resource-schema",
Description: "External resource schema",
SkipCompileCheck: codegen.NewStringSet(nodejs, golang),
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
Skip: codegen.NewStringSet("python/test", "nodejs/test",
/* TODO[pulumi/pulumi#8308] */ "all"),
},
{
Directory: "nested-module",
@ -77,7 +78,8 @@ var sdkTests = []sdkTest{
{
Directory: "plain-schema-gh6957",
Description: "Repro for #6957",
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
Skip: codegen.NewStringSet("python/test", "nodejs/test",
/* TODO[pulumi/pulumi#8308] */ "all"),
},
{
Directory: "resource-args-python-case-insensitive",
@ -153,7 +155,8 @@ var sdkTests = []sdkTest{
Description: "A resource url with a hyphen in its path",
// TODO[pulumi/pulumi#8370]: Re-enable compiling for Go.
SkipCompileCheck: codegen.NewStringSet(golang),
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
Skip: codegen.NewStringSet("python/test", "nodejs/test",
/* TODO[pulumi/pulumi#8308] */ "all"),
},
{
Directory: "output-funcs",
@ -192,22 +195,11 @@ var sdkTests = []sdkTest{
SkipCompileCheck: codegen.NewStringSet(nodejs),
},
{
Directory: "plain-object-defaults",
Description: "Ensure that object defaults are generated (repro #8132)",
Directory: "env-helper",
Description: "Ensure that eviromental helpers 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
@ -302,6 +294,11 @@ func TestSDKCodegen(t *testing.T, opts *SDKCodegenOptions) { // revive:disable-l
}
t.Log(tt.Description)
// Skip all check. This needs to be here because it needs to skip
// the codegen.
if tt.Skip.Has("all") {
t.SkipNow()
}
dirPath := filepath.Join(testDir, filepath.FromSlash(tt.Directory))

View file

@ -48,7 +48,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
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)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

@ -75,11 +75,3 @@ 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()
}

View file

@ -48,7 +48,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
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)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

@ -75,11 +75,3 @@ 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()
}

View file

@ -76,7 +76,7 @@ type ModuleResourceInput interface {
}
func (*ModuleResource) ElementType() reflect.Type {
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
return reflect.TypeOf((*ModuleResource)(nil))
}
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)).Elem()
return reflect.TypeOf((*ModuleResource)(nil))
}
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {

View file

@ -167,14 +167,6 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#diameter">Pulumi.<wbr>Plant.<wbr>Tree.<wbr>V1.<wbr>Diameter</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="type_csharp">
<a href="#type_csharp" style="color: inherit; text-decoration: inherit;">Type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Pulumi.<wbr>Plant.<wbr>Tree.<wbr>V1.<wbr>Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="container_csharp">
@ -199,6 +191,14 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#treesize">Pulumi.<wbr>Plant.<wbr>Tree.<wbr>V1.<wbr>Tree<wbr>Size</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="type_csharp">
<a href="#type_csharp" style="color: inherit; text-decoration: inherit;">Type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Pulumi.<wbr>Plant.<wbr>Tree.<wbr>V1.<wbr>Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
{{% /choosable %}}
@ -211,14 +211,6 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#diameter">Diameter</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="type_go">
<a href="#type_go" style="color: inherit; text-decoration: inherit;">Type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="container_go">
@ -243,6 +235,14 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#treesize">Tree<wbr>Size</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="type_go">
<a href="#type_go" style="color: inherit; text-decoration: inherit;">Type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
{{% /choosable %}}
@ -255,14 +255,6 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#diameter">Diameter</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="type_nodejs">
<a href="#type_nodejs" style="color: inherit; text-decoration: inherit;">type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="container_nodejs">
@ -287,6 +279,14 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#treesize">Tree<wbr>Size</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="type_nodejs">
<a href="#type_nodejs" style="color: inherit; text-decoration: inherit;">type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
{{% /choosable %}}
@ -299,14 +299,6 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#diameter">Diameter</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="type_python">
<a href="#type_python" style="color: inherit; text-decoration: inherit;">type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="container_python">
@ -331,6 +323,14 @@ The RubberTree resource accepts the following [input]({{< relref "/docs/intro/co
<span class="property-indicator"></span>
<span class="property-type"><a href="#treesize">Tree<wbr>Size</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="type_python">
<a href="#type_python" style="color: inherit; text-decoration: inherit;">type</a>
</span>
<span class="property-indicator"></span>
<span class="property-type"><a href="#rubbertreevariety">Rubber<wbr>Tree<wbr>Variety</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
{{% /choosable %}}

View file

@ -25,7 +25,7 @@ namespace Pulumi.Plant.Tree.V1
public Output<Pulumi.Plant.Tree.V1.TreeSize?> Size { get; private set; } = null!;
[Output("type")]
public Output<Pulumi.Plant.Tree.V1.RubberTreeVariety> Type { get; private set; } = null!;
public Output<Pulumi.Plant.Tree.V1.RubberTreeVariety?> Type { get; private set; } = null!;
/// <summary>
@ -85,12 +85,11 @@ namespace Pulumi.Plant.Tree.V1
[Input("size")]
public Input<Pulumi.Plant.Tree.V1.TreeSize>? Size { get; set; }
[Input("type", required: true)]
public Input<Pulumi.Plant.Tree.V1.RubberTreeVariety> Type { get; set; } = null!;
[Input("type")]
public Input<Pulumi.Plant.Tree.V1.RubberTreeVariety>? Type { get; set; }
public RubberTreeArgs()
{
Diameter = Pulumi.Plant.Tree.V1.Diameter.Sixinch;
Farm = "(unknown)";
Size = Pulumi.Plant.Tree.V1.TreeSize.Medium;
Type = Pulumi.Plant.Tree.V1.RubberTreeVariety.Burgundy;

View file

@ -9,7 +9,6 @@
"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"
]
}

View file

@ -48,7 +48,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
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)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

@ -17,19 +17,6 @@ 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:
//

View file

@ -75,11 +75,3 @@ 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()
}

View file

@ -83,7 +83,7 @@ type NurseryInput interface {
}
func (*Nursery) ElementType() reflect.Type {
return reflect.TypeOf((**Nursery)(nil)).Elem()
return reflect.TypeOf((*Nursery)(nil))
}
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)).Elem()
return reflect.TypeOf((*Nursery)(nil))
}
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {

View file

@ -1,85 +0,0 @@
// *** 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()
}

View file

@ -19,7 +19,7 @@ type RubberTree struct {
Diameter DiameterOutput `pulumi:"diameter"`
Farm pulumi.StringPtrOutput `pulumi:"farm"`
Size TreeSizePtrOutput `pulumi:"size"`
Type RubberTreeVarietyOutput `pulumi:"type"`
Type RubberTreeVarietyPtrOutput `pulumi:"type"`
}
// NewRubberTree registers a new resource with the given unique name, arguments, and options.
@ -29,20 +29,16 @@ func NewRubberTree(ctx *pulumi.Context,
return nil, errors.New("missing one or more required arguments")
}
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 args.Diameter == nil {
return nil, errors.New("invalid value for required argument 'Diameter'")
}
if isZero(args.Diameter) {
args.Diameter = Diameter(6.0)
}
if isZero(args.Farm) {
if args.Farm == nil {
args.Farm = pulumi.StringPtr("(unknown)")
}
if isZero(args.Size) {
if args.Size == nil {
args.Size = TreeSize("medium")
}
if isZero(args.Type) {
if args.Type == nil {
args.Type = RubberTreeVariety("Burgundy")
}
var resource RubberTree
@ -83,7 +79,7 @@ type rubberTreeArgs struct {
Diameter Diameter `pulumi:"diameter"`
Farm *string `pulumi:"farm"`
Size *TreeSize `pulumi:"size"`
Type RubberTreeVariety `pulumi:"type"`
Type *RubberTreeVariety `pulumi:"type"`
}
// The set of arguments for constructing a RubberTree resource.
@ -92,7 +88,7 @@ type RubberTreeArgs struct {
Diameter DiameterInput
Farm pulumi.StringPtrInput
Size TreeSizePtrInput
Type RubberTreeVarietyInput
Type RubberTreeVarietyPtrInput
}
func (RubberTreeArgs) ElementType() reflect.Type {
@ -107,7 +103,7 @@ type RubberTreeInput interface {
}
func (*RubberTree) ElementType() reflect.Type {
return reflect.TypeOf((**RubberTree)(nil)).Elem()
return reflect.TypeOf((*RubberTree)(nil))
}
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
@ -121,7 +117,7 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
type RubberTreeOutput struct{ *pulumi.OutputState }
func (RubberTreeOutput) ElementType() reflect.Type {
return reflect.TypeOf((**RubberTree)(nil)).Elem()
return reflect.TypeOf((*RubberTree)(nil))
}
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {

View file

@ -37,7 +37,7 @@ export class RubberTree extends pulumi.CustomResource {
public readonly diameter!: pulumi.Output<enums.tree.v1.Diameter>;
public readonly farm!: pulumi.Output<enums.tree.v1.Farm | string | undefined>;
public readonly size!: pulumi.Output<enums.tree.v1.TreeSize | undefined>;
public readonly type!: pulumi.Output<enums.tree.v1.RubberTreeVariety>;
public readonly type!: pulumi.Output<enums.tree.v1.RubberTreeVariety | undefined>;
/**
* Create a RubberTree resource with the given unique name, arguments, and options.
@ -58,11 +58,8 @@ export class RubberTree extends pulumi.CustomResource {
if ((!args || args.diameter === undefined) && !opts.urn) {
throw new Error("Missing required property 'diameter'");
}
if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined;
resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
resourceInputs["diameter"] = args ? args.diameter : undefined;
resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
resourceInputs["size"] = (args ? args.size : undefined) ?? "medium";
resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
@ -86,5 +83,5 @@ export interface RubberTreeArgs {
diameter: pulumi.Input<enums.tree.v1.Diameter>;
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
size?: pulumi.Input<enums.tree.v1.TreeSize>;
type: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
type?: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
}

View file

@ -18,19 +18,14 @@ __all__ = ['RubberTreeArgs', 'RubberTree']
class RubberTreeArgs:
def __init__(__self__, *,
diameter: pulumi.Input['Diameter'],
type: pulumi.Input['RubberTreeVariety'],
container: Optional[pulumi.Input['_root_inputs.ContainerArgs']] = None,
farm: Optional[pulumi.Input[Union['Farm', str]]] = None,
size: Optional[pulumi.Input['TreeSize']] = None):
size: Optional[pulumi.Input['TreeSize']] = None,
type: Optional[pulumi.Input['RubberTreeVariety']] = None):
"""
The set of arguments for constructing a RubberTree resource.
"""
if diameter is None:
diameter = 6
pulumi.set(__self__, "diameter", diameter)
if type is None:
type = 'Burgundy'
pulumi.set(__self__, "type", type)
if container is not None:
pulumi.set(__self__, "container", container)
if farm is None:
@ -41,6 +36,10 @@ class RubberTreeArgs:
size = 'medium'
if size is not None:
pulumi.set(__self__, "size", size)
if type is None:
type = 'Burgundy'
if type is not None:
pulumi.set(__self__, "type", type)
@property
@pulumi.getter
@ -51,15 +50,6 @@ class RubberTreeArgs:
def diameter(self, value: pulumi.Input['Diameter']):
pulumi.set(self, "diameter", value)
@property
@pulumi.getter
def type(self) -> pulumi.Input['RubberTreeVariety']:
return pulumi.get(self, "type")
@type.setter
def type(self, value: pulumi.Input['RubberTreeVariety']):
pulumi.set(self, "type", value)
@property
@pulumi.getter
def container(self) -> Optional[pulumi.Input['_root_inputs.ContainerArgs']]:
@ -87,6 +77,15 @@ class RubberTreeArgs:
def size(self, value: Optional[pulumi.Input['TreeSize']]):
pulumi.set(self, "size", value)
@property
@pulumi.getter
def type(self) -> Optional[pulumi.Input['RubberTreeVariety']]:
return pulumi.get(self, "type")
@type.setter
def type(self, value: Optional[pulumi.Input['RubberTreeVariety']]):
pulumi.set(self, "type", value)
@pulumi.input_type
class _RubberTreeState:
@ -167,8 +166,6 @@ class RubberTree(pulumi.CustomResource):
__props__ = RubberTreeArgs.__new__(RubberTreeArgs)
__props__.__dict__["container"] = container
if diameter is None:
diameter = 6
if diameter is None and not opts.urn:
raise TypeError("Missing required property 'diameter'")
__props__.__dict__["diameter"] = diameter
@ -180,8 +177,6 @@ class RubberTree(pulumi.CustomResource):
__props__.__dict__["size"] = size
if type is None:
type = 'Burgundy'
if type is None and not opts.urn:
raise TypeError("Missing required property 'type'")
__props__.__dict__["type"] = type
super(RubberTree, __self__).__init__(
'plant:tree/v1:RubberTree',
@ -235,6 +230,6 @@ class RubberTree(pulumi.CustomResource):
@property
@pulumi.getter
def type(self) -> pulumi.Output['RubberTreeVariety']:
def type(self) -> pulumi.Output[Optional['RubberTreeVariety']]:
return pulumi.get(self, "type")

View file

@ -42,8 +42,7 @@
"default": "medium"
},
"diameter": {
"$ref": "#/types/plant:tree/v1:Diameter",
"default": 6
"$ref": "#/types/plant:tree/v1:Diameter"
}
},
"stateInputs": {
@ -75,12 +74,11 @@
"default": "medium"
},
"diameter": {
"$ref": "#/types/plant:tree/v1:Diameter",
"default": 6
"$ref": "#/types/plant:tree/v1:Diameter"
}
},
"required": ["type", "diameter"],
"requiredInputs": ["type", "diameter"]
"required": ["diameter"],
"requiredInputs": ["diameter"]
}
},
"types": {

View file

@ -639,15 +639,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#helmreleasesettings">Helm<wbr>Release<wbr>Settings</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="thinker_csharp">
<a href="#thinker_csharp" style="color: inherit; text-decoration: inherit;">Thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd><dt class="property-optional"
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="answer_csharp">
<a href="#answer_csharp" style="color: inherit; text-decoration: inherit;">Answer</a>
@ -679,7 +671,15 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#layeredtype">Layered<wbr>Type</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="thinker_csharp">
<a href="#thinker_csharp" style="color: inherit; text-decoration: inherit;">Thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd></dl>
{{% /choosable %}}
{{% choosable language go %}}
@ -691,15 +691,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#helmreleasesettings">Helm<wbr>Release<wbr>Settings</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="thinker_go">
<a href="#thinker_go" style="color: inherit; text-decoration: inherit;">Thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd><dt class="property-optional"
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="answer_go">
<a href="#answer_go" style="color: inherit; text-decoration: inherit;">Answer</a>
@ -731,7 +723,15 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#layeredtype">Layered<wbr>Type</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="thinker_go">
<a href="#thinker_go" style="color: inherit; text-decoration: inherit;">Thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd></dl>
{{% /choosable %}}
{{% choosable language nodejs %}}
@ -743,15 +743,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#helmreleasesettings">Helm<wbr>Release<wbr>Settings</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="thinker_nodejs">
<a href="#thinker_nodejs" style="color: inherit; text-decoration: inherit;">thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd><dt class="property-optional"
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="answer_nodejs">
<a href="#answer_nodejs" style="color: inherit; text-decoration: inherit;">answer</a>
@ -783,7 +775,15 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#layeredtype">Layered<wbr>Type</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="thinker_nodejs">
<a href="#thinker_nodejs" style="color: inherit; text-decoration: inherit;">thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">string</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd></dl>
{{% /choosable %}}
{{% choosable language python %}}
@ -795,15 +795,7 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#helmreleasesettings">Helm<wbr>Release<wbr>Settings</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
title="Required">
<span id="thinker_python">
<a href="#thinker_python" style="color: inherit; text-decoration: inherit;">thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">str</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd><dt class="property-optional"
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="answer_python">
<a href="#answer_python" style="color: inherit; text-decoration: inherit;">answer</a>
@ -835,7 +827,15 @@ All [input](#inputs) properties are implicitly available as output properties. A
<span class="property-indicator"></span>
<span class="property-type"><a href="#layeredtype">Layered<wbr>Type</a></span>
</dt>
<dd>{{% md %}}{{% /md %}}</dd></dl>
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
title="Optional">
<span id="thinker_python">
<a href="#thinker_python" style="color: inherit; text-decoration: inherit;">thinker</a>
</span>
<span class="property-indicator"></span>
<span class="property-type">str</span>
</dt>
<dd>{{% md %}}To ask and answer{{% /md %}}</dd></dl>
{{% /choosable %}}

View file

@ -42,8 +42,8 @@ namespace Pulumi.Example.Inputs
/// <summary>
/// To ask and answer
/// </summary>
[Input("thinker", required: true)]
public Input<string> Thinker { get; set; } = null!;
[Input("thinker")]
public Input<string>? Thinker { get; set; }
public LayeredTypeArgs()
{

View file

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View file

@ -93,7 +93,7 @@ type FooInput interface {
}
func (*Foo) ElementType() reflect.Type {
return reflect.TypeOf((**Foo)(nil)).Elem()
return reflect.TypeOf((*Foo)(nil))
}
func (i *Foo) ToFooOutput() FooOutput {
@ -107,7 +107,7 @@ func (i *Foo) ToFooOutputWithContext(ctx context.Context) FooOutput {
type FooOutput struct{ *pulumi.OutputState }
func (FooOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Foo)(nil)).Elem()
return reflect.TypeOf((*Foo)(nil))
}
func (o FooOutput) ToFooOutput() FooOutput {

View file

@ -7,8 +7,8 @@ import (
"context"
"reflect"
"env-helper/example/mod1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"plain-object-disable-defaults/example/mod1"
)
// A test for namespaces (mod 2)

View file

@ -7,8 +7,8 @@ import (
"context"
"reflect"
"env-helper/example/mod1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"plain-object-disable-defaults/example/mod1"
)
type ModuleTest struct {
@ -76,7 +76,7 @@ type ModuleTestInput interface {
}
func (*ModuleTest) ElementType() reflect.Type {
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
return reflect.TypeOf((*ModuleTest)(nil))
}
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
@ -90,7 +90,7 @@ func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTe
type ModuleTestOutput struct{ *pulumi.OutputState }
func (ModuleTestOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
return reflect.TypeOf((*ModuleTest)(nil))
}
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {

View file

@ -53,7 +53,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (i *Provider) ToProviderOutput() ProviderOutput {
@ -67,7 +67,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
type ProviderOutput struct{ *pulumi.OutputState }
func (ProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

@ -7,9 +7,9 @@ import (
"context"
"reflect"
"env-helper/example/mod1"
"env-helper/example/mod2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"plain-object-disable-defaults/example/mod1"
"plain-object-disable-defaults/example/mod2"
)
// BETA FEATURE - Options to configure the Helm Release resource.
@ -375,7 +375,7 @@ type LayeredType struct {
Question *string `pulumi:"question"`
Recursive *LayeredType `pulumi:"recursive"`
// To ask and answer
Thinker string `pulumi:"thinker"`
Thinker *string `pulumi:"thinker"`
}
// LayeredTypeInput is an input type that accepts LayeredTypeArgs and LayeredTypeOutput values.
@ -400,7 +400,7 @@ type LayeredTypeArgs struct {
Question pulumi.StringPtrInput `pulumi:"question"`
Recursive LayeredTypePtrInput `pulumi:"recursive"`
// To ask and answer
Thinker pulumi.StringInput `pulumi:"thinker"`
Thinker pulumi.StringPtrInput `pulumi:"thinker"`
}
func (LayeredTypeArgs) ElementType() reflect.Type {
@ -505,8 +505,8 @@ func (o LayeredTypeOutput) Recursive() LayeredTypePtrOutput {
}
// To ask and answer
func (o LayeredTypeOutput) Thinker() pulumi.StringOutput {
return o.ApplyT(func(v LayeredType) string { return v.Thinker }).(pulumi.StringOutput)
func (o LayeredTypeOutput) Thinker() pulumi.StringPtrOutput {
return o.ApplyT(func(v LayeredType) *string { return v.Thinker }).(pulumi.StringPtrOutput)
}
type LayeredTypePtrOutput struct{ *pulumi.OutputState }
@ -587,7 +587,7 @@ func (o LayeredTypePtrOutput) Thinker() pulumi.StringPtrOutput {
if v == nil {
return nil
}
return &v.Thinker
return v.Thinker
}).(pulumi.StringPtrOutput)
}

View file

@ -75,11 +75,3 @@ 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()
}

View file

@ -109,7 +109,7 @@ export interface LayeredTypeArgs {
/**
* To ask and answer
*/
thinker: pulumi.Input<string>;
thinker?: pulumi.Input<string>;
}
/**
* layeredTypeArgsProvideDefaults sets the appropriate defaults for LayeredTypeArgs

View file

@ -196,22 +196,19 @@ class KubeClientSettingsArgs:
class LayeredTypeArgs:
def __init__(__self__, *,
other: pulumi.Input['HelmReleaseSettingsArgs'],
thinker: pulumi.Input[str],
answer: Optional[pulumi.Input[float]] = None,
plain_other: Optional['HelmReleaseSettingsArgs'] = None,
question: Optional[pulumi.Input[str]] = None,
recursive: Optional[pulumi.Input['LayeredTypeArgs']] = None):
recursive: Optional[pulumi.Input['LayeredTypeArgs']] = None,
thinker: Optional[pulumi.Input[str]] = None):
"""
Make sure that defaults propagate through types
:param pulumi.Input[str] thinker: To ask and answer
:param pulumi.Input[float] answer: The answer to the question
:param 'HelmReleaseSettingsArgs' plain_other: Test how plain types interact
:param pulumi.Input[str] question: The question already answered
:param pulumi.Input[str] thinker: To ask and answer
"""
pulumi.set(__self__, "other", other)
if thinker is None:
thinker = 'not a good interaction'
pulumi.set(__self__, "thinker", thinker)
if answer is None:
answer = 42
if answer is not None:
@ -224,6 +221,10 @@ class LayeredTypeArgs:
pulumi.set(__self__, "question", question)
if recursive is not None:
pulumi.set(__self__, "recursive", recursive)
if thinker is None:
thinker = 'not a good interaction'
if thinker is not None:
pulumi.set(__self__, "thinker", thinker)
@property
@pulumi.getter
@ -234,18 +235,6 @@ class LayeredTypeArgs:
def other(self, value: pulumi.Input['HelmReleaseSettingsArgs']):
pulumi.set(self, "other", value)
@property
@pulumi.getter
def thinker(self) -> pulumi.Input[str]:
"""
To ask and answer
"""
return pulumi.get(self, "thinker")
@thinker.setter
def thinker(self, value: pulumi.Input[str]):
pulumi.set(self, "thinker", value)
@property
@pulumi.getter
def answer(self) -> Optional[pulumi.Input[float]]:
@ -291,6 +280,18 @@ class LayeredTypeArgs:
def recursive(self, value: Optional[pulumi.Input['LayeredTypeArgs']]):
pulumi.set(self, "recursive", value)
@property
@pulumi.getter
def thinker(self) -> Optional[pulumi.Input[str]]:
"""
To ask and answer
"""
return pulumi.get(self, "thinker")
@thinker.setter
def thinker(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "thinker", value)
@pulumi.input_type
class TypArgs:

View file

@ -156,7 +156,7 @@
"$ref": "#/types/example:index:LayeredType"
}
},
"required": ["other", "thinker"]
"required": ["other"]
},
"example:index:KubeClientSettings": {
"description": "Options for tuning the Kubernetes client used by a Provider.",
@ -219,8 +219,7 @@
}
},
"go": {
"importBasePath": "plain-object-disable-defaults/example",
"disableObjectDefaults": true
"importBasePath": "env-helper/example"
},
"nodejs": {
"dependencies": {

View file

@ -77,7 +77,7 @@ type CatInput interface {
}
func (*Cat) ElementType() reflect.Type {
return reflect.TypeOf((**Cat)(nil)).Elem()
return reflect.TypeOf((*Cat)(nil))
}
func (i *Cat) ToCatOutput() CatOutput {
@ -88,6 +88,35 @@ 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:
//
@ -141,7 +170,7 @@ func (i CatMap) ToCatMapOutputWithContext(ctx context.Context) CatMapOutput {
type CatOutput struct{ *pulumi.OutputState }
func (CatOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Cat)(nil)).Elem()
return reflect.TypeOf((*Cat)(nil))
}
func (o CatOutput) ToCatOutput() CatOutput {
@ -152,10 +181,44 @@ 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)).Elem()
return reflect.TypeOf((*[]Cat)(nil))
}
func (o CatArrayOutput) ToCatArrayOutput() CatArrayOutput {
@ -167,15 +230,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)).Elem()
return reflect.TypeOf((*map[string]Cat)(nil))
}
func (o CatMapOutput) ToCatMapOutput() CatMapOutput {
@ -187,16 +250,18 @@ 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{})
}

View file

@ -101,7 +101,7 @@ type ComponentInput interface {
}
func (*Component) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil)).Elem()
return reflect.TypeOf((*Component)(nil))
}
func (i *Component) ToComponentOutput() ComponentOutput {
@ -112,6 +112,35 @@ 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:
//
@ -165,7 +194,7 @@ func (i ComponentMap) ToComponentMapOutputWithContext(ctx context.Context) Compo
type ComponentOutput struct{ *pulumi.OutputState }
func (ComponentOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil)).Elem()
return reflect.TypeOf((*Component)(nil))
}
func (o ComponentOutput) ToComponentOutput() ComponentOutput {
@ -176,10 +205,44 @@ 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)).Elem()
return reflect.TypeOf((*[]Component)(nil))
}
func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput {
@ -191,15 +254,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)).Elem()
return reflect.TypeOf((*map[string]Component)(nil))
}
func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput {
@ -211,16 +274,18 @@ 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{})
}

View file

@ -48,7 +48,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (i *Provider) ToProviderOutput() ProviderOutput {
@ -59,10 +59,39 @@ 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)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
@ -73,7 +102,43 @@ 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{})
}

View file

@ -75,11 +75,3 @@ 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()
}

View file

@ -74,7 +74,7 @@ type WorkloadInput interface {
}
func (*Workload) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil)).Elem()
return reflect.TypeOf((*Workload)(nil))
}
func (i *Workload) ToWorkloadOutput() WorkloadOutput {
@ -85,6 +85,35 @@ 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:
//
@ -138,7 +167,7 @@ func (i WorkloadMap) ToWorkloadMapOutputWithContext(ctx context.Context) Workloa
type WorkloadOutput struct{ *pulumi.OutputState }
func (WorkloadOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil)).Elem()
return reflect.TypeOf((*Workload)(nil))
}
func (o WorkloadOutput) ToWorkloadOutput() WorkloadOutput {
@ -149,10 +178,44 @@ 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)).Elem()
return reflect.TypeOf((*[]Workload)(nil))
}
func (o WorkloadArrayOutput) ToWorkloadArrayOutput() WorkloadArrayOutput {
@ -164,15 +227,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)).Elem()
return reflect.TypeOf((*map[string]Workload)(nil))
}
func (o WorkloadMapOutput) ToWorkloadMapOutput() WorkloadMapOutput {
@ -184,16 +247,18 @@ 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{})
}

View file

@ -48,7 +48,7 @@ type ProviderInput interface {
}
func (*Provider) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (i *Provider) ToProviderOutput() ProviderOutput {
@ -59,10 +59,39 @@ 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)).Elem()
return reflect.TypeOf((*Provider)(nil))
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
@ -73,7 +102,43 @@ 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{})
}

View file

@ -75,11 +75,3 @@ 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()
}

Some files were not shown because too many files have changed in this diff Show more