Compare commits
4 commits
master
...
pgavlin/re
Author | SHA1 | Date | |
---|---|---|---|
88f9ca4b51 | |||
87d9be60e1 | |||
e8f3d448db | |||
e07c2c2c21 |
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -1,43 +1,6 @@
|
||||||
CHANGELOG
|
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)
|
## 3.18.0 (2021-11-17)
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being
|
- Clear pending operations during `pulumi refresh` or `pulumi up -r`.
|
||||||
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of
|
[#8435](https://github.com/pulumi/pulumi/pull/8435)
|
||||||
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
|
### Bug Fixes
|
||||||
|
|
||||||
- [codegen/go] - Respect default values in Pulumi object types.
|
- [codegen/typescript] - Respect default values in Pulumi object types.
|
||||||
[#8411](https://github.com/pulumi/pulumi/pull/8400)
|
[#8400](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
|
You can easily get all required dependencies with brew and npm
|
||||||
|
|
||||||
```bash
|
```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
|
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
|
brew install --HEAD -s dotnet-sdk.rb
|
||||||
rm 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:
|
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
|
0. `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
|
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`.
|
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 |
|
| 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) |
|
| 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) |
|
| 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
|
### Languages
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ func (b *localBackend) GetStack(ctx context.Context, stackRef backend.StackRefer
|
||||||
snapshot, path, err := b.getStack(stackName)
|
snapshot, path, err := b.getStack(stackName)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case gcerrors.Code(err) == gcerrors.NotFound:
|
case gcerrors.Code(drillError(err)) == gcerrors.NotFound:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -882,3 +882,12 @@ func (b *localBackend) UpdateStackTags(ctx context.Context,
|
||||||
// The local backend does not currently persist tags.
|
// The local backend does not currently persist tags.
|
||||||
return errors.New("stack tags not supported in --local mode")
|
return errors.New("stack tags not supported in --local mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the original error in the chain. If `err` is nil, nil is returned.
|
||||||
|
func drillError(err error) error {
|
||||||
|
e := err
|
||||||
|
for errors.Unwrap(e) != nil {
|
||||||
|
e = errors.Unwrap(e)
|
||||||
|
}
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
|
@ -187,20 +187,3 @@ func TestListStacksWithMultiplePassphrases(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDrillError(t *testing.T) {
|
|
||||||
// Login to a temp dir filestate backend
|
|
||||||
tmpDir, err := ioutil.TempDir("", "filestatebackend")
|
|
||||||
assert.NoError(t, err)
|
|
||||||
b, err := New(cmdutil.Diag(), "file://"+filepath.ToSlash(tmpDir))
|
|
||||||
assert.NoError(t, err)
|
|
||||||
ctx := context.Background()
|
|
||||||
|
|
||||||
// Get a non-existent stack and expect a nil error because it won't be found.
|
|
||||||
stackRef, err := b.ParseStackReference("dev")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("unexpected error %v when parsing stack reference", err)
|
|
||||||
}
|
|
||||||
_, err = b.GetStack(ctx, stackRef)
|
|
||||||
assert.Nil(t, err)
|
|
||||||
}
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ func (b *localBackend) getHistory(name tokens.QName, pageSize int, page int) ([]
|
||||||
allFiles, err := listBucket(b.bucket, dir)
|
allFiles, err := listBucket(b.bucket, dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// History doesn't exist until a stack has been updated.
|
// History doesn't exist until a stack has been updated.
|
||||||
if gcerrors.Code(err) == gcerrors.NotFound {
|
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -391,7 +391,7 @@ func (b *localBackend) renameHistory(oldName tokens.QName, newName tokens.QName)
|
||||||
allFiles, err := listBucket(b.bucket, oldHistory)
|
allFiles, err := listBucket(b.bucket, oldHistory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// if there's nothing there, we don't really need to do a rename.
|
// if there's nothing there, we don't really need to do a rename.
|
||||||
if gcerrors.Code(err) == gcerrors.NotFound {
|
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -902,14 +902,8 @@ func (mod *modContext) genNestedTypes(member interface{}, resourceType bool) []d
|
||||||
// and if it appears in an input object and/or output object.
|
// and if it appears in an input object and/or output object.
|
||||||
mod.getTypes(member, tokens)
|
mod.getTypes(member, tokens)
|
||||||
|
|
||||||
var sortedTokens []string
|
|
||||||
for token := range tokens {
|
|
||||||
sortedTokens = append(sortedTokens, token)
|
|
||||||
}
|
|
||||||
sort.Strings(sortedTokens)
|
|
||||||
|
|
||||||
var typs []docNestedType
|
var typs []docNestedType
|
||||||
for _, token := range sortedTokens {
|
for token := range tokens {
|
||||||
for _, t := range mod.pkg.Types {
|
for _, t := range mod.pkg.Types {
|
||||||
switch typ := t.(type) {
|
switch typ := t.(type) {
|
||||||
case *schema.ObjectType:
|
case *schema.ObjectType:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2016-2021, Pulumi Corporation.
|
// Copyright 2016-2020, Pulumi Corporation.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -46,9 +46,6 @@ type generator struct {
|
||||||
asyncInit bool
|
asyncInit bool
|
||||||
configCreated bool
|
configCreated bool
|
||||||
diagnostics hcl.Diagnostics
|
diagnostics hcl.Diagnostics
|
||||||
// Helper map to emit custom type name suffixes that match
|
|
||||||
// those emitted by codegen.
|
|
||||||
usedInFunctionOutputVersionInputs map[schema.Type]bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const pulumiPackage = "pulumi"
|
const pulumiPackage = "pulumi"
|
||||||
|
@ -346,32 +343,14 @@ func (g *generator) functionName(tokenArg model.Expression) (string, string) {
|
||||||
return rootNamespace, fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
|
return rootNamespace, fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *generator) toSchemaType(destType model.Type) (schema.Type, bool) {
|
|
||||||
schemaType, ok := pcl.GetSchemaForType(destType.(model.Type))
|
|
||||||
if !ok {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
return codegen.UnwrapType(schemaType), true
|
|
||||||
}
|
|
||||||
|
|
||||||
// argumentTypeName computes the C# argument class name for the given expression and model type.
|
// argumentTypeName computes the C# argument class name for the given expression and model type.
|
||||||
func (g *generator) argumentTypeName(expr model.Expression, destType model.Type) string {
|
func (g *generator) argumentTypeName(expr model.Expression, destType model.Type) string {
|
||||||
schemaType, ok := g.toSchemaType(destType)
|
schemaType, ok := pcl.GetSchemaForType(destType.(model.Type))
|
||||||
if !ok {
|
if !ok {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
suffix := "Args"
|
|
||||||
if g.usedInFunctionOutputVersionInputs[schemaType] {
|
|
||||||
suffix = "InputArgs"
|
|
||||||
}
|
|
||||||
return g.argumentTypeNameWithSuffix(expr, destType, suffix)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) argumentTypeNameWithSuffix(expr model.Expression, destType model.Type, suffix string) string {
|
schemaType = codegen.UnwrapType(schemaType)
|
||||||
schemaType, ok := g.toSchemaType(destType)
|
|
||||||
if !ok {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
objType, ok := schemaType.(*schema.ObjectType)
|
objType, ok := schemaType.(*schema.ObjectType)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -403,7 +382,7 @@ func (g *generator) argumentTypeNameWithSuffix(expr model.Expression, destType m
|
||||||
} else if qualifier != "" {
|
} else if qualifier != "" {
|
||||||
namespace = namespace + "." + qualifier
|
namespace = namespace + "." + qualifier
|
||||||
}
|
}
|
||||||
member = member + suffix
|
member = member + "Args"
|
||||||
|
|
||||||
return fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
|
return fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,28 +255,6 @@ func (g *generator) genFunctionUsings(x *model.FunctionCallExpression) []string
|
||||||
return []string{fmt.Sprintf("%s = Pulumi.%[1]s", pkg)}
|
return []string{fmt.Sprintf("%s = Pulumi.%[1]s", pkg)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *generator) markTypeAsUsedInFunctionOutputVersionInputs(t model.Type) {
|
|
||||||
if g.usedInFunctionOutputVersionInputs == nil {
|
|
||||||
g.usedInFunctionOutputVersionInputs = make(map[schema.Type]bool)
|
|
||||||
}
|
|
||||||
schemaType, ok := g.toSchemaType(t)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
g.usedInFunctionOutputVersionInputs[schemaType] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) visitToMarkTypesUsedInFunctionOutputVersionInputs(expr model.Expression) {
|
|
||||||
visitor := func(expr model.Expression) (model.Expression, hcl.Diagnostics) {
|
|
||||||
isCons, _, t := pcl.RecognizeTypedObjectCons(expr)
|
|
||||||
if isCons {
|
|
||||||
g.markTypeAsUsedInFunctionOutputVersionInputs(t)
|
|
||||||
}
|
|
||||||
return expr, nil
|
|
||||||
}
|
|
||||||
model.VisitExpression(expr, nil, visitor) // nolint:errcheck
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionCallExpression) {
|
func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionCallExpression) {
|
||||||
switch expr.Name {
|
switch expr.Name {
|
||||||
case pcl.IntrinsicConvert:
|
case pcl.IntrinsicConvert:
|
||||||
|
@ -316,19 +294,10 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
||||||
case pcl.Invoke:
|
case pcl.Invoke:
|
||||||
_, name := g.functionName(expr.Args[0])
|
_, name := g.functionName(expr.Args[0])
|
||||||
|
|
||||||
isOut, outArgs, outArgsTy := pcl.RecognizeOutputVersionedInvoke(expr)
|
g.Fprintf(w, "%s.InvokeAsync(", name)
|
||||||
if isOut {
|
if len(expr.Args) >= 2 {
|
||||||
g.visitToMarkTypesUsedInFunctionOutputVersionInputs(outArgs)
|
g.Fgenf(w, "%.v", expr.Args[1])
|
||||||
g.Fprintf(w, "%s.Invoke(", name)
|
|
||||||
typeName := g.argumentTypeNameWithSuffix(expr, outArgsTy, "InvokeArgs")
|
|
||||||
g.genObjectConsExpressionWithTypeName(w, outArgs, typeName)
|
|
||||||
} else {
|
|
||||||
g.Fprintf(w, "%s.InvokeAsync(", name)
|
|
||||||
if len(expr.Args) >= 2 {
|
|
||||||
g.Fgenf(w, "%.v", expr.Args[1])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(expr.Args) == 3 {
|
if len(expr.Args) == 3 {
|
||||||
g.Fgenf(w, ", %.v", expr.Args[2])
|
g.Fgenf(w, ", %.v", expr.Args[2])
|
||||||
}
|
}
|
||||||
|
@ -477,18 +446,7 @@ func (g *generator) genObjectConsExpression(w io.Writer, expr *model.ObjectConsE
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
destTypeName := g.argumentTypeName(expr, destType)
|
typeName := g.argumentTypeName(expr, destType)
|
||||||
g.genObjectConsExpressionWithTypeName(w, expr, destTypeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) genObjectConsExpressionWithTypeName(
|
|
||||||
w io.Writer, expr *model.ObjectConsExpression, destTypeName string) {
|
|
||||||
|
|
||||||
if len(expr.Items) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
typeName := destTypeName
|
|
||||||
if typeName != "" {
|
if typeName != "" {
|
||||||
g.Fgenf(w, "new %s", typeName)
|
g.Fgenf(w, "new %s", typeName)
|
||||||
g.Fgenf(w, "\n%s{\n", g.Indent)
|
g.Fgenf(w, "\n%s{\n", g.Indent)
|
||||||
|
|
|
@ -114,9 +114,6 @@ type pkgContext struct {
|
||||||
|
|
||||||
// Determines if we should emit type registration code
|
// Determines if we should emit type registration code
|
||||||
disableInputTypeRegistrations bool
|
disableInputTypeRegistrations bool
|
||||||
|
|
||||||
// Determines if we should emit object defaults code
|
|
||||||
disableObjectDefaults bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
|
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
|
||||||
|
@ -272,7 +269,6 @@ func rawResourceName(r *schema.Resource) string {
|
||||||
return tokenToName(r.Token)
|
return tokenToName(r.Token)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If `nil` is a valid value of type `t`.
|
|
||||||
func isNilType(t schema.Type) bool {
|
func isNilType(t schema.Type) bool {
|
||||||
switch t := t.(type) {
|
switch t := t.(type) {
|
||||||
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
|
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
|
||||||
|
@ -299,6 +295,23 @@ func isNilType(t schema.Type) bool {
|
||||||
return false
|
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) {
|
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
|
||||||
switch t := codegen.SimplifyInputUnion(t).(type) {
|
switch t := codegen.SimplifyInputUnion(t).(type) {
|
||||||
case *schema.OptionalType:
|
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 {
|
func (pkg *pkgContext) typeString(t schema.Type) string {
|
||||||
s := pkg.typeStringImpl(t, false)
|
return pkg.typeStringImpl(t, false)
|
||||||
if s == "pulumi." {
|
|
||||||
return "pulumi.Any"
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
|
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
|
||||||
|
@ -563,10 +571,6 @@ func (pkg *pkgContext) resolveObjectType(t *schema.ObjectType) string {
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
return pkg.contextForExternalReferenceType(t).typeString(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pkg *pkgContext) contextForExternalReferenceType(t *schema.ObjectType) *pkgContext {
|
|
||||||
extPkg := t.Package
|
extPkg := t.Package
|
||||||
var goInfo GoPackageInfo
|
var goInfo GoPackageInfo
|
||||||
|
|
||||||
|
@ -580,7 +584,7 @@ func (pkg *pkgContext) contextForExternalReferenceType(t *schema.ObjectType) *pk
|
||||||
pkgImportAliases: goInfo.PackageImportAliases,
|
pkgImportAliases: goInfo.PackageImportAliases,
|
||||||
modToPkg: goInfo.ModuleToPackage,
|
modToPkg: goInfo.ModuleToPackage,
|
||||||
}
|
}
|
||||||
return extPkgCtx
|
return extPkgCtx.typeString(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) outputType(t schema.Type) string {
|
func (pkg *pkgContext) outputType(t schema.Type) string {
|
||||||
|
@ -625,9 +629,6 @@ func (pkg *pkgContext) outputType(t schema.Type) string {
|
||||||
}
|
}
|
||||||
// TODO(pdg): union types
|
// TODO(pdg): union types
|
||||||
return "pulumi.AnyOutput"
|
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:
|
default:
|
||||||
switch t {
|
switch t {
|
||||||
case schema.BoolType:
|
case schema.BoolType:
|
||||||
|
@ -779,14 +780,16 @@ type genInputImplementationArgs struct {
|
||||||
elementType string
|
elementType string
|
||||||
ptrMethods bool
|
ptrMethods bool
|
||||||
toOutputMethods 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{
|
genInputImplementationWithArgs(w, genInputImplementationArgs{
|
||||||
name: name,
|
name: name,
|
||||||
receiverType: receiverType,
|
receiverType: receiverType,
|
||||||
elementType: elementType,
|
elementType: elementType,
|
||||||
ptrMethods: ptrMethods,
|
ptrMethods: ptrMethods,
|
||||||
|
resourceType: resourceType,
|
||||||
toOutputMethods: true,
|
toOutputMethods: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -795,9 +798,14 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
||||||
name := genArgs.name
|
name := genArgs.name
|
||||||
receiverType := genArgs.receiverType
|
receiverType := genArgs.receiverType
|
||||||
elementType := genArgs.elementType
|
elementType := genArgs.elementType
|
||||||
|
resourceType := genArgs.resourceType
|
||||||
|
|
||||||
fmt.Fprintf(w, "func (%s) ElementType() reflect.Type {\n", receiverType)
|
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")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
|
|
||||||
if genArgs.toOutputMethods {
|
if genArgs.toOutputMethods {
|
||||||
|
@ -825,11 +833,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, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
|
||||||
|
|
||||||
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\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, "}\n\n")
|
||||||
|
|
||||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
|
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
|
||||||
|
@ -853,8 +865,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func genArrayOutput(w io.Writer, baseName, elementType string) {
|
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||||
genOutputType(w, baseName+"Array", "[]"+elementType, false)
|
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, "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)
|
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", elementType)
|
||||||
|
@ -863,8 +875,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string) {
|
||||||
fmt.Fprintf(w, "}\n\n")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func genMapOutput(w io.Writer, baseName, elementType string) {
|
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
|
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, "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)
|
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s{\n", elementType)
|
||||||
|
@ -873,8 +885,8 @@ func genMapOutput(w io.Writer, baseName, elementType string) {
|
||||||
fmt.Fprintf(w, "}\n\n")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func genPtrOutput(w io.Writer, baseName, elementType string) {
|
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
|
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
|
||||||
|
|
||||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) Elem() %[1]sOutput {\n", baseName)
|
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)
|
fmt.Fprintf(w, "\treturn o.ApplyT(func(v *%[1]s) %[1]s {\n", baseName)
|
||||||
|
@ -940,7 +952,7 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
||||||
|
|
||||||
fmt.Fprintf(w, "type %[1]sArray []%[1]s\n\n", name)
|
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.
|
// Generate the map input.
|
||||||
|
@ -949,24 +961,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)
|
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
|
// Generate the array output
|
||||||
if details.arrayElement {
|
if details.arrayElement {
|
||||||
genArrayOutput(w, name, name)
|
genArrayOutput(w, name, name, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the map output.
|
// Generate the map output.
|
||||||
if details.mapElement {
|
if details.mapElement {
|
||||||
genMapOutput(w, name, name)
|
genMapOutput(w, name, name, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
|
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, "func (o %[1]sOutput) To%[2]sOutput() %[3]sOutput {\n", name, asFuncName, elementArgsType)
|
||||||
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
|
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
|
||||||
|
@ -989,7 +1001,7 @@ func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, el
|
||||||
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
|
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
|
||||||
fmt.Fprint(w, "}\n\n")
|
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, "func (o %[1]sPtrOutput) To%[2]sPtrOutput() %[3]sPtrOutput {\n", name, asFuncName, elementArgsType)
|
||||||
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
|
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
|
||||||
|
@ -1091,27 +1103,6 @@ func (pkg *pkgContext) genEnumInputFuncs(w io.Writer, typeName string, enum *sch
|
||||||
fmt.Fprintln(w)
|
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,
|
func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessage string,
|
||||||
properties []*schema.Property) {
|
properties []*schema.Property) {
|
||||||
|
|
||||||
|
@ -1124,66 +1115,6 @@ func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessa
|
||||||
fmt.Fprintf(w, "}\n\n")
|
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) {
|
func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details *typeDetails) {
|
||||||
contract.Assert(t.IsInputShape())
|
contract.Assert(t.IsInputShape())
|
||||||
|
|
||||||
|
@ -1194,7 +1125,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
||||||
|
|
||||||
pkg.genInputArgsStruct(w, name+"Args", t)
|
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.
|
// Generate the pointer input.
|
||||||
if details.ptrElement {
|
if details.ptrElement {
|
||||||
|
@ -1208,7 +1139,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
||||||
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
|
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
|
||||||
fmt.Fprintf(w, "}\n\n")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
|
|
||||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false)
|
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the array input.
|
// Generate the array input.
|
||||||
|
@ -1217,7 +1148,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
||||||
|
|
||||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
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.
|
// Generate the map input.
|
||||||
|
@ -1226,7 +1157,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)
|
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 +1196,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
||||||
name, /* baseName */
|
name, /* baseName */
|
||||||
name, /* elementType */
|
name, /* elementType */
|
||||||
details.ptrElement, /* ptrMethods */
|
details.ptrElement, /* ptrMethods */
|
||||||
|
false, /* resourceType */
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, p := range t.Properties {
|
for _, p := range t.Properties {
|
||||||
|
@ -1283,7 +1215,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if details.ptrElement {
|
if details.ptrElement {
|
||||||
genPtrOutput(w, name, name)
|
genPtrOutput(w, name, name, false)
|
||||||
|
|
||||||
for _, p := range t.Properties {
|
for _, p := range t.Properties {
|
||||||
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
|
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
|
||||||
|
@ -1316,11 +1248,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if details.arrayElement {
|
if details.arrayElement {
|
||||||
genArrayOutput(w, name, name)
|
genArrayOutput(w, name, name, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if details.mapElement {
|
if details.mapElement {
|
||||||
genMapOutput(w, name, name)
|
genMapOutput(w, name, name, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1374,11 +1306,6 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
val = v
|
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 {
|
if len(dv.Environment) > 0 {
|
||||||
|
@ -1462,8 +1389,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
||||||
fmt.Fprintf(w, "\t}\n\n")
|
fmt.Fprintf(w, "\t}\n\n")
|
||||||
|
|
||||||
// Produce the inputs.
|
// Produce the inputs.
|
||||||
|
|
||||||
// Check all required inputs are present
|
|
||||||
for _, p := range r.InputProperties {
|
for _, p := range r.InputProperties {
|
||||||
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
|
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
|
||||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||||
|
@ -1472,8 +1397,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assign := func(p *schema.Property, value string) {
|
assign := func(p *schema.Property, value string, indentation int) {
|
||||||
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
|
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 {
|
for _, p := range r.InputProperties {
|
||||||
|
@ -1482,51 +1425,19 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
assign(p, v)
|
assign(p, v, 1)
|
||||||
} else if p.DefaultValue != nil {
|
} 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pkg.needsUtils = true
|
defaultComp := "nil"
|
||||||
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
|
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
|
||||||
assign(p, dv)
|
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")
|
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 +1704,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, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
|
||||||
fmt.Fprintf(w, "}\n\n")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
|
|
||||||
genInputImplementation(w, name, "*"+name, "*"+name, false)
|
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, true)
|
||||||
|
|
||||||
if generateResourceContainerTypes && !r.IsProvider {
|
if generateResourceContainerTypes {
|
||||||
// Generate the resource array input.
|
// Emit the resource pointer input type.
|
||||||
pkg.genInputInterface(w, name+"Array")
|
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
|
||||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
fmt.Fprintf(w, "\tpulumi.Input\n\n")
|
||||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false)
|
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.
|
if !r.IsProvider {
|
||||||
pkg.genInputInterface(w, name+"Map")
|
// Generate the resource array input.
|
||||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
pkg.genInputInterface(w, name+"Array")
|
||||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false)
|
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.
|
// Emit the resource output type.
|
||||||
genOutputType(w, name, "*"+name, false)
|
genOutputType(w, name, name, generateResourceContainerTypes, true)
|
||||||
|
|
||||||
if generateResourceContainerTypes && !r.IsProvider {
|
if generateResourceContainerTypes {
|
||||||
genArrayOutput(w, name, "*"+name)
|
genPtrOutput(w, name, name, true)
|
||||||
genMapOutput(w, name, "*"+name)
|
|
||||||
|
if !r.IsProvider {
|
||||||
|
genArrayOutput(w, name, name, true)
|
||||||
|
genMapOutput(w, name, name, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
|
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
|
||||||
|
@ -1820,30 +1747,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
||||||
return nil
|
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 {
|
func NeedsGoOutputVersion(f *schema.Function) bool {
|
||||||
fPkg := f.Package
|
fPkg := f.Package
|
||||||
|
|
||||||
|
@ -1861,7 +1764,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
|
||||||
return f.NeedsOutputVersion()
|
return f.NeedsOutputVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
|
||||||
importsAndAliases := map[string]string{}
|
importsAndAliases := map[string]string{}
|
||||||
pkg.getImports(f, importsAndAliases)
|
pkg.getImports(f, importsAndAliases)
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
|
@ -1872,14 +1775,12 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg.genHeader(buffer, imports, importsAndAliases)
|
pkg.genHeader(buffer, imports, importsAndAliases)
|
||||||
if err := pkg.genFunction(buffer, f); err != nil {
|
pkg.genFunction(buffer, f)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
pkg.genFunctionOutputVersion(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)
|
name := pkg.functionName(f)
|
||||||
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
|
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
|
||||||
|
|
||||||
|
@ -1900,8 +1801,6 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
||||||
var inputsVar string
|
var inputsVar string
|
||||||
if f.Inputs == nil {
|
if f.Inputs == nil {
|
||||||
inputsVar = "nil"
|
inputsVar = "nil"
|
||||||
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
|
||||||
inputsVar = "args.Defaults()"
|
|
||||||
} else {
|
} else {
|
||||||
inputsVar = "args"
|
inputsVar = "args"
|
||||||
}
|
}
|
||||||
|
@ -1925,38 +1824,19 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
||||||
fmt.Fprintf(w, "\t}\n")
|
fmt.Fprintf(w, "\t}\n")
|
||||||
|
|
||||||
// Return the result.
|
// Return the result.
|
||||||
var retValue string
|
fmt.Fprintf(w, "\treturn &rv, nil\n")
|
||||||
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")
|
fmt.Fprintf(w, "}\n")
|
||||||
|
|
||||||
// If there are argument and/or return types, emit them.
|
// If there are argument and/or return types, emit them.
|
||||||
if f.Inputs != nil {
|
if f.Inputs != nil {
|
||||||
fmt.Fprintf(w, "\n")
|
fmt.Fprintf(w, "\n")
|
||||||
fnInputsName := pkg.functionArgsTypeName(f)
|
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
|
||||||
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 {
|
if f.Outputs != nil {
|
||||||
fmt.Fprintf(w, "\n")
|
fmt.Fprintf(w, "\n")
|
||||||
fnOutputsName := pkg.functionResultTypeName(f)
|
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
|
||||||
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 {
|
func (pkg *pkgContext) functionName(f *schema.Function) string {
|
||||||
|
@ -2135,24 +2015,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())
|
contract.Assert(!obj.IsInputShape())
|
||||||
if obj.IsOverlay {
|
if obj.IsOverlay {
|
||||||
// This type is generated by the provider, so no further action is required.
|
// This type is generated by the provider, so no further action is required.
|
||||||
return nil
|
return
|
||||||
}
|
|
||||||
|
|
||||||
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.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
|
||||||
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
|
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
|
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
|
||||||
|
@ -2224,16 +2096,16 @@ func (pkg *pkgContext) genNestedCollectionTypes(w io.Writer, types map[string]ma
|
||||||
names = append(names, name)
|
names = append(names, name)
|
||||||
if strings.HasSuffix(name, "Array") {
|
if strings.HasSuffix(name, "Array") {
|
||||||
fmt.Fprintf(w, "type %s []%sInput\n\n", name, elementTypeName)
|
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") {
|
if strings.HasSuffix(name, "Map") {
|
||||||
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
|
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)
|
pkg.genInputInterface(w, name)
|
||||||
}
|
}
|
||||||
|
@ -2360,13 +2232,18 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
||||||
fmt.Fprintf(w,
|
fmt.Fprintf(w,
|
||||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
|
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
|
||||||
name)
|
name)
|
||||||
if generateResourceContainerTypes && !r.IsProvider {
|
if generateResourceContainerTypes {
|
||||||
fmt.Fprintf(w,
|
fmt.Fprintf(w,
|
||||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\n",
|
||||||
name)
|
|
||||||
fmt.Fprintf(w,
|
|
||||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
|
||||||
name)
|
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
|
// Register all output types
|
||||||
|
@ -2381,9 +2258,12 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if generateResourceContainerTypes && !r.IsProvider {
|
if generateResourceContainerTypes {
|
||||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
|
||||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\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")
|
fmt.Fprintf(w, "}\n\n")
|
||||||
}
|
}
|
||||||
|
@ -2786,7 +2666,6 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
||||||
packages: packages,
|
packages: packages,
|
||||||
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
|
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
|
||||||
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
|
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
|
||||||
disableObjectDefaults: goInfo.DisableObjectDefaults,
|
|
||||||
}
|
}
|
||||||
packages[mod] = pack
|
packages[mod] = pack
|
||||||
}
|
}
|
||||||
|
@ -3110,10 +2989,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
||||||
pkg.functions = append(pkg.functions, f)
|
pkg.functions = append(pkg.functions, f)
|
||||||
|
|
||||||
name := tokenToName(f.Token)
|
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 {
|
switch {
|
||||||
case strings.HasPrefix(name, "New"):
|
case strings.HasPrefix(name, "New"):
|
||||||
name = "Create" + name[3:]
|
name = "Create" + name[3:]
|
||||||
|
@ -3126,9 +3003,15 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
||||||
|
|
||||||
if f.Inputs != nil {
|
if f.Inputs != nil {
|
||||||
pkg.names.Add(name + "Args")
|
pkg.names.Add(name + "Args")
|
||||||
|
if originalName != name {
|
||||||
|
pkg.renamed[originalName+"Args"] = name + "Args"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if f.Outputs != nil {
|
if f.Outputs != nil {
|
||||||
pkg.names.Add(name + "Result")
|
pkg.names.Add(name + "Result")
|
||||||
|
if originalName != name {
|
||||||
|
pkg.renamed[originalName+"Result"] = name + "Result"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3317,10 +3200,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
||||||
code, err := pkg.genFunctionCodeFile(f)
|
code := pkg.genFunctionCodeFile(f)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
setFile(fileName, code)
|
setFile(fileName, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3360,9 +3240,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
||||||
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
|
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
|
||||||
|
|
||||||
for _, t := range pkg.types {
|
for _, t := range pkg.types {
|
||||||
if err := pkg.genType(buffer, t); err != nil {
|
pkg.genType(buffer, t)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
delete(knownTypes, t)
|
delete(knownTypes, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3498,12 +3376,4 @@ func PkgVersion() (semver.Version, error) {
|
||||||
}
|
}
|
||||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %%s", pkgPath)
|
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,9 +43,7 @@ func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error
|
||||||
|
|
||||||
if len(pkg.types) > 0 {
|
if len(pkg.types) > 0 {
|
||||||
for _, t := range pkg.types {
|
for _, t := range pkg.types {
|
||||||
if err := pkg.genType(buffer, t); err != nil {
|
pkg.genType(buffer, t)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pkg.genTypeRegistrations(buffer, pkg.types)
|
pkg.genTypeRegistrations(buffer, pkg.types)
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,9 @@ func (g *generator) collectImports(
|
||||||
}
|
}
|
||||||
pulumiImports.Add(g.getPulumiImport(pkg, vPath, mod))
|
pulumiImports.Add(g.getPulumiImport(pkg, vPath, mod))
|
||||||
} else if call.Name == pcl.IntrinsicConvert {
|
} else if call.Name == pcl.IntrinsicConvert {
|
||||||
g.collectConvertImports(program, call, pulumiImports)
|
if schemaType, ok := pcl.GetSchemaForType(call.Type()); ok {
|
||||||
|
g.collectTypeImports(program, schemaType, pulumiImports)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking to see if this function call deserves its own dedicated helper method in the preamble
|
// Checking to see if this function call deserves its own dedicated helper method in the preamble
|
||||||
|
@ -275,30 +277,6 @@ func (g *generator) collectImports(
|
||||||
return stdImports, pulumiImports, preambleHelperMethods
|
return stdImports, pulumiImports, preambleHelperMethods
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *generator) collectConvertImports(
|
|
||||||
program *pcl.Program,
|
|
||||||
call *model.FunctionCallExpression,
|
|
||||||
pulumiImports codegen.StringSet) {
|
|
||||||
if schemaType, ok := pcl.GetSchemaForType(call.Type()); ok {
|
|
||||||
// Sometimes code for a `__convert` call does not
|
|
||||||
// really use the import of the result type. In such
|
|
||||||
// cases it is important not to generate a
|
|
||||||
// non-compiling unused import. Detect some of these
|
|
||||||
// cases here.
|
|
||||||
//
|
|
||||||
// Fully solving this is deferred for later:
|
|
||||||
// TODO[pulumi/pulumi#8324].
|
|
||||||
if expr, ok := call.Args[0].(*model.TemplateExpression); ok {
|
|
||||||
if lit, ok := expr.Parts[0].(*model.LiteralValueExpression); ok &&
|
|
||||||
model.StringType.AssignableFrom(lit.Type()) &&
|
|
||||||
call.Type().AssignableFrom(lit.Type()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g.collectTypeImports(program, schemaType, pulumiImports)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) getVersionPath(program *pcl.Program, pkg string) (string, error) {
|
func (g *generator) getVersionPath(program *pcl.Program, pkg string) (string, error) {
|
||||||
for _, p := range program.Packages() {
|
for _, p := range program.Packages() {
|
||||||
if p.Name == pkg {
|
if p.Name == pkg {
|
||||||
|
@ -636,17 +614,11 @@ func (g *generator) genLocalVariable(w io.Writer, v *pcl.LocalVariable) {
|
||||||
case *model.FunctionCallExpression:
|
case *model.FunctionCallExpression:
|
||||||
switch expr.Name {
|
switch expr.Name {
|
||||||
case pcl.Invoke:
|
case pcl.Invoke:
|
||||||
// OutputVersionedInvoke does not return an error
|
g.Fgenf(w, "%s, err %s %.3v;\n", name, assignment, expr)
|
||||||
noError, _, _ := pcl.RecognizeOutputVersionedInvoke(expr)
|
g.isErrAssigned = true
|
||||||
if noError {
|
g.Fgenf(w, "if err != nil {\n")
|
||||||
g.Fgenf(w, "%s %s %.3v;\n", name, assignment, expr)
|
g.Fgenf(w, "return err\n")
|
||||||
} else {
|
g.Fgenf(w, "}\n")
|
||||||
g.Fgenf(w, "%s, err %s %.3v;\n", name, assignment, expr)
|
|
||||||
g.isErrAssigned = true
|
|
||||||
g.Fgenf(w, "if err != nil {\n")
|
|
||||||
g.Fgenf(w, "return err\n")
|
|
||||||
g.Fgenf(w, "}\n")
|
|
||||||
}
|
|
||||||
case "join", "toBase64", "mimeType", "fileAsset":
|
case "join", "toBase64", "mimeType", "fileAsset":
|
||||||
g.Fgenf(w, "%s := %.3v;\n", name, expr)
|
g.Fgenf(w, "%s := %.3v;\n", name, expr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,18 +195,7 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
||||||
if module == "" {
|
if module == "" {
|
||||||
module = pkg
|
module = pkg
|
||||||
}
|
}
|
||||||
isOut, outArgs, outArgsType := pcl.RecognizeOutputVersionedInvoke(expr)
|
name := fmt.Sprintf("%s.%s", module, fn)
|
||||||
if isOut {
|
|
||||||
outTypeName, err := outputVersionFunctionArgTypeName(outArgsType)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("Error when generating an output-versioned Invoke: %w", err))
|
|
||||||
}
|
|
||||||
g.Fgenf(w, "%s.%sOutput(ctx, ", module, fn)
|
|
||||||
g.genObjectConsExpressionWithTypeName(w, outArgs, outArgsType, outTypeName)
|
|
||||||
} else {
|
|
||||||
g.Fgenf(w, "%s.%s(ctx, ", module, fn)
|
|
||||||
g.Fgenf(w, "%.v", expr.Args[1])
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsBag := ""
|
optionsBag := ""
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
@ -216,6 +205,9 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
||||||
g.Fgenf(&buf, ", nil")
|
g.Fgenf(&buf, ", nil")
|
||||||
}
|
}
|
||||||
optionsBag = buf.String()
|
optionsBag = buf.String()
|
||||||
|
|
||||||
|
g.Fgenf(w, "%s(ctx, ", name)
|
||||||
|
g.Fgenf(w, "%.v", expr.Args[1])
|
||||||
g.Fgenf(w, "%v)", optionsBag)
|
g.Fgenf(w, "%v)", optionsBag)
|
||||||
case "join":
|
case "join":
|
||||||
g.Fgenf(w, "strings.Join(%v, %v)", expr.Args[1], expr.Args[0])
|
g.Fgenf(w, "strings.Join(%v, %v)", expr.Args[1], expr.Args[0])
|
||||||
|
@ -254,32 +246,6 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently args type for output-versioned invokes are named
|
|
||||||
// `FOutputArgs`, but this is not yet understood by `tokenToType`. Use
|
|
||||||
// this function to compensate.
|
|
||||||
func outputVersionFunctionArgTypeName(t model.Type) (string, error) {
|
|
||||||
schemaType, ok := pcl.GetSchemaForType(t)
|
|
||||||
if !ok {
|
|
||||||
return "", fmt.Errorf("No schema.Type type found for the given model.Type")
|
|
||||||
}
|
|
||||||
|
|
||||||
objType, ok := schemaType.(*schema.ObjectType)
|
|
||||||
if !ok {
|
|
||||||
return "", fmt.Errorf("Expected a schema.ObjectType, got %s", schemaType.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg := &pkgContext{pkg: &schema.Package{Name: "main"}}
|
|
||||||
|
|
||||||
var ty string
|
|
||||||
if pkg.isExternalReference(objType) {
|
|
||||||
ty = pkg.contextForExternalReferenceType(objType).tokenToType(objType.Token)
|
|
||||||
} else {
|
|
||||||
ty = pkg.tokenToType(objType.Token)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Sprintf("%sOutputArgs", strings.TrimSuffix(ty, "Args")), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) GenIndexExpression(w io.Writer, expr *model.IndexExpression) {
|
func (g *generator) GenIndexExpression(w io.Writer, expr *model.IndexExpression) {
|
||||||
g.Fgenf(w, "%.20v[%.v]", expr.Collection, expr.Key)
|
g.Fgenf(w, "%.20v[%.v]", expr.Collection, expr.Key)
|
||||||
}
|
}
|
||||||
|
@ -350,10 +316,15 @@ func (g *generator) genObjectConsExpression(
|
||||||
w io.Writer,
|
w io.Writer,
|
||||||
expr *model.ObjectConsExpression,
|
expr *model.ObjectConsExpression,
|
||||||
destType model.Type,
|
destType model.Type,
|
||||||
isInput bool) {
|
isInput bool,
|
||||||
|
) {
|
||||||
|
if len(expr.Items) == 0 {
|
||||||
|
g.Fgenf(w, "nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var temps []interface{}
|
||||||
isInput = isInput || isInputty(destType)
|
isInput = isInput || isInputty(destType)
|
||||||
|
|
||||||
typeName := g.argumentTypeName(expr, destType, isInput)
|
typeName := g.argumentTypeName(expr, destType, isInput)
|
||||||
if schemaType, ok := pcl.GetSchemaForType(destType); ok {
|
if schemaType, ok := pcl.GetSchemaForType(destType); ok {
|
||||||
if obj, ok := codegen.UnwrapType(schemaType).(*schema.ObjectType); ok {
|
if obj, ok := codegen.UnwrapType(schemaType).(*schema.ObjectType); ok {
|
||||||
|
@ -363,21 +334,6 @@ func (g *generator) genObjectConsExpression(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.genObjectConsExpressionWithTypeName(w, expr, destType, typeName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *generator) genObjectConsExpressionWithTypeName(
|
|
||||||
w io.Writer,
|
|
||||||
expr *model.ObjectConsExpression,
|
|
||||||
destType model.Type,
|
|
||||||
typeName string) {
|
|
||||||
|
|
||||||
if len(expr.Items) == 0 {
|
|
||||||
g.Fgenf(w, "nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var temps []interface{}
|
|
||||||
// TODO: @pgavlin --- ineffectual assignment, was there some work in flight here?
|
// TODO: @pgavlin --- ineffectual assignment, was there some work in flight here?
|
||||||
// if strings.HasSuffix(typeName, "Args") {
|
// if strings.HasSuffix(typeName, "Args") {
|
||||||
// isInput = true
|
// isInput = true
|
||||||
|
@ -404,7 +360,7 @@ func (g *generator) genObjectConsExpressionWithTypeName(
|
||||||
}
|
}
|
||||||
g.genTemps(w, temps)
|
g.genTemps(w, temps)
|
||||||
|
|
||||||
if isMap || !strings.HasSuffix(typeName, "Args") || strings.HasSuffix(typeName, "OutputArgs") {
|
if isMap || !strings.HasSuffix(typeName, "Args") {
|
||||||
g.Fgenf(w, "%s", typeName)
|
g.Fgenf(w, "%s", typeName)
|
||||||
} else {
|
} else {
|
||||||
g.Fgenf(w, "&%s", typeName)
|
g.Fgenf(w, "&%s", typeName)
|
||||||
|
@ -858,15 +814,9 @@ func (g *generator) genApply(w io.Writer, expr *model.FunctionCallExpression) {
|
||||||
isInput := false
|
isInput := false
|
||||||
retType := g.argumentTypeName(nil, then.Signature.ReturnType, isInput)
|
retType := g.argumentTypeName(nil, then.Signature.ReturnType, isInput)
|
||||||
// TODO account for outputs in other namespaces like aws
|
// TODO account for outputs in other namespaces like aws
|
||||||
// TODO[pulumi/pulumi#8453] incomplete pattern code below.
|
typeAssertion := fmt.Sprintf(".(%sOutput)", retType)
|
||||||
var typeAssertion string
|
if !strings.HasPrefix(retType, "pulumi.") {
|
||||||
if retType == "[]string" {
|
typeAssertion = fmt.Sprintf(".(pulumi.%sOutput)", Title(retType))
|
||||||
typeAssertion = ".(pulumi.StringArrayOutput)"
|
|
||||||
} else {
|
|
||||||
typeAssertion = fmt.Sprintf(".(%sOutput)", retType)
|
|
||||||
if !strings.HasPrefix(retType, "pulumi.") {
|
|
||||||
typeAssertion = fmt.Sprintf(".(pulumi.%sOutput)", Title(retType))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(applyArgs) == 1 {
|
if len(applyArgs) == 1 {
|
||||||
|
|
|
@ -44,9 +44,7 @@ func (os *optionalSpiller) spillExpressionHelper(
|
||||||
case *model.FunctionCallExpression:
|
case *model.FunctionCallExpression:
|
||||||
if x.Name == "invoke" {
|
if x.Name == "invoke" {
|
||||||
// recurse into invoke args
|
// recurse into invoke args
|
||||||
isOutputInvoke, _, _ := pcl.RecognizeOutputVersionedInvoke(x)
|
isInvoke = true
|
||||||
// ignore output-versioned invokes as they do not need converting
|
|
||||||
isInvoke = !isOutputInvoke
|
|
||||||
_, diags := os.spillExpressionHelper(x.Args[1], x.Args[1].Type(), isInvoke)
|
_, diags := os.spillExpressionHelper(x.Args[1], x.Args[1].Type(), isInvoke)
|
||||||
return x, diags
|
return x, diags
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,6 @@ type GoPackageInfo struct {
|
||||||
// Feature flag to disable generating input type registration. This is a
|
// Feature flag to disable generating input type registration. This is a
|
||||||
// space saving measure.
|
// space saving measure.
|
||||||
DisableInputTypeRegistrations bool `json:"disableInputTypeRegistrations,omitempty"`
|
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.
|
// Importer implements schema.Language for Go.
|
||||||
|
|
|
@ -49,9 +49,8 @@ var programTests = []programTest{
|
||||||
{
|
{
|
||||||
Name: "aws-fargate",
|
Name: "aws-fargate",
|
||||||
Description: "AWS Fargate",
|
Description: "AWS Fargate",
|
||||||
|
|
||||||
// TODO[pulumi/pulumi#8440]
|
|
||||||
SkipCompile: codegen.NewStringSet("go"),
|
SkipCompile: codegen.NewStringSet("go"),
|
||||||
|
Skip: codegen.NewStringSet("go", "python", "dotnet"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "aws-s3-logging",
|
Name: "aws-s3-logging",
|
||||||
|
@ -128,6 +127,7 @@ var programTests = []programTest{
|
||||||
{
|
{
|
||||||
Name: "output-funcs-aws",
|
Name: "output-funcs-aws",
|
||||||
Description: "Output Versioned Functions",
|
Description: "Output Versioned Functions",
|
||||||
|
Skip: codegen.NewStringSet("go", "python", "dotnet"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,22 +192,11 @@ var sdkTests = []sdkTest{
|
||||||
SkipCompileCheck: codegen.NewStringSet(nodejs),
|
SkipCompileCheck: codegen.NewStringSet(nodejs),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Directory: "plain-object-defaults",
|
Directory: "env-helper",
|
||||||
Description: "Ensure that object defaults are generated (repro #8132)",
|
Description: "Ensure that eviromental helpers are generated (repro #8132)",
|
||||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||||
SkipCompileCheck: codegen.NewStringSet(dotnet),
|
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
|
var genSDKOnly bool
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws"
|
||||||
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
|
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
|
||||||
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ecs"
|
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ecs"
|
||||||
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/elasticloadbalancingv2"
|
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/elasticloadbalancingv2"
|
||||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Provider) ElementType() reflect.Type {
|
func (*Provider) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
||||||
type ProviderOutput struct{ *pulumi.OutputState }
|
type ProviderOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ProviderOutput) ElementType() reflect.Type {
|
func (ProviderOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
||||||
}
|
}
|
||||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
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 {
|
func (*Provider) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
||||||
type ProviderOutput struct{ *pulumi.OutputState }
|
type ProviderOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ProviderOutput) ElementType() reflect.Type {
|
func (ProviderOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
||||||
}
|
}
|
||||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
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 {
|
func (*ModuleResource) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
return reflect.TypeOf((*ModuleResource)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
||||||
|
@ -90,7 +90,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
|
||||||
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ModuleResourceOutput) ElementType() reflect.Type {
|
func (ModuleResourceOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
return reflect.TypeOf((*ModuleResource)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
"plant-provider/tree/v1/init.go",
|
"plant-provider/tree/v1/init.go",
|
||||||
"plant-provider/tree/v1/nursery.go",
|
"plant-provider/tree/v1/nursery.go",
|
||||||
"plant-provider/tree/v1/pulumiEnums.go",
|
"plant-provider/tree/v1/pulumiEnums.go",
|
||||||
"plant-provider/tree/v1/pulumiUtilities.go",
|
|
||||||
"plant-provider/tree/v1/rubberTree.go"
|
"plant-provider/tree/v1/rubberTree.go"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Provider) ElementType() reflect.Type {
|
func (*Provider) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
||||||
type ProviderOutput struct{ *pulumi.OutputState }
|
type ProviderOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ProviderOutput) ElementType() reflect.Type {
|
func (ProviderOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||||
|
|
|
@ -17,19 +17,6 @@ type Container struct {
|
||||||
Size ContainerSize `pulumi:"size"`
|
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.
|
// ContainerInput is an input type that accepts ContainerArgs and ContainerOutput values.
|
||||||
// You can construct a concrete instance of `ContainerInput` via:
|
// You can construct a concrete instance of `ContainerInput` via:
|
||||||
//
|
//
|
||||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
||||||
}
|
}
|
||||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
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 {
|
func (*Nursery) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
return reflect.TypeOf((*Nursery)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Nursery) ToNurseryOutput() NurseryOutput {
|
func (i *Nursery) ToNurseryOutput() NurseryOutput {
|
||||||
|
@ -97,7 +97,7 @@ func (i *Nursery) ToNurseryOutputWithContext(ctx context.Context) NurseryOutput
|
||||||
type NurseryOutput struct{ *pulumi.OutputState }
|
type NurseryOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (NurseryOutput) ElementType() reflect.Type {
|
func (NurseryOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
return reflect.TypeOf((*Nursery)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {
|
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {
|
||||||
|
|
|
@ -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()
|
|
||||||
}
|
|
|
@ -29,20 +29,16 @@ func NewRubberTree(ctx *pulumi.Context,
|
||||||
return nil, errors.New("missing one or more required arguments")
|
return nil, errors.New("missing one or more required arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
containerApplier := func(v plantprovider.Container) *plantprovider.Container { return v.Defaults() }
|
if args.Diameter == nil {
|
||||||
if args.Container != nil {
|
|
||||||
args.Container = args.Container.ToContainerPtrOutput().Elem().ApplyT(containerApplier).(plantprovider.ContainerPtrOutput)
|
|
||||||
}
|
|
||||||
if isZero(args.Diameter) {
|
|
||||||
args.Diameter = Diameter(6.0)
|
args.Diameter = Diameter(6.0)
|
||||||
}
|
}
|
||||||
if isZero(args.Farm) {
|
if args.Farm == nil {
|
||||||
args.Farm = pulumi.StringPtr("(unknown)")
|
args.Farm = pulumi.StringPtr("(unknown)")
|
||||||
}
|
}
|
||||||
if isZero(args.Size) {
|
if args.Size == nil {
|
||||||
args.Size = TreeSize("medium")
|
args.Size = TreeSize("medium")
|
||||||
}
|
}
|
||||||
if isZero(args.Type) {
|
if args.Type == nil {
|
||||||
args.Type = RubberTreeVariety("Burgundy")
|
args.Type = RubberTreeVariety("Burgundy")
|
||||||
}
|
}
|
||||||
var resource RubberTree
|
var resource RubberTree
|
||||||
|
@ -107,7 +103,7 @@ type RubberTreeInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*RubberTree) ElementType() reflect.Type {
|
func (*RubberTree) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
return reflect.TypeOf((*RubberTree)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
|
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
|
||||||
|
@ -121,7 +117,7 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
|
||||||
type RubberTreeOutput struct{ *pulumi.OutputState }
|
type RubberTreeOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (RubberTreeOutput) ElementType() reflect.Type {
|
func (RubberTreeOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
return reflect.TypeOf((*RubberTree)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {
|
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {
|
||||||
|
|
|
@ -300,6 +300,56 @@ All [input](#inputs) properties are implicitly available as output properties. A
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4 id="typ">Typ</h4>
|
||||||
|
|
||||||
|
{{% choosable language csharp %}}
|
||||||
|
<dl class="resources-properties"><dt class="property-optional"
|
||||||
|
title="Optional">
|
||||||
|
<span id="val_csharp">
|
||||||
|
<a href="#val_csharp" style="color: inherit; text-decoration: inherit;">Val</a>
|
||||||
|
</span>
|
||||||
|
<span class="property-indicator"></span>
|
||||||
|
<span class="property-type">string</span>
|
||||||
|
</dt>
|
||||||
|
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||||
|
{{% /choosable %}}
|
||||||
|
|
||||||
|
{{% choosable language go %}}
|
||||||
|
<dl class="resources-properties"><dt class="property-optional"
|
||||||
|
title="Optional">
|
||||||
|
<span id="val_go">
|
||||||
|
<a href="#val_go" style="color: inherit; text-decoration: inherit;">Val</a>
|
||||||
|
</span>
|
||||||
|
<span class="property-indicator"></span>
|
||||||
|
<span class="property-type">string</span>
|
||||||
|
</dt>
|
||||||
|
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||||
|
{{% /choosable %}}
|
||||||
|
|
||||||
|
{{% choosable language nodejs %}}
|
||||||
|
<dl class="resources-properties"><dt class="property-optional"
|
||||||
|
title="Optional">
|
||||||
|
<span id="val_nodejs">
|
||||||
|
<a href="#val_nodejs" style="color: inherit; text-decoration: inherit;">val</a>
|
||||||
|
</span>
|
||||||
|
<span class="property-indicator"></span>
|
||||||
|
<span class="property-type">string</span>
|
||||||
|
</dt>
|
||||||
|
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||||
|
{{% /choosable %}}
|
||||||
|
|
||||||
|
{{% choosable language python %}}
|
||||||
|
<dl class="resources-properties"><dt class="property-optional"
|
||||||
|
title="Optional">
|
||||||
|
<span id="val_python">
|
||||||
|
<a href="#val_python" style="color: inherit; text-decoration: inherit;">val</a>
|
||||||
|
</span>
|
||||||
|
<span class="property-indicator"></span>
|
||||||
|
<span class="property-type">str</span>
|
||||||
|
</dt>
|
||||||
|
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||||
|
{{% /choosable %}}
|
||||||
|
|
||||||
<h4 id="typ">Typ</h4>
|
<h4 id="typ">Typ</h4>
|
||||||
|
|
||||||
{{% choosable language csharp %}}
|
{{% choosable language csharp %}}
|
||||||
|
@ -416,56 +466,6 @@ All [input](#inputs) properties are implicitly available as output properties. A
|
||||||
|
|
||||||
<h4 id="typ">Typ</h4>
|
<h4 id="typ">Typ</h4>
|
||||||
|
|
||||||
{{% choosable language csharp %}}
|
|
||||||
<dl class="resources-properties"><dt class="property-optional"
|
|
||||||
title="Optional">
|
|
||||||
<span id="val_csharp">
|
|
||||||
<a href="#val_csharp" style="color: inherit; text-decoration: inherit;">Val</a>
|
|
||||||
</span>
|
|
||||||
<span class="property-indicator"></span>
|
|
||||||
<span class="property-type">string</span>
|
|
||||||
</dt>
|
|
||||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
|
||||||
{{% /choosable %}}
|
|
||||||
|
|
||||||
{{% choosable language go %}}
|
|
||||||
<dl class="resources-properties"><dt class="property-optional"
|
|
||||||
title="Optional">
|
|
||||||
<span id="val_go">
|
|
||||||
<a href="#val_go" style="color: inherit; text-decoration: inherit;">Val</a>
|
|
||||||
</span>
|
|
||||||
<span class="property-indicator"></span>
|
|
||||||
<span class="property-type">string</span>
|
|
||||||
</dt>
|
|
||||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
|
||||||
{{% /choosable %}}
|
|
||||||
|
|
||||||
{{% choosable language nodejs %}}
|
|
||||||
<dl class="resources-properties"><dt class="property-optional"
|
|
||||||
title="Optional">
|
|
||||||
<span id="val_nodejs">
|
|
||||||
<a href="#val_nodejs" style="color: inherit; text-decoration: inherit;">val</a>
|
|
||||||
</span>
|
|
||||||
<span class="property-indicator"></span>
|
|
||||||
<span class="property-type">string</span>
|
|
||||||
</dt>
|
|
||||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
|
||||||
{{% /choosable %}}
|
|
||||||
|
|
||||||
{{% choosable language python %}}
|
|
||||||
<dl class="resources-properties"><dt class="property-optional"
|
|
||||||
title="Optional">
|
|
||||||
<span id="val_python">
|
|
||||||
<a href="#val_python" style="color: inherit; text-decoration: inherit;">val</a>
|
|
||||||
</span>
|
|
||||||
<span class="property-indicator"></span>
|
|
||||||
<span class="property-type">str</span>
|
|
||||||
</dt>
|
|
||||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
|
||||||
{{% /choosable %}}
|
|
||||||
|
|
||||||
<h4 id="typ">Typ</h4>
|
|
||||||
|
|
||||||
{{% choosable language csharp %}}
|
{{% choosable language csharp %}}
|
||||||
<dl class="resources-properties"><dt class="property-optional"
|
<dl class="resources-properties"><dt class="property-optional"
|
||||||
title="Optional">
|
title="Optional">
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
@ -93,7 +93,7 @@ type FooInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Foo) ElementType() reflect.Type {
|
func (*Foo) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
return reflect.TypeOf((*Foo)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Foo) ToFooOutput() FooOutput {
|
func (i *Foo) ToFooOutput() FooOutput {
|
||||||
|
@ -107,7 +107,7 @@ func (i *Foo) ToFooOutputWithContext(ctx context.Context) FooOutput {
|
||||||
type FooOutput struct{ *pulumi.OutputState }
|
type FooOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (FooOutput) ElementType() reflect.Type {
|
func (FooOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
return reflect.TypeOf((*Foo)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o FooOutput) ToFooOutput() FooOutput {
|
func (o FooOutput) ToFooOutput() FooOutput {
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"env-helper/example/mod1"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||||
"plain-object-disable-defaults/example/mod1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A test for namespaces (mod 2)
|
// A test for namespaces (mod 2)
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"env-helper/example/mod1"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||||
"plain-object-disable-defaults/example/mod1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModuleTest struct {
|
type ModuleTest struct {
|
||||||
|
@ -76,7 +76,7 @@ type ModuleTestInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*ModuleTest) ElementType() reflect.Type {
|
func (*ModuleTest) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
return reflect.TypeOf((*ModuleTest)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
|
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
|
||||||
|
@ -90,7 +90,7 @@ func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTe
|
||||||
type ModuleTestOutput struct{ *pulumi.OutputState }
|
type ModuleTestOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ModuleTestOutput) ElementType() reflect.Type {
|
func (ModuleTestOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
return reflect.TypeOf((*ModuleTest)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {
|
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {
|
|
@ -53,7 +53,7 @@ type ProviderInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Provider) ElementType() reflect.Type {
|
func (*Provider) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||||
|
@ -67,7 +67,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
||||||
type ProviderOutput struct{ *pulumi.OutputState }
|
type ProviderOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (ProviderOutput) ElementType() reflect.Type {
|
func (ProviderOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
return reflect.TypeOf((*Provider)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"env-helper/example/mod1"
|
||||||
|
"env-helper/example/mod2"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
"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.
|
// BETA FEATURE - Options to configure the Helm Release resource.
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
||||||
}
|
}
|
||||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
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()
|
|
||||||
}
|
|
|
@ -219,8 +219,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"go": {
|
"go": {
|
||||||
"importBasePath": "plain-object-disable-defaults/example",
|
"importBasePath": "env-helper/example"
|
||||||
"disableObjectDefaults": true
|
|
||||||
},
|
},
|
||||||
"nodejs": {
|
"nodejs": {
|
||||||
"dependencies": {
|
"dependencies": {
|
|
@ -77,7 +77,7 @@ type CatInput interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Cat) ElementType() reflect.Type {
|
func (*Cat) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
return reflect.TypeOf((*Cat)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Cat) ToCatOutput() CatOutput {
|
func (i *Cat) ToCatOutput() CatOutput {
|
||||||
|
@ -88,6 +88,35 @@ func (i *Cat) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
||||||
return pulumi.ToOutputWithContext(ctx, i).(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.
|
// CatArrayInput is an input type that accepts CatArray and CatArrayOutput values.
|
||||||
// You can construct a concrete instance of `CatArrayInput` via:
|
// 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 }
|
type CatOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (CatOutput) ElementType() reflect.Type {
|
func (CatOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
return reflect.TypeOf((*Cat)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o CatOutput) ToCatOutput() CatOutput {
|
func (o CatOutput) ToCatOutput() CatOutput {
|
||||||
|
@ -152,10 +181,44 @@ func (o CatOutput) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
||||||
return o
|
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 }
|
type CatArrayOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (CatArrayOutput) ElementType() reflect.Type {
|
func (CatArrayOutput) ElementType() reflect.Type {
|
||||||
return reflect.TypeOf((*[]*Cat)(nil)).Elem()
|
return reflect.TypeOf((*[]Cat)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o CatArrayOutput) ToCatArrayOutput() CatArrayOutput {
|
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 {
|
func (o CatArrayOutput) Index(i pulumi.IntInput) CatOutput {
|
||||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Cat {
|
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Cat {
|
||||||
return vs[0].([]*Cat)[vs[1].(int)]
|
return vs[0].([]Cat)[vs[1].(int)]
|
||||||
}).(CatOutput)
|
}).(CatOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
type CatMapOutput struct{ *pulumi.OutputState }
|
type CatMapOutput struct{ *pulumi.OutputState }
|
||||||
|
|
||||||
func (CatMapOutput) ElementType() reflect.Type {
|
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 {
|
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 {
|
func (o CatMapOutput) MapIndex(k pulumi.StringInput) CatOutput {
|
||||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Cat {
|
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Cat {
|
||||||
return vs[0].(map[string]*Cat)[vs[1].(string)]
|
return vs[0].(map[string]Cat)[vs[1].(string)]
|
||||||
}).(CatOutput)
|
}).(CatOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pulumi.RegisterInputType(reflect.TypeOf((*CatInput)(nil)).Elem(), &Cat{})
|
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((*CatArrayInput)(nil)).Elem(), CatArray{})
|
||||||
pulumi.RegisterInputType(reflect.TypeOf((*CatMapInput)(nil)).Elem(), CatMap{})
|
pulumi.RegisterInputType(reflect.TypeOf((*CatMapInput)(nil)).Elem(), CatMap{})
|
||||||
pulumi.RegisterOutputType(CatOutput{})
|
pulumi.RegisterOutputType(CatOutput{})
|
||||||
|
pulumi.RegisterOutputType(CatPtrOutput{})
|
||||||
pulumi.RegisterOutputType(CatArrayOutput{})
|
pulumi.RegisterOutputType(CatArrayOutput{})
|
||||||
pulumi.RegisterOutputType(CatMapOutput{})
|
pulumi.RegisterOutputType(CatMapOutput{})
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue