Compare commits

..

2 commits

Author SHA1 Message Date
Pat Gavlin cf6076d6b0 fix, baselines, CL 2021-11-17 11:21:33 -08:00
Luke Hoban ae70447a18 Allow optional inputs to be Input<T | undefined>
The Node.js runtime accepts `Output<undefined>` values as inputs to
optional parameters, but the TypeScript typing currently does not
allow these. This extends the TypeScript typings to allow
`Output<undefined>` values as inputs to optional input properties.

I cannot think of any way in which this is breaking or would regress
any aspect of the TypeScript experience, other than making the `.d.ts`
files a little "noisier".

Fixes #6175.
2021-11-17 08:55:04 -08:00
454 changed files with 2910 additions and 25007 deletions

View file

@ -28,8 +28,8 @@ RUN groupadd --gid $USER_GID $USER_NAME \
RUN mkdir -p /go/bin \ RUN mkdir -p /go/bin \
&& chown -R $USER_NAME: /go \ && chown -R $USER_NAME: /go \
&& mkdir -p $HOME/.pulumi/bin \ && mkdir -p /opt/pulumi/bin \
&& chown -R $USER_NAME: $HOME/.pulumi && chown -R $USER_NAME: /opt/pulumi
USER $USER_NAME USER $USER_NAME
@ -38,7 +38,7 @@ USER $USER_NAME
ENV XDG_CONFIG_HOME=/home/$USER_NAME/.config ENV XDG_CONFIG_HOME=/home/$USER_NAME/.config
ENV XDG_CACHE_HOME=/home/$USER_NAME/.cache ENV XDG_CACHE_HOME=/home/$USER_NAME/.cache
RUN echo "export PATH=$HOME/.pulumi:$HOME/.pulumi/bin:$GOPATH/bin:/usr/local/go/bin:$PATH" >> ~/.bashrc \ RUN echo "export PATH=/opt/pulumi:/opt/pulumi/bin:$GOPATH/bin:/usr/local/go/bin:$PATH" >> ~/.bashrc \
&& echo "alias l='ls -aF'" >> ~/.bash_aliases \ && echo "alias l='ls -aF'" >> ~/.bash_aliases \
&& echo "alias ll='ls -ahlF'" >> ~/.bash_aliases \ && echo "alias ll='ls -ahlF'" >> ~/.bash_aliases \
&& echo "alias ls='ls --color=auto --group-directories-first'" >> ~/.bash_aliases && echo "alias ls='ls --color=auto --group-directories-first'" >> ~/.bash_aliases

View file

@ -101,13 +101,6 @@ jobs:
./scripts/gen_resource_docs.sh aws true ./scripts/gen_resource_docs.sh aws true
./scripts/gen_resource_docs.sh kubernetes true ./scripts/gen_resource_docs.sh kubernetes true
# Undo the changes to the go.mod and go.sum files since we don't want the PR
# to contain local overrides or the PR build in docs repo would fail.
pushd tools/resourcedocsgen
git checkout .
popd
popd popd
echo "::set-output name=branchName::${BRANCH_NAME}" echo "::set-output name=branchName::${BRANCH_NAME}"

View file

@ -5,7 +5,7 @@ image:
tasks: tasks:
- before: > - before: >
mkdir -p /workspace/opt-pulumi && mkdir -p /workspace/opt-pulumi &&
sudo ln -s /workspace/opt-pulumi $HOME/.pulumi sudo ln -s /workspace/opt-pulumi /opt/pulumi
init: > init: >
make ensure && make ensure &&
make install make install

View file

@ -1,7 +1,7 @@
FROM gitpod/workspace-full FROM gitpod/workspace-full
USER gitpod USER gitpod
ENV PATH="$HOME/.pulumi:$HOME/.pulumi/bin:$PATH" ENV PATH="/opt/pulumi:/opt/pulumi/bin:$PATH"
# Install .NET Core 3.1 SDK binaries on Ubuntu 20.04 # Install .NET Core 3.1 SDK binaries on Ubuntu 20.04
# Source: https://dev.to/carlos487/installing-dotnet-core-in-ubuntu-20-04-6jh # Source: https://dev.to/carlos487/installing-dotnet-core-in-ubuntu-20-04-6jh

View file

@ -1,90 +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)
### Improvements
- [ci] - Adds CI detector for Buildkite
[#7933](https://github.com/pulumi/pulumi/pull/7933)
- [cli] - Add `--exclude-protected` flag to `pulumi destroy`.
[#8359](https://github.com/pulumi/pulumi/pull/8359)
- [cli] Add the ability to use `pulumi org set [name]` to set a default org
to use when creating a stacks in the Pulumi Service backend or self-hosted Service.
[#8352](https://github.com/pulumi/pulumi/pull/8352)
- [schema] Add IsOverlay option to disable codegen for particular types.
[#8338](https://github.com/pulumi/pulumi/pull/8338)
[#8425](https://github.com/pulumi/pulumi/pull/8425)
- [sdk/dotnet] - Marshal output values.
[#8316](https://github.com/pulumi/pulumi/pull/8316)
- [sdk/python] - Unmarshal output values in component provider.
[#8212](https://github.com/pulumi/pulumi/pull/8212)
- [sdk/nodejs] - Unmarshal output values in component provider.
[#8205](https://github.com/pulumi/pulumi/pull/8205)
- [sdk/nodejs] - Allow returning failures from Call in the provider without setting result outputs.
[#8424](https://github.com/pulumi/pulumi/pull/8424)
- [sdk/go] - Allow specifying Call failures from the provider.
[#8424](https://github.com/pulumi/pulumi/pull/8424)
- [codegen/nodejs] - Program generator now uses `fnOutput` forms where
appropriate, simplifying auto-generated examples.
[#8434](https://github.com/pulumi/pulumi/pull/8434)
### Bug Fixes
- [engine] - Compute dependents correctly during targeted deletes.
[#8360](https://github.com/pulumi/pulumi/pull/8360)
- [cli/engine] - Update command respects `--target-dependents`.
[#8395](https://github.com/pulumi/pulumi/pull/8395)
- [docs] - Fix broken lists in dotnet docs.
[docs#6558](https://github.com/pulumi/docs/issues/6558)
## 3.17.1 (2021-11-09) ## 3.17.1 (2021-11-09)
### Improvements ### Improvements

View file

@ -1,12 +1,42 @@
### Improvements ### Improvements
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being - [sdk/nodejs] - Type optional input properties as `Input<T | undefined> | undefined` instead of
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of `Input<T> | undefined`. This allows users to pass `Output<T | undefined>` for optional input
a value--the implementation of `Ptr` types for resources was incorrect, making properties.
these types virtually unusable in practice. [#6323](https://github.com/pulumi/pulumi/pull/6323)
[#8449](https://github.com/pulumi/pulumi/pull/8449)
- Adds CI detector for Buildkite
[#7933](https://github.com/pulumi/pulumi/pull/7933)
- [cli] - Add `--exclude-protected` flag to `pulumi destroy`.
[#8359](https://github.com/pulumi/pulumi/pull/8359)
- [cli] Adding the ability to use `pulumi org set [name]` to set a default org
to use when creating a stacks in the Pulumi Service backend or self-hosted Service
[#8352](https://github.com/pulumi/pulumi/pull/8352)
- [schema] Add IsOverlay option to disable codegen for particular types
[#8338](https://github.com/pulumi/pulumi/pull/8338)
- [sdk/dotnet] - Marshal output values.
[#8316](https://github.com/pulumi/pulumi/pull/8316)
- [sdk/python] - Unmarshal output values in component provider.
[#8212](https://github.com/pulumi/pulumi/pull/8212)
- [sdk/nodejs] - Unmarshal output values in component provider.
[#8205](https://github.com/pulumi/pulumi/pull/8205)
- [sdk/nodejs] - Allow returning failures from Call in the provider without setting result outputs.
[#8424](https://github.com/pulumi/pulumi/pull/8424)
- [sdk/go] - Allow specifying Call failures from the provider.
[#8424](https://github.com/pulumi/pulumi/pull/8424)
### Bug Fixes ### Bug Fixes
- [codegen/go] - Respect default values in Pulumi object types. - [engine] - Compute dependents correctly during targeted deletes.
[#8411](https://github.com/pulumi/pulumi/pull/8400) [#8360](https://github.com/pulumi/pulumi/pull/8360)
- [docs] - Fix broken lists in dotnet docs
[docs#6558](https://github.com/pulumi/docs/issues/6558)

View file

@ -22,7 +22,7 @@ To hack on Pulumi, you'll need to get a development environment set up. You'll w
You can easily get all required dependencies with brew and npm 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
@ -38,10 +38,12 @@ If you have a web browser, you can get a fully pre-configured Pulumi development
We use `make` as our build system, so you'll want to install that as well, if you don't have it already. We have extremely limited support for doing development on Windows (the bare minimum for us to get Windows validation of `pulumi`) so if you're on windows, we recommend that you use the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). We'd like to [make this better](https://github.com/pulumi/pulumi/issues/208) so feel free to pitch in if you can. We use `make` as our build system, so you'll want to install that as well, if you don't have it already. We have extremely limited support for doing development on Windows (the bare minimum for us to get Windows validation of `pulumi`) so if you're on windows, we recommend that you use the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). We'd like to [make this better](https://github.com/pulumi/pulumi/issues/208) so feel free to pitch in if you can.
We build Pulumi in `$PULUMI_ROOT`, which defaults to `$HOME/.pulumi`. If you would like to build Pulumi in another location, you do so by setting `$PULUMI_ROOT`. For historical reasons (which we'd [like to address](https://github.com/pulumi/pulumi/issues/1515)) our build system requires that the folder `/opt/pulumi` exists and is writable by the current user. If you'd like, you can override this location by setting `PULUMI_ROOT` in your environment. The build is known to fail if this doesn't exist, so you'll need to create it first.
```bash ```bash
export PATH=$HOME/.pulumi/bin:$PATH mkdir /opt/pulumi
sudo chown <your_user_name>: /opt/pulumi
export PATH=/opt/pulumi:/opt/pulumi/bin:$PATH
``` ```
You'll also need to make sure your maximum open file descriptor limit is set to 5000 at a minimum. You'll also need to make sure your maximum open file descriptor limit is set to 5000 at a minimum.
@ -53,10 +55,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`.

View file

@ -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

View file

@ -96,9 +96,9 @@ SHELL := /bin/bash
STEP_MESSAGE = @echo -e "\033[0;32m$(shell echo '$@' | tr a-z A-Z | tr '_' ' '):\033[0m" STEP_MESSAGE = @echo -e "\033[0;32m$(shell echo '$@' | tr a-z A-Z | tr '_' ' '):\033[0m"
# Our install targets place items item into $PULUMI_ROOT, if it's # Our install targets place items item into $PULUMI_ROOT, if it's
# unset, default to `$HOME/.pulumi`. # unset, default to /opt/pulumi.
ifeq ($(PULUMI_ROOT),) ifeq ($(PULUMI_ROOT),)
PULUMI_ROOT:=$(shell realpath "$$HOME/.pulumi") PULUMI_ROOT:=/opt/pulumi
endif endif
# Use Python 3 explicitly vs expecting that `python` will resolve to a python 3 # Use Python 3 explicitly vs expecting that `python` will resolve to a python 3
@ -168,7 +168,6 @@ test_fast::
install:: install::
$(call STEP_MESSAGE) $(call STEP_MESSAGE)
# Implicitly creates PULUMI_ROOT.
@mkdir -p $(PULUMI_BIN) @mkdir -p $(PULUMI_BIN)
@mkdir -p $(PULUMI_NODE_MODULES) @mkdir -p $(PULUMI_NODE_MODULES)
@mkdir -p $(PULUMI_NUGET) @mkdir -p $(PULUMI_NUGET)

View file

@ -57,14 +57,6 @@ The description of the package. Descriptions are interpreted as Markdown.
--- ---
### `displayName`
The human-friendly name of the package.
`string`
---
### `functions` ### `functions`
A map from token to functionSpec that describes the set of functions defined by this package. A map from token to functionSpec that describes the set of functions defined by this package.
@ -167,14 +159,6 @@ The provider type for this package.
--- ---
### `publisher`
The name of the person or organization that authored and published the package.
`string`
---
### `repository` ### `repository`
The URL at which the package's sources can be found. The URL at which the package's sources can be found.
@ -377,14 +361,6 @@ The bag of input values for the function, if any.
--- ---
#### `isOverlay`
Indicates that the implementation of the function should not be generated from the schema, and is instead provided out-of-band by the package author
`boolean`
---
#### `language` #### `language`
Additional language-specific data about the function. Additional language-specific data about the function.
@ -685,7 +661,7 @@ Indicates whether the resource is a component.
#### `isOverlay` #### `isOverlay`
Indicates that the implementation of the resource should not be generated from the schema, and is instead provided out-of-band by the package author Indicates whether the resource is an overlay (code is generated by the package rather than by the core Pulumi codegen).
`boolean` `boolean`
@ -723,7 +699,7 @@ An optional objectTypeSpec that describes additional inputs that mau be necessar
`string` `string`
Pattern: `^[a-zA-Z][-a-zA-Z0-9_]*:([^0-9][a-zA-Z0-9._/-]*)?:[^0-9][a-zA-Z0-9._/]*$` Pattern: `^[a-zA-Z][-a-zA-Z0-9_]*:([^0-9][a-zA-Z0-9._/]*)?:[^0-9][a-zA-Z0-9._/]*$`
## Type Definition ## Type Definition
@ -745,14 +721,6 @@ The description of the type, if any. Interpreted as Markdown.
--- ---
#### `isOverlay`
Indicates that the implementation of the type should not be generated from the schema, and is instead provided out-of-band by the package author
`boolean`
---
#### `language` #### `language`
Additional language-specific data about the type. Additional language-specific data about the type.

View file

@ -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
}

View file

@ -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)
}

View file

@ -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

View file

@ -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:
@ -1963,14 +1957,8 @@ func (dctx *docGenContext) generatePackage(tool string, pkg *schema.Package) (ma
glog.V(3).Infoln("generating package docs now...") glog.V(3).Infoln("generating package docs now...")
files := fs{} files := fs{}
modules := []string{} for _, mod := range dctx.modules() {
modMap := dctx.modules() if err := mod.gen(files); err != nil {
for k := range modMap {
modules = append(modules, k)
}
sort.Strings(modules)
for _, mod := range modules {
if err := modMap[mod].gen(files); err != nil {
return nil, err return nil, err
} }
} }

View file

@ -2352,10 +2352,8 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod
mod := getModFromToken(typ.Token, pkg) mod := getModFromToken(typ.Token, pkg)
mod.types = append(mod.types, typ) mod.types = append(mod.types, typ)
case *schema.EnumType: case *schema.EnumType:
if !typ.IsOverlay { mod := getModFromToken(typ.Token, pkg)
mod := getModFromToken(typ.Token, pkg) mod.enums = append(mod.enums, typ)
mod.enums = append(mod.enums, typ)
}
default: default:
continue continue
} }

View file

@ -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))
} }

View file

@ -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)

View file

@ -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
} }
@ -2890,10 +2769,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
} }
populateDetailsForPropertyTypes(seenMap, typ.Properties, false) populateDetailsForPropertyTypes(seenMap, typ.Properties, false)
case *schema.EnumType: case *schema.EnumType:
if !typ.IsOverlay { pkg := getPkgFromToken(typ.Token)
pkg := getPkgFromToken(typ.Token) pkg.enums = append(pkg.enums, typ)
pkg.enums = append(pkg.enums, typ)
}
} }
} }
@ -3110,10 +2987,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 +3001,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 +3198,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 +3238,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 +3374,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()
}
` `

View file

@ -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)
} }

View file

@ -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)
} }

View file

@ -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 {

View file

@ -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
} }

View file

@ -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.

View file

@ -1034,13 +1034,7 @@ func (x *FunctionCallExpression) Typecheck(typecheckOperands bool) hcl.Diagnosti
typecheckDiags := typecheckArgs(rng, x.Signature, x.Args...) typecheckDiags := typecheckArgs(rng, x.Signature, x.Args...)
diagnostics = append(diagnostics, typecheckDiags...) diagnostics = append(diagnostics, typecheckDiags...)
// Unless the function is already automatically using an x.Signature.ReturnType = liftOperationType(x.Signature.ReturnType, x.Args...)
// Output-returning version, modify the signature to account
// for automatic lifting to Promise or Output.
_, isOutput := x.Signature.ReturnType.(*OutputType)
if !isOutput {
x.Signature.ReturnType = liftOperationType(x.Signature.ReturnType, x.Args...)
}
return diagnostics return diagnostics
} }

View file

@ -363,7 +363,7 @@ func RunCommandWithOptions(
type SchemaVersion = string type SchemaVersion = string
const ( const (
AwsSchema SchemaVersion = "4.26.0" AwsSchema SchemaVersion = "4.21.1"
AzureNativeSchema SchemaVersion = "1.29.0" AzureNativeSchema SchemaVersion = "1.29.0"
AzureSchema SchemaVersion = "4.18.0" AzureSchema SchemaVersion = "4.18.0"
KubernetesSchema SchemaVersion = "3.7.2" KubernetesSchema SchemaVersion = "3.7.2"

View file

@ -49,8 +49,6 @@ 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"),
}, },
{ {
@ -125,10 +123,6 @@ var programTests = []programTest{
// TODO[pulumi/pulumi#8078] // TODO[pulumi/pulumi#8078]
// TODO[pulumi/pulumi#8079] // TODO[pulumi/pulumi#8079]
}, },
{
Name: "output-funcs-aws",
Description: "Output Versioned Functions",
},
} }
// Checks that a generated program is correct // Checks that a generated program is correct

View file

@ -191,23 +191,6 @@ var sdkTests = []sdkTest{
Skip: codegen.NewStringSet("python/test", "nodejs/test"), Skip: codegen.NewStringSet("python/test", "nodejs/test"),
SkipCompileCheck: codegen.NewStringSet(nodejs), SkipCompileCheck: codegen.NewStringSet(nodejs),
}, },
{
Directory: "plain-object-defaults",
Description: "Ensure that object defaults are generated (repro #8132)",
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
SkipCompileCheck: codegen.NewStringSet(dotnet),
},
{
Directory: "plain-object-disable-defaults",
Description: "Ensure that we can still compile safely when defaults are disabled",
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
SkipCompileCheck: codegen.NewStringSet(dotnet),
},
{
Directory: "regress-8403",
Description: "Regress pulumi/pulumi#8403",
SkipCompileCheck: codegen.NewStringSet(dotnet, python, nodejs),
},
} }
var genSDKOnly bool var genSDKOnly bool

View file

@ -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"

File diff suppressed because one or more lines are too long

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -76,7 +76,7 @@ type ModuleResourceInput interface {
} }
func (*ModuleResource) ElementType() reflect.Type { 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 {

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -42,17 +42,17 @@ export class ModuleResource extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["thing"] = args ? args.thing : undefined; inputs["thing"] = args ? args.thing : undefined;
} else { } else {
resourceInputs["thing"] = undefined /*out*/; inputs["thing"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(ModuleResource.__pulumiType, name, resourceInputs, opts); super(ModuleResource.__pulumiType, name, inputs, opts);
} }
} }
@ -60,5 +60,5 @@ export class ModuleResource extends pulumi.CustomResource {
* The set of arguments for constructing a ModuleResource resource. * The set of arguments for constructing a ModuleResource resource.
*/ */
export interface ModuleResourceArgs { export interface ModuleResourceArgs {
thing?: pulumi.Input<inputs.TopLevelArgs>; thing?: pulumi.Input<inputs.TopLevelArgs | undefined>;
} }

View file

@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types"; import { input as inputs, output as outputs } from "../types";
export interface TopLevelArgs { export interface TopLevelArgs {
buzz?: pulumi.Input<string>; buzz?: pulumi.Input<string | undefined>;
} }

View file

@ -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"
] ]
} }

View file

@ -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 {

View file

@ -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:
// //

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -83,7 +83,7 @@ type NurseryInput interface {
} }
func (*Nursery) ElementType() reflect.Type { 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 {

View file

@ -1,85 +0,0 @@
// *** WARNING: this file was generated by test. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package v1
import (
"fmt"
"os"
"reflect"
"regexp"
"strconv"
"strings"
"github.com/blang/semver"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
type envParser func(v string) interface{}
func parseEnvBool(v string) interface{} {
b, err := strconv.ParseBool(v)
if err != nil {
return nil
}
return b
}
func parseEnvInt(v string) interface{} {
i, err := strconv.ParseInt(v, 0, 0)
if err != nil {
return nil
}
return int(i)
}
func parseEnvFloat(v string) interface{} {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return nil
}
return f
}
func parseEnvStringArray(v string) interface{} {
var result pulumi.StringArray
for _, item := range strings.Split(v, ";") {
result = append(result, pulumi.String(item))
}
return result
}
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
for _, v := range vars {
if value := os.Getenv(v); value != "" {
if parser != nil {
return parser(value)
}
return value
}
}
return def
}
// PkgVersion uses reflection to determine the version of the current package.
func PkgVersion() (semver.Version, error) {
type sentinal struct{}
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
re := regexp.MustCompile("^.*/pulumi-plant/sdk(/v\\d+)?")
if match := re.FindStringSubmatch(pkgPath); match != nil {
vStr := match[1]
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
return semver.Version{Major: 1}, nil
}
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -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 {

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -41,20 +41,20 @@ export class Nursery extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args: NurseryArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args: NurseryArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
if ((!args || args.varieties === undefined) && !opts.urn) { if ((!args || args.varieties === undefined) && !opts.urn) {
throw new Error("Missing required property 'varieties'"); throw new Error("Missing required property 'varieties'");
} }
resourceInputs["sizes"] = args ? args.sizes : undefined; inputs["sizes"] = args ? args.sizes : undefined;
resourceInputs["varieties"] = args ? args.varieties : undefined; inputs["varieties"] = args ? args.varieties : undefined;
} else { } else {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Nursery.__pulumiType, name, resourceInputs, opts); super(Nursery.__pulumiType, name, inputs, opts);
} }
} }
@ -65,7 +65,7 @@ export interface NurseryArgs {
/** /**
* The sizes of trees available * The sizes of trees available
*/ */
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>}>; sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>} | undefined>;
/** /**
* The varieties available * The varieties available
*/ */

View file

@ -48,11 +48,11 @@ export class RubberTree extends pulumi.CustomResource {
*/ */
constructor(name: string, args: RubberTreeArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, args: RubberTreeArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: RubberTreeArgs | RubberTreeState, opts?: pulumi.CustomResourceOptions) { constructor(name: string, argsOrState?: RubberTreeArgs | RubberTreeState, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (opts.id) { if (opts.id) {
const state = argsOrState as RubberTreeState | undefined; const state = argsOrState as RubberTreeState | undefined;
resourceInputs["farm"] = state ? state.farm : undefined; inputs["farm"] = state ? state.farm : undefined;
} else { } else {
const args = argsOrState as RubberTreeArgs | undefined; const args = argsOrState as RubberTreeArgs | undefined;
if ((!args || args.diameter === undefined) && !opts.urn) { if ((!args || args.diameter === undefined) && !opts.urn) {
@ -61,30 +61,30 @@ export class RubberTree extends pulumi.CustomResource {
if ((!args || args.type === undefined) && !opts.urn) { if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'"); throw new Error("Missing required property 'type'");
} }
resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined; inputs["container"] = args ? args.container : undefined;
resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6; inputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)"; inputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
resourceInputs["size"] = (args ? args.size : undefined) ?? "medium"; inputs["size"] = (args ? args.size : undefined) ?? "medium";
resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy"; inputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(RubberTree.__pulumiType, name, resourceInputs, opts); super(RubberTree.__pulumiType, name, inputs, opts);
} }
} }
export interface RubberTreeState { export interface RubberTreeState {
farm?: pulumi.Input<enums.tree.v1.Farm | string>; farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
} }
/** /**
* The set of arguments for constructing a RubberTree resource. * The set of arguments for constructing a RubberTree resource.
*/ */
export interface RubberTreeArgs { export interface RubberTreeArgs {
container?: pulumi.Input<inputs.ContainerArgs>; container?: pulumi.Input<inputs.ContainerArgs | undefined>;
diameter: pulumi.Input<enums.tree.v1.Diameter>; diameter: pulumi.Input<enums.tree.v1.Diameter>;
farm?: pulumi.Input<enums.tree.v1.Farm | string>; farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
size?: pulumi.Input<enums.tree.v1.TreeSize>; size?: pulumi.Input<enums.tree.v1.TreeSize | undefined>;
type: pulumi.Input<enums.tree.v1.RubberTreeVariety>; type: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
} }

View file

@ -4,20 +4,9 @@
import * as pulumi from "@pulumi/pulumi"; import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types"; import { input as inputs, output as outputs, enums } from "../types";
import * as utilities from "../utilities";
export interface ContainerArgs { export interface ContainerArgs {
brightness?: pulumi.Input<enums.ContainerBrightness>; brightness?: pulumi.Input<enums.ContainerBrightness | undefined>;
color?: pulumi.Input<enums.ContainerColor | string>; color?: pulumi.Input<enums.ContainerColor | string | undefined>;
material?: pulumi.Input<string>; material?: pulumi.Input<string | undefined>;
size: pulumi.Input<enums.ContainerSize>; size: pulumi.Input<enums.ContainerSize>;
} }
/**
* containerArgsProvideDefaults sets the appropriate defaults for ContainerArgs
*/
export function containerArgsProvideDefaults(val: ContainerArgs): ContainerArgs {
return {
...val,
brightness: (val.brightness) ?? 1,
};
}

View file

@ -4,21 +4,10 @@
import * as pulumi from "@pulumi/pulumi"; import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types"; import { input as inputs, output as outputs, enums } from "../types";
import * as utilities from "../utilities";
export interface Container { export interface Container {
brightness?: enums.ContainerBrightness; brightness?: enums.ContainerBrightness;
color?: enums.ContainerColor | string; color?: enums.ContainerColor | string;
material?: string; material?: string;
size: enums.ContainerSize; size: enums.ContainerSize;
} }
/**
* containerProvideDefaults sets the appropriate defaults for Container
*/
export function containerProvideDefaults(val: Container): Container {
return {
...val,
brightness: (val.brightness) ?? 1,
};
}

View file

@ -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{})
} }

View file

@ -101,7 +101,7 @@ type ComponentInput interface {
} }
func (*Component) ElementType() reflect.Type { func (*Component) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil)).Elem() return reflect.TypeOf((*Component)(nil))
} }
func (i *Component) ToComponentOutput() ComponentOutput { func (i *Component) ToComponentOutput() ComponentOutput {
@ -112,6 +112,35 @@ func (i *Component) ToComponentOutputWithContext(ctx context.Context) ComponentO
return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput) return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput)
} }
func (i *Component) ToComponentPtrOutput() ComponentPtrOutput {
return i.ToComponentPtrOutputWithContext(context.Background())
}
func (i *Component) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
}
type ComponentPtrInput interface {
pulumi.Input
ToComponentPtrOutput() ComponentPtrOutput
ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput
}
type componentPtrType ComponentArgs
func (*componentPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil))
}
func (i *componentPtrType) ToComponentPtrOutput() ComponentPtrOutput {
return i.ToComponentPtrOutputWithContext(context.Background())
}
func (i *componentPtrType) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
}
// ComponentArrayInput is an input type that accepts ComponentArray and ComponentArrayOutput values. // ComponentArrayInput is an input type that accepts ComponentArray and ComponentArrayOutput values.
// You can construct a concrete instance of `ComponentArrayInput` via: // You can construct a concrete instance of `ComponentArrayInput` via:
// //
@ -165,7 +194,7 @@ func (i ComponentMap) ToComponentMapOutputWithContext(ctx context.Context) Compo
type ComponentOutput struct{ *pulumi.OutputState } type ComponentOutput struct{ *pulumi.OutputState }
func (ComponentOutput) ElementType() reflect.Type { func (ComponentOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil)).Elem() return reflect.TypeOf((*Component)(nil))
} }
func (o ComponentOutput) ToComponentOutput() ComponentOutput { func (o ComponentOutput) ToComponentOutput() ComponentOutput {
@ -176,10 +205,44 @@ func (o ComponentOutput) ToComponentOutputWithContext(ctx context.Context) Compo
return o return o
} }
func (o ComponentOutput) ToComponentPtrOutput() ComponentPtrOutput {
return o.ToComponentPtrOutputWithContext(context.Background())
}
func (o ComponentOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Component) *Component {
return &v
}).(ComponentPtrOutput)
}
type ComponentPtrOutput struct{ *pulumi.OutputState }
func (ComponentPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Component)(nil))
}
func (o ComponentPtrOutput) ToComponentPtrOutput() ComponentPtrOutput {
return o
}
func (o ComponentPtrOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
return o
}
func (o ComponentPtrOutput) Elem() ComponentOutput {
return o.ApplyT(func(v *Component) Component {
if v != nil {
return *v
}
var ret Component
return ret
}).(ComponentOutput)
}
type ComponentArrayOutput struct{ *pulumi.OutputState } type ComponentArrayOutput struct{ *pulumi.OutputState }
func (ComponentArrayOutput) ElementType() reflect.Type { func (ComponentArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Component)(nil)).Elem() return reflect.TypeOf((*[]Component)(nil))
} }
func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput { func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput {
@ -191,15 +254,15 @@ func (o ComponentArrayOutput) ToComponentArrayOutputWithContext(ctx context.Cont
} }
func (o ComponentArrayOutput) Index(i pulumi.IntInput) ComponentOutput { func (o ComponentArrayOutput) Index(i pulumi.IntInput) ComponentOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Component { return pulumi.All(o, i).ApplyT(func(vs []interface{}) Component {
return vs[0].([]*Component)[vs[1].(int)] return vs[0].([]Component)[vs[1].(int)]
}).(ComponentOutput) }).(ComponentOutput)
} }
type ComponentMapOutput struct{ *pulumi.OutputState } type ComponentMapOutput struct{ *pulumi.OutputState }
func (ComponentMapOutput) ElementType() reflect.Type { func (ComponentMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Component)(nil)).Elem() return reflect.TypeOf((*map[string]Component)(nil))
} }
func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput { func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput {
@ -211,16 +274,18 @@ func (o ComponentMapOutput) ToComponentMapOutputWithContext(ctx context.Context)
} }
func (o ComponentMapOutput) MapIndex(k pulumi.StringInput) ComponentOutput { func (o ComponentMapOutput) MapIndex(k pulumi.StringInput) ComponentOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Component { return pulumi.All(o, k).ApplyT(func(vs []interface{}) Component {
return vs[0].(map[string]*Component)[vs[1].(string)] return vs[0].(map[string]Component)[vs[1].(string)]
}).(ComponentOutput) }).(ComponentOutput)
} }
func init() { func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{}) pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{})
pulumi.RegisterInputType(reflect.TypeOf((*ComponentPtrInput)(nil)).Elem(), &Component{})
pulumi.RegisterInputType(reflect.TypeOf((*ComponentArrayInput)(nil)).Elem(), ComponentArray{}) pulumi.RegisterInputType(reflect.TypeOf((*ComponentArrayInput)(nil)).Elem(), ComponentArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ComponentMapInput)(nil)).Elem(), ComponentMap{}) pulumi.RegisterInputType(reflect.TypeOf((*ComponentMapInput)(nil)).Elem(), ComponentMap{})
pulumi.RegisterOutputType(ComponentOutput{}) pulumi.RegisterOutputType(ComponentOutput{})
pulumi.RegisterOutputType(ComponentPtrOutput{})
pulumi.RegisterOutputType(ComponentArrayOutput{}) pulumi.RegisterOutputType(ComponentArrayOutput{})
pulumi.RegisterOutputType(ComponentMapOutput{}) pulumi.RegisterOutputType(ComponentMapOutput{})
} }

View file

@ -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 {
@ -59,10 +59,39 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput) return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
} }
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderPtrInput interface {
pulumi.Input
ToProviderPtrOutput() ProviderPtrOutput
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
}
type providerPtrType ProviderArgs
func (*providerPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderOutput struct{ *pulumi.OutputState } 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 {
@ -73,7 +102,43 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
return o return o
} }
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o.ToProviderPtrOutputWithContext(context.Background())
}
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
return &v
}).(ProviderPtrOutput)
}
type ProviderPtrOutput struct{ *pulumi.OutputState }
func (ProviderPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) Elem() ProviderOutput {
return o.ApplyT(func(v *Provider) Provider {
if v != nil {
return *v
}
var ret Provider
return ret
}).(ProviderOutput)
}
func init() { func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{}) pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
pulumi.RegisterOutputType(ProviderOutput{}) pulumi.RegisterOutputType(ProviderOutput{})
pulumi.RegisterOutputType(ProviderPtrOutput{})
} }

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -74,7 +74,7 @@ type WorkloadInput interface {
} }
func (*Workload) ElementType() reflect.Type { func (*Workload) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil)).Elem() return reflect.TypeOf((*Workload)(nil))
} }
func (i *Workload) ToWorkloadOutput() WorkloadOutput { func (i *Workload) ToWorkloadOutput() WorkloadOutput {
@ -85,6 +85,35 @@ func (i *Workload) ToWorkloadOutputWithContext(ctx context.Context) WorkloadOutp
return pulumi.ToOutputWithContext(ctx, i).(WorkloadOutput) return pulumi.ToOutputWithContext(ctx, i).(WorkloadOutput)
} }
func (i *Workload) ToWorkloadPtrOutput() WorkloadPtrOutput {
return i.ToWorkloadPtrOutputWithContext(context.Background())
}
func (i *Workload) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
}
type WorkloadPtrInput interface {
pulumi.Input
ToWorkloadPtrOutput() WorkloadPtrOutput
ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput
}
type workloadPtrType WorkloadArgs
func (*workloadPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil))
}
func (i *workloadPtrType) ToWorkloadPtrOutput() WorkloadPtrOutput {
return i.ToWorkloadPtrOutputWithContext(context.Background())
}
func (i *workloadPtrType) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
}
// WorkloadArrayInput is an input type that accepts WorkloadArray and WorkloadArrayOutput values. // WorkloadArrayInput is an input type that accepts WorkloadArray and WorkloadArrayOutput values.
// You can construct a concrete instance of `WorkloadArrayInput` via: // You can construct a concrete instance of `WorkloadArrayInput` via:
// //
@ -138,7 +167,7 @@ func (i WorkloadMap) ToWorkloadMapOutputWithContext(ctx context.Context) Workloa
type WorkloadOutput struct{ *pulumi.OutputState } type WorkloadOutput struct{ *pulumi.OutputState }
func (WorkloadOutput) ElementType() reflect.Type { func (WorkloadOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil)).Elem() return reflect.TypeOf((*Workload)(nil))
} }
func (o WorkloadOutput) ToWorkloadOutput() WorkloadOutput { func (o WorkloadOutput) ToWorkloadOutput() WorkloadOutput {
@ -149,10 +178,44 @@ func (o WorkloadOutput) ToWorkloadOutputWithContext(ctx context.Context) Workloa
return o return o
} }
func (o WorkloadOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
return o.ToWorkloadPtrOutputWithContext(context.Background())
}
func (o WorkloadOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Workload) *Workload {
return &v
}).(WorkloadPtrOutput)
}
type WorkloadPtrOutput struct{ *pulumi.OutputState }
func (WorkloadPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Workload)(nil))
}
func (o WorkloadPtrOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
return o
}
func (o WorkloadPtrOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
return o
}
func (o WorkloadPtrOutput) Elem() WorkloadOutput {
return o.ApplyT(func(v *Workload) Workload {
if v != nil {
return *v
}
var ret Workload
return ret
}).(WorkloadOutput)
}
type WorkloadArrayOutput struct{ *pulumi.OutputState } type WorkloadArrayOutput struct{ *pulumi.OutputState }
func (WorkloadArrayOutput) ElementType() reflect.Type { func (WorkloadArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Workload)(nil)).Elem() return reflect.TypeOf((*[]Workload)(nil))
} }
func (o WorkloadArrayOutput) ToWorkloadArrayOutput() WorkloadArrayOutput { func (o WorkloadArrayOutput) ToWorkloadArrayOutput() WorkloadArrayOutput {
@ -164,15 +227,15 @@ func (o WorkloadArrayOutput) ToWorkloadArrayOutputWithContext(ctx context.Contex
} }
func (o WorkloadArrayOutput) Index(i pulumi.IntInput) WorkloadOutput { func (o WorkloadArrayOutput) Index(i pulumi.IntInput) WorkloadOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Workload { return pulumi.All(o, i).ApplyT(func(vs []interface{}) Workload {
return vs[0].([]*Workload)[vs[1].(int)] return vs[0].([]Workload)[vs[1].(int)]
}).(WorkloadOutput) }).(WorkloadOutput)
} }
type WorkloadMapOutput struct{ *pulumi.OutputState } type WorkloadMapOutput struct{ *pulumi.OutputState }
func (WorkloadMapOutput) ElementType() reflect.Type { func (WorkloadMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Workload)(nil)).Elem() return reflect.TypeOf((*map[string]Workload)(nil))
} }
func (o WorkloadMapOutput) ToWorkloadMapOutput() WorkloadMapOutput { func (o WorkloadMapOutput) ToWorkloadMapOutput() WorkloadMapOutput {
@ -184,16 +247,18 @@ func (o WorkloadMapOutput) ToWorkloadMapOutputWithContext(ctx context.Context) W
} }
func (o WorkloadMapOutput) MapIndex(k pulumi.StringInput) WorkloadOutput { func (o WorkloadMapOutput) MapIndex(k pulumi.StringInput) WorkloadOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Workload { return pulumi.All(o, k).ApplyT(func(vs []interface{}) Workload {
return vs[0].(map[string]*Workload)[vs[1].(string)] return vs[0].(map[string]Workload)[vs[1].(string)]
}).(WorkloadOutput) }).(WorkloadOutput)
} }
func init() { func init() {
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadInput)(nil)).Elem(), &Workload{}) pulumi.RegisterInputType(reflect.TypeOf((*WorkloadInput)(nil)).Elem(), &Workload{})
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadPtrInput)(nil)).Elem(), &Workload{})
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadArrayInput)(nil)).Elem(), WorkloadArray{}) pulumi.RegisterInputType(reflect.TypeOf((*WorkloadArrayInput)(nil)).Elem(), WorkloadArray{})
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadMapInput)(nil)).Elem(), WorkloadMap{}) pulumi.RegisterInputType(reflect.TypeOf((*WorkloadMapInput)(nil)).Elem(), WorkloadMap{})
pulumi.RegisterOutputType(WorkloadOutput{}) pulumi.RegisterOutputType(WorkloadOutput{})
pulumi.RegisterOutputType(WorkloadPtrOutput{})
pulumi.RegisterOutputType(WorkloadArrayOutput{}) pulumi.RegisterOutputType(WorkloadArrayOutput{})
pulumi.RegisterOutputType(WorkloadMapOutput{}) pulumi.RegisterOutputType(WorkloadMapOutput{})
} }

View file

@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
} }
export interface ArgFunctionOutputArgs { export interface ArgFunctionOutputArgs {
name?: pulumi.Input<pulumiRandom.RandomPet>; name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
} }

View file

@ -44,19 +44,19 @@ export class Cat extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: CatArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: CatArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["age"] = args ? args.age : undefined; inputs["age"] = args ? args.age : undefined;
resourceInputs["pet"] = args ? args.pet : undefined; inputs["pet"] = args ? args.pet : undefined;
resourceInputs["name"] = undefined /*out*/; inputs["name"] = undefined /*out*/;
} else { } else {
resourceInputs["name"] = undefined /*out*/; inputs["name"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Cat.__pulumiType, name, resourceInputs, opts); super(Cat.__pulumiType, name, inputs, opts);
} }
} }
@ -64,6 +64,6 @@ export class Cat extends pulumi.CustomResource {
* The set of arguments for constructing a Cat resource. * The set of arguments for constructing a Cat resource.
*/ */
export interface CatArgs { export interface CatArgs {
age?: pulumi.Input<number>; age?: pulumi.Input<number | undefined>;
pet?: pulumi.Input<inputs.PetArgs>; pet?: pulumi.Input<inputs.PetArgs | undefined>;
} }

View file

@ -46,7 +46,7 @@ export class Component extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args: ComponentArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args: ComponentArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
if ((!args || args.requiredMetadata === undefined) && !opts.urn) { if ((!args || args.requiredMetadata === undefined) && !opts.urn) {
@ -58,24 +58,24 @@ export class Component extends pulumi.CustomResource {
if ((!args || args.requiredMetadataMap === undefined) && !opts.urn) { if ((!args || args.requiredMetadataMap === undefined) && !opts.urn) {
throw new Error("Missing required property 'requiredMetadataMap'"); throw new Error("Missing required property 'requiredMetadataMap'");
} }
resourceInputs["metadata"] = args ? args.metadata : undefined; inputs["metadata"] = args ? args.metadata : undefined;
resourceInputs["metadataArray"] = args ? args.metadataArray : undefined; inputs["metadataArray"] = args ? args.metadataArray : undefined;
resourceInputs["metadataMap"] = args ? args.metadataMap : undefined; inputs["metadataMap"] = args ? args.metadataMap : undefined;
resourceInputs["requiredMetadata"] = args ? args.requiredMetadata : undefined; inputs["requiredMetadata"] = args ? args.requiredMetadata : undefined;
resourceInputs["requiredMetadataArray"] = args ? args.requiredMetadataArray : undefined; inputs["requiredMetadataArray"] = args ? args.requiredMetadataArray : undefined;
resourceInputs["requiredMetadataMap"] = args ? args.requiredMetadataMap : undefined; inputs["requiredMetadataMap"] = args ? args.requiredMetadataMap : undefined;
resourceInputs["provider"] = undefined /*out*/; inputs["provider"] = undefined /*out*/;
resourceInputs["securityGroup"] = undefined /*out*/; inputs["securityGroup"] = undefined /*out*/;
resourceInputs["storageClasses"] = undefined /*out*/; inputs["storageClasses"] = undefined /*out*/;
} else { } else {
resourceInputs["provider"] = undefined /*out*/; inputs["provider"] = undefined /*out*/;
resourceInputs["securityGroup"] = undefined /*out*/; inputs["securityGroup"] = undefined /*out*/;
resourceInputs["storageClasses"] = undefined /*out*/; inputs["storageClasses"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Component.__pulumiType, name, resourceInputs, opts); super(Component.__pulumiType, name, inputs, opts);
} }
} }
@ -83,9 +83,9 @@ export class Component extends pulumi.CustomResource {
* The set of arguments for constructing a Component resource. * The set of arguments for constructing a Component resource.
*/ */
export interface ComponentArgs { export interface ComponentArgs {
metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>; metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs | undefined>;
metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>; metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[] | undefined>;
metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>; metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>} | undefined>;
requiredMetadata: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>; requiredMetadata: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>;
requiredMetadataArray: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>; requiredMetadataArray: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>;
requiredMetadataMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>; requiredMetadataMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>;

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -7,10 +7,10 @@ import { input as inputs, output as outputs } from "../types";
import * as pulumiRandom from "@pulumi/random"; import * as pulumiRandom from "@pulumi/random";
export interface PetArgs { export interface PetArgs {
age?: pulumi.Input<number>; age?: pulumi.Input<number | undefined>;
name?: pulumi.Input<pulumiRandom.RandomPet>; name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>; nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[] | undefined>;
nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>; nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>} | undefined>;
requiredName: pulumi.Input<pulumiRandom.RandomPet>; requiredName: pulumi.Input<pulumiRandom.RandomPet>;
requiredNameArray: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>; requiredNameArray: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>;
requiredNameMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>; requiredNameMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>;

View file

@ -43,17 +43,17 @@ export class Workload extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: WorkloadArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: WorkloadArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["pod"] = undefined /*out*/; inputs["pod"] = undefined /*out*/;
} else { } else {
resourceInputs["pod"] = undefined /*out*/; inputs["pod"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Workload.__pulumiType, name, resourceInputs, opts); super(Workload.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -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 {
@ -59,10 +59,39 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput) return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
} }
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderPtrInput interface {
pulumi.Input
ToProviderPtrOutput() ProviderPtrOutput
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
}
type providerPtrType ProviderArgs
func (*providerPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderOutput struct{ *pulumi.OutputState } 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 {
@ -73,7 +102,43 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
return o return o
} }
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o.ToProviderPtrOutputWithContext(context.Background())
}
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
return &v
}).(ProviderPtrOutput)
}
type ProviderPtrOutput struct{ *pulumi.OutputState }
func (ProviderPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) Elem() ProviderOutput {
return o.ApplyT(func(v *Provider) Provider {
if v != nil {
return *v
}
var ret Provider
return ret
}).(ProviderOutput)
}
func init() { func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{}) pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
pulumi.RegisterOutputType(ProviderOutput{}) pulumi.RegisterOutputType(ProviderOutput{})
pulumi.RegisterOutputType(ProviderPtrOutput{})
} }

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -65,7 +65,7 @@ type RegistryGeoReplicationInput interface {
} }
func (*RegistryGeoReplication) ElementType() reflect.Type { func (*RegistryGeoReplication) ElementType() reflect.Type {
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem() return reflect.TypeOf((*RegistryGeoReplication)(nil))
} }
func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput { func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
@ -76,6 +76,35 @@ func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutputWithContext(ctx c
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationOutput) return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationOutput)
} }
func (i *RegistryGeoReplication) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
return i.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
}
func (i *RegistryGeoReplication) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationPtrOutput)
}
type RegistryGeoReplicationPtrInput interface {
pulumi.Input
ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput
ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput
}
type registryGeoReplicationPtrType RegistryGeoReplicationArgs
func (*registryGeoReplicationPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**RegistryGeoReplication)(nil))
}
func (i *registryGeoReplicationPtrType) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
return i.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
}
func (i *registryGeoReplicationPtrType) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(RegistryGeoReplicationPtrOutput)
}
// RegistryGeoReplicationArrayInput is an input type that accepts RegistryGeoReplicationArray and RegistryGeoReplicationArrayOutput values. // RegistryGeoReplicationArrayInput is an input type that accepts RegistryGeoReplicationArray and RegistryGeoReplicationArrayOutput values.
// You can construct a concrete instance of `RegistryGeoReplicationArrayInput` via: // You can construct a concrete instance of `RegistryGeoReplicationArrayInput` via:
// //
@ -129,7 +158,7 @@ func (i RegistryGeoReplicationMap) ToRegistryGeoReplicationMapOutputWithContext(
type RegistryGeoReplicationOutput struct{ *pulumi.OutputState } type RegistryGeoReplicationOutput struct{ *pulumi.OutputState }
func (RegistryGeoReplicationOutput) ElementType() reflect.Type { func (RegistryGeoReplicationOutput) ElementType() reflect.Type {
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem() return reflect.TypeOf((*RegistryGeoReplication)(nil))
} }
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput { func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
@ -140,10 +169,44 @@ func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutputWithContext(
return o return o
} }
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
return o.ToRegistryGeoReplicationPtrOutputWithContext(context.Background())
}
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v RegistryGeoReplication) *RegistryGeoReplication {
return &v
}).(RegistryGeoReplicationPtrOutput)
}
type RegistryGeoReplicationPtrOutput struct{ *pulumi.OutputState }
func (RegistryGeoReplicationPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**RegistryGeoReplication)(nil))
}
func (o RegistryGeoReplicationPtrOutput) ToRegistryGeoReplicationPtrOutput() RegistryGeoReplicationPtrOutput {
return o
}
func (o RegistryGeoReplicationPtrOutput) ToRegistryGeoReplicationPtrOutputWithContext(ctx context.Context) RegistryGeoReplicationPtrOutput {
return o
}
func (o RegistryGeoReplicationPtrOutput) Elem() RegistryGeoReplicationOutput {
return o.ApplyT(func(v *RegistryGeoReplication) RegistryGeoReplication {
if v != nil {
return *v
}
var ret RegistryGeoReplication
return ret
}).(RegistryGeoReplicationOutput)
}
type RegistryGeoReplicationArrayOutput struct{ *pulumi.OutputState } type RegistryGeoReplicationArrayOutput struct{ *pulumi.OutputState }
func (RegistryGeoReplicationArrayOutput) ElementType() reflect.Type { func (RegistryGeoReplicationArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*RegistryGeoReplication)(nil)).Elem() return reflect.TypeOf((*[]RegistryGeoReplication)(nil))
} }
func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutput() RegistryGeoReplicationArrayOutput { func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutput() RegistryGeoReplicationArrayOutput {
@ -155,15 +218,15 @@ func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutputWi
} }
func (o RegistryGeoReplicationArrayOutput) Index(i pulumi.IntInput) RegistryGeoReplicationOutput { func (o RegistryGeoReplicationArrayOutput) Index(i pulumi.IntInput) RegistryGeoReplicationOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RegistryGeoReplication { return pulumi.All(o, i).ApplyT(func(vs []interface{}) RegistryGeoReplication {
return vs[0].([]*RegistryGeoReplication)[vs[1].(int)] return vs[0].([]RegistryGeoReplication)[vs[1].(int)]
}).(RegistryGeoReplicationOutput) }).(RegistryGeoReplicationOutput)
} }
type RegistryGeoReplicationMapOutput struct{ *pulumi.OutputState } type RegistryGeoReplicationMapOutput struct{ *pulumi.OutputState }
func (RegistryGeoReplicationMapOutput) ElementType() reflect.Type { func (RegistryGeoReplicationMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*RegistryGeoReplication)(nil)).Elem() return reflect.TypeOf((*map[string]RegistryGeoReplication)(nil))
} }
func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutput() RegistryGeoReplicationMapOutput { func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutput() RegistryGeoReplicationMapOutput {
@ -175,16 +238,18 @@ func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutputWithCo
} }
func (o RegistryGeoReplicationMapOutput) MapIndex(k pulumi.StringInput) RegistryGeoReplicationOutput { func (o RegistryGeoReplicationMapOutput) MapIndex(k pulumi.StringInput) RegistryGeoReplicationOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RegistryGeoReplication { return pulumi.All(o, k).ApplyT(func(vs []interface{}) RegistryGeoReplication {
return vs[0].(map[string]*RegistryGeoReplication)[vs[1].(string)] return vs[0].(map[string]RegistryGeoReplication)[vs[1].(string)]
}).(RegistryGeoReplicationOutput) }).(RegistryGeoReplicationOutput)
} }
func init() { func init() {
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationInput)(nil)).Elem(), &RegistryGeoReplication{}) pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationInput)(nil)).Elem(), &RegistryGeoReplication{})
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationPtrInput)(nil)).Elem(), &RegistryGeoReplication{})
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationArrayInput)(nil)).Elem(), RegistryGeoReplicationArray{}) pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationArrayInput)(nil)).Elem(), RegistryGeoReplicationArray{})
pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationMapInput)(nil)).Elem(), RegistryGeoReplicationMap{}) pulumi.RegisterInputType(reflect.TypeOf((*RegistryGeoReplicationMapInput)(nil)).Elem(), RegistryGeoReplicationMap{})
pulumi.RegisterOutputType(RegistryGeoReplicationOutput{}) pulumi.RegisterOutputType(RegistryGeoReplicationOutput{})
pulumi.RegisterOutputType(RegistryGeoReplicationPtrOutput{})
pulumi.RegisterOutputType(RegistryGeoReplicationArrayOutput{}) pulumi.RegisterOutputType(RegistryGeoReplicationArrayOutput{})
pulumi.RegisterOutputType(RegistryGeoReplicationMapOutput{}) pulumi.RegisterOutputType(RegistryGeoReplicationMapOutput{})
} }

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -42,25 +42,25 @@ export class RegistryGeoReplication extends pulumi.ComponentResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args: RegistryGeoReplicationArgs, opts?: pulumi.ComponentResourceOptions) { constructor(name: string, args: RegistryGeoReplicationArgs, opts?: pulumi.ComponentResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
if ((!args || args.resourceGroup === undefined) && !opts.urn) { if ((!args || args.resourceGroup === undefined) && !opts.urn) {
throw new Error("Missing required property 'resourceGroup'"); throw new Error("Missing required property 'resourceGroup'");
} }
resourceInputs["resourceGroup"] = args ? args.resourceGroup : undefined; inputs["resourceGroup"] = args ? args.resourceGroup : undefined;
resourceInputs["acrLoginServerOut"] = undefined /*out*/; inputs["acrLoginServerOut"] = undefined /*out*/;
resourceInputs["registry"] = undefined /*out*/; inputs["registry"] = undefined /*out*/;
resourceInputs["replication"] = undefined /*out*/; inputs["replication"] = undefined /*out*/;
} else { } else {
resourceInputs["acrLoginServerOut"] = undefined /*out*/; inputs["acrLoginServerOut"] = undefined /*out*/;
resourceInputs["registry"] = undefined /*out*/; inputs["registry"] = undefined /*out*/;
resourceInputs["replication"] = undefined /*out*/; inputs["replication"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(RegistryGeoReplication.__pulumiType, name, resourceInputs, opts, true /*remote*/); super(RegistryGeoReplication.__pulumiType, name, inputs, opts, true /*remote*/);
} }
} }

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -73,7 +73,7 @@ type ResourceInput interface {
} }
func (*Resource) ElementType() reflect.Type { func (*Resource) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (i *Resource) ToResourceOutput() ResourceOutput { func (i *Resource) ToResourceOutput() ResourceOutput {
@ -87,7 +87,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
type ResourceOutput struct{ *pulumi.OutputState } type ResourceOutput struct{ *pulumi.OutputState }
func (ResourceOutput) ElementType() reflect.Type { func (ResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (o ResourceOutput) ToResourceOutput() ResourceOutput { func (o ResourceOutput) ToResourceOutput() ResourceOutput {

View file

@ -73,7 +73,7 @@ type ResourceInputResourceInput interface {
} }
func (*ResourceInputResource) ElementType() reflect.Type { func (*ResourceInputResource) ElementType() reflect.Type {
return reflect.TypeOf((**ResourceInputResource)(nil)).Elem() return reflect.TypeOf((*ResourceInputResource)(nil))
} }
func (i *ResourceInputResource) ToResourceInputResourceOutput() ResourceInputResourceOutput { func (i *ResourceInputResource) ToResourceInputResourceOutput() ResourceInputResourceOutput {
@ -87,7 +87,7 @@ func (i *ResourceInputResource) ToResourceInputResourceOutputWithContext(ctx con
type ResourceInputResourceOutput struct{ *pulumi.OutputState } type ResourceInputResourceOutput struct{ *pulumi.OutputState }
func (ResourceInputResourceOutput) ElementType() reflect.Type { func (ResourceInputResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ResourceInputResource)(nil)).Elem() return reflect.TypeOf((*ResourceInputResource)(nil))
} }
func (o ResourceInputResourceOutput) ToResourceInputResourceOutput() ResourceInputResourceOutput { func (o ResourceInputResourceOutput) ToResourceInputResourceOutput() ResourceInputResourceOutput {

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -41,17 +41,17 @@ export class Resource extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["bar"] = undefined /*out*/; inputs["bar"] = undefined /*out*/;
} else { } else {
resourceInputs["bar"] = undefined /*out*/; inputs["bar"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Resource.__pulumiType, name, resourceInputs, opts); super(Resource.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -41,17 +41,17 @@ export class ResourceInput extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ResourceInputArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: ResourceInputArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["bar"] = undefined /*out*/; inputs["bar"] = undefined /*out*/;
} else { } else {
resourceInputs["bar"] = undefined /*out*/; inputs["bar"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(ResourceInput.__pulumiType, name, resourceInputs, opts); super(ResourceInput.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -82,7 +82,7 @@ type ResourceInput interface {
} }
func (*Resource) ElementType() reflect.Type { func (*Resource) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (i *Resource) ToResourceOutput() ResourceOutput { func (i *Resource) ToResourceOutput() ResourceOutput {
@ -96,7 +96,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
type ResourceOutput struct{ *pulumi.OutputState } type ResourceOutput struct{ *pulumi.OutputState }
func (ResourceOutput) ElementType() reflect.Type { func (ResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (o ResourceOutput) ToResourceOutput() ResourceOutput { func (o ResourceOutput) ToResourceOutput() ResourceOutput {

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined; inputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined;
} else { } else {
resourceInputs["baz"] = undefined /*out*/; inputs["baz"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
const secretOpts = { additionalSecretOutputs: ["baz"] }; const secretOpts = { additionalSecretOutputs: ["baz"] };
opts = pulumi.mergeOptions(opts, secretOpts); opts = pulumi.mergeOptions(opts, secretOpts);
super(Resource.__pulumiType, name, resourceInputs, opts); super(Resource.__pulumiType, name, inputs, opts);
} }
} }
@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource. * The set of arguments for constructing a Resource resource.
*/ */
export interface ResourceArgs { export interface ResourceArgs {
baz?: pulumi.Input<string>; baz?: pulumi.Input<string | undefined>;
} }

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -82,7 +82,7 @@ type ResourceInput interface {
} }
func (*Resource) ElementType() reflect.Type { func (*Resource) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (i *Resource) ToResourceOutput() ResourceOutput { func (i *Resource) ToResourceOutput() ResourceOutput {
@ -96,7 +96,7 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
type ResourceOutput struct{ *pulumi.OutputState } type ResourceOutput struct{ *pulumi.OutputState }
func (ResourceOutput) ElementType() reflect.Type { func (ResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil)).Elem() return reflect.TypeOf((*Resource)(nil))
} }
func (o ResourceOutput) ToResourceOutput() ResourceOutput { func (o ResourceOutput) ToResourceOutput() ResourceOutput {

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
if (!opts.id) { if (!opts.id) {
resourceInputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; inputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined;
} else { } else {
resourceInputs["bar"] = undefined /*out*/; inputs["bar"] = undefined /*out*/;
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
const secretOpts = { additionalSecretOutputs: ["bar"] }; const secretOpts = { additionalSecretOutputs: ["bar"] };
opts = pulumi.mergeOptions(opts, secretOpts); opts = pulumi.mergeOptions(opts, secretOpts);
super(Resource.__pulumiType, name, resourceInputs, opts); super(Resource.__pulumiType, name, inputs, opts);
} }
} }
@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
* The set of arguments for constructing a Resource resource. * The set of arguments for constructing a Resource resource.
*/ */
export interface ResourceArgs { export interface ResourceArgs {
bar?: pulumi.Input<string>; bar?: pulumi.Input<string | undefined>;
} }

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -1,57 +0,0 @@
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var aws_vpc = new Aws.Ec2.Vpc("aws_vpc", new Aws.Ec2.VpcArgs
{
CidrBlock = "10.0.0.0/16",
InstanceTenancy = "default",
});
var privateS3VpcEndpoint = new Aws.Ec2.VpcEndpoint("privateS3VpcEndpoint", new Aws.Ec2.VpcEndpointArgs
{
VpcId = aws_vpc.Id,
ServiceName = "com.amazonaws.us-west-2.s3",
});
var privateS3PrefixList = Aws.Ec2.GetPrefixList.Invoke(new Aws.Ec2.GetPrefixListInvokeArgs
{
PrefixListId = privateS3VpcEndpoint.PrefixListId,
});
var bar = new Aws.Ec2.NetworkAcl("bar", new Aws.Ec2.NetworkAclArgs
{
VpcId = aws_vpc.Id,
});
var privateS3NetworkAclRule = new Aws.Ec2.NetworkAclRule("privateS3NetworkAclRule", new Aws.Ec2.NetworkAclRuleArgs
{
NetworkAclId = bar.Id,
RuleNumber = 200,
Egress = false,
Protocol = "tcp",
RuleAction = "allow",
CidrBlock = privateS3PrefixList.Apply(privateS3PrefixList => privateS3PrefixList.CidrBlocks[0]),
FromPort = 443,
ToPort = 443,
});
var amis = Aws.Ec2.GetAmiIds.Invoke(new Aws.Ec2.GetAmiIdsInvokeArgs
{
Owners =
{
bar.Id,
},
Filters =
{
new Aws.Ec2.Inputs.GetAmiIdsFilterInputArgs
{
Name = bar.Id,
Values =
{
"pulumi*",
},
},
},
});
}
}

View file

@ -1,63 +0,0 @@
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
aws_vpc, err := ec2.NewVpc(ctx, "aws_vpc", &ec2.VpcArgs{
CidrBlock: pulumi.String("10.0.0.0/16"),
InstanceTenancy: pulumi.String("default"),
})
if err != nil {
return err
}
privateS3VpcEndpoint, err := ec2.NewVpcEndpoint(ctx, "privateS3VpcEndpoint", &ec2.VpcEndpointArgs{
VpcId: aws_vpc.ID(),
ServiceName: pulumi.String("com.amazonaws.us-west-2.s3"),
})
if err != nil {
return err
}
privateS3PrefixList := ec2.GetPrefixListOutput(ctx, ec2.GetPrefixListOutputArgs{
PrefixListId: privateS3VpcEndpoint.PrefixListId,
}, nil)
bar, err := ec2.NewNetworkAcl(ctx, "bar", &ec2.NetworkAclArgs{
VpcId: aws_vpc.ID(),
})
if err != nil {
return err
}
_, err = ec2.NewNetworkAclRule(ctx, "privateS3NetworkAclRule", &ec2.NetworkAclRuleArgs{
NetworkAclId: bar.ID(),
RuleNumber: pulumi.Int(200),
Egress: pulumi.Bool(false),
Protocol: pulumi.String("tcp"),
RuleAction: pulumi.String("allow"),
CidrBlock: privateS3PrefixList.ApplyT(func(privateS3PrefixList ec2.GetPrefixListResult) (string, error) {
return privateS3PrefixList.CidrBlocks[0], nil
}).(pulumi.StringOutput),
FromPort: pulumi.Int(443),
ToPort: pulumi.Int(443),
})
if err != nil {
return err
}
_ = ec2.GetAmiIdsOutput(ctx, ec2.GetAmiIdsOutputArgs{
Owners: pulumi.StringArray{
bar.ID(),
},
Filters: ec2.GetAmiIdsFilterArray{
&ec2.GetAmiIdsFilterArgs{
Name: bar.ID(),
Values: pulumi.StringArray{
pulumi.String("pulumi*"),
},
},
},
}, nil)
return nil
})
}

View file

@ -1,32 +0,0 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const aws_vpc = new aws.ec2.Vpc("aws_vpc", {
cidrBlock: "10.0.0.0/16",
instanceTenancy: "default",
});
const privateS3VpcEndpoint = new aws.ec2.VpcEndpoint("privateS3VpcEndpoint", {
vpcId: aws_vpc.id,
serviceName: "com.amazonaws.us-west-2.s3",
});
const privateS3PrefixList = aws.ec2.getPrefixListOutput({
prefixListId: privateS3VpcEndpoint.prefixListId,
});
const bar = new aws.ec2.NetworkAcl("bar", {vpcId: aws_vpc.id});
const privateS3NetworkAclRule = new aws.ec2.NetworkAclRule("privateS3NetworkAclRule", {
networkAclId: bar.id,
ruleNumber: 200,
egress: false,
protocol: "tcp",
ruleAction: "allow",
cidrBlock: privateS3PrefixList.cidrBlocks[0],
fromPort: 443,
toPort: 443,
});
const amis = aws.ec2.getAmiIdsOutput({
owners: [bar.id],
filters: [{
name: bar.id,
values: ["pulumi*"],
}],
});

View file

@ -1,36 +0,0 @@
resource aws_vpc "aws:ec2/vpc:Vpc" {
cidrBlock = "10.0.0.0/16"
instanceTenancy = "default"
}
resource privateS3VpcEndpoint "aws:ec2/vpcEndpoint:VpcEndpoint" {
vpcId = aws_vpc.id
serviceName = "com.amazonaws.us-west-2.s3"
}
privateS3PrefixList = invoke("aws:ec2:getPrefixList", {
prefixListId = privateS3VpcEndpoint.prefixListId
})
resource bar "aws:ec2/networkAcl:NetworkAcl" {
vpcId = aws_vpc.id
}
resource privateS3NetworkAclRule "aws:ec2/networkAclRule:NetworkAclRule" {
networkAclId = bar.id
ruleNumber = 200
egress = false
protocol = "tcp"
ruleAction = "allow"
cidrBlock = privateS3PrefixList.cidrBlocks[0]
fromPort = 443
toPort = 443
}
# A contrived example to test that helper nested records ( `filters`
# below) generate correctly when using output-versioned function
# invoke forms.
amis = invoke("aws:ec2:getAmiIds", {
owners = [bar.id]
filters = [{name=bar.id, values=["pulumi*"]}]
})

View file

@ -1,25 +0,0 @@
import pulumi
import pulumi_aws as aws
aws_vpc = aws.ec2.Vpc("aws_vpc",
cidr_block="10.0.0.0/16",
instance_tenancy="default")
private_s3_vpc_endpoint = aws.ec2.VpcEndpoint("privateS3VpcEndpoint",
vpc_id=aws_vpc.id,
service_name="com.amazonaws.us-west-2.s3")
private_s3_prefix_list = aws.ec2.get_prefix_list_output(prefix_list_id=private_s3_vpc_endpoint.prefix_list_id)
bar = aws.ec2.NetworkAcl("bar", vpc_id=aws_vpc.id)
private_s3_network_acl_rule = aws.ec2.NetworkAclRule("privateS3NetworkAclRule",
network_acl_id=bar.id,
rule_number=200,
egress=False,
protocol="tcp",
rule_action="allow",
cidr_block=private_s3_prefix_list.cidr_blocks[0],
from_port=443,
to_port=443)
amis = aws.ec2.get_ami_ids_output(owners=[bar.id],
filters=[aws.ec2.GetAmiIdsFilterArgs(
name=bar.id,
values=["pulumi*"],
)])

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -65,9 +65,9 @@ export interface ListConfigurationsOutputArgs {
/** /**
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details * Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
*/ */
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>; customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
/** /**
* $skipToken is supported on list of configurations, which provides the next page in the list of configurations. * $skipToken is supported on list of configurations, which provides the next page in the list of configurations.
*/ */
skipToken?: pulumi.Input<string>; skipToken?: pulumi.Input<string | undefined>;
} }

View file

@ -66,11 +66,11 @@ export interface ListProductFamiliesOutputArgs {
/** /**
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details * Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
*/ */
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>; customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
/** /**
* $expand is supported on configurations parameter for product, which provides details on the configurations for the product. * $expand is supported on configurations parameter for product, which provides details on the configurations for the product.
*/ */
expand?: pulumi.Input<string>; expand?: pulumi.Input<string | undefined>;
/** /**
* Dictionary of filterable properties on product family. * Dictionary of filterable properties on product family.
*/ */
@ -78,5 +78,5 @@ export interface ListProductFamiliesOutputArgs {
/** /**
* $skipToken is supported on list of product families, which provides the next page in the list of product families. * $skipToken is supported on list of product families, which provides the next page in the list of product families.
*/ */
skipToken?: pulumi.Input<string>; skipToken?: pulumi.Input<string | undefined>;
} }

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -11,7 +11,7 @@ export interface ConfigurationFiltersArgs {
/** /**
* Filters specific to product * Filters specific to product
*/ */
filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[]>; filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[] | undefined>;
/** /**
* Product hierarchy information * Product hierarchy information
*/ */
@ -57,7 +57,7 @@ export interface CustomerSubscriptionDetailsArgs {
/** /**
* Location placement Id of a subscription * Location placement Id of a subscription
*/ */
locationPlacementId?: pulumi.Input<string>; locationPlacementId?: pulumi.Input<string | undefined>;
/** /**
* Quota ID of a subscription * Quota ID of a subscription
*/ */
@ -65,7 +65,7 @@ export interface CustomerSubscriptionDetailsArgs {
/** /**
* List of registered feature flags for subscription * List of registered feature flags for subscription
*/ */
registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[]>; registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[] | undefined>;
} }
/** /**
@ -89,11 +89,11 @@ export interface CustomerSubscriptionRegisteredFeaturesArgs {
/** /**
* Name of subscription registered feature * Name of subscription registered feature
*/ */
name?: pulumi.Input<string>; name?: pulumi.Input<string | undefined>;
/** /**
* State of subscription registered feature * State of subscription registered feature
*/ */
state?: pulumi.Input<string>; state?: pulumi.Input<string | undefined>;
} }
/** /**
@ -153,18 +153,18 @@ export interface HierarchyInformationArgs {
/** /**
* Represents configuration name that uniquely identifies configuration * Represents configuration name that uniquely identifies configuration
*/ */
configurationName?: pulumi.Input<string>; configurationName?: pulumi.Input<string | undefined>;
/** /**
* Represents product family name that uniquely identifies product family * Represents product family name that uniquely identifies product family
*/ */
productFamilyName?: pulumi.Input<string>; productFamilyName?: pulumi.Input<string | undefined>;
/** /**
* Represents product line name that uniquely identifies product line * Represents product line name that uniquely identifies product line
*/ */
productLineName?: pulumi.Input<string>; productLineName?: pulumi.Input<string | undefined>;
/** /**
* Represents product name that uniquely identifies product * Represents product name that uniquely identifies product
*/ */
productName?: pulumi.Input<string>; productName?: pulumi.Input<string | undefined>;
} }

View file

@ -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 {

View file

@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
} }
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath) return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
} }
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}

View file

@ -88,13 +88,13 @@ export interface GetAmiIdsOutputArgs {
* Limit search to users with *explicit* launch * Limit search to users with *explicit* launch
* permission on the image. Valid items are the numeric account ID or `self`. * permission on the image. Valid items are the numeric account ID or `self`.
*/ */
executableUsers?: pulumi.Input<pulumi.Input<string>[]>; executableUsers?: pulumi.Input<pulumi.Input<string>[] | undefined>;
/** /**
* One or more name/value pairs to filter off of. There * One or more name/value pairs to filter off of. There
* are several valid keys, for a full reference, check out * are several valid keys, for a full reference, check out
* [describe-images in the AWS CLI reference][1]. * [describe-images in the AWS CLI reference][1].
*/ */
filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[]>; filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[] | undefined>;
/** /**
* A regex string to apply to the AMI list returned * A regex string to apply to the AMI list returned
* by AWS. This allows more advanced filtering not supported from the AWS API. * by AWS. This allows more advanced filtering not supported from the AWS API.
@ -102,7 +102,7 @@ export interface GetAmiIdsOutputArgs {
* impact if the result is large. It is recommended to combine this with other * impact if the result is large. It is recommended to combine this with other
* options to narrow down the list AWS returns. * options to narrow down the list AWS returns.
*/ */
nameRegex?: pulumi.Input<string>; nameRegex?: pulumi.Input<string | undefined>;
/** /**
* List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g. `amazon`, `aws-marketplace`, `microsoft`). * List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g. `amazon`, `aws-marketplace`, `microsoft`).
*/ */
@ -110,5 +110,5 @@ export interface GetAmiIdsOutputArgs {
/** /**
* Used to sort AMIs by creation time. * Used to sort AMIs by creation time.
*/ */
sortAscending?: pulumi.Input<boolean>; sortAscending?: pulumi.Input<boolean | undefined>;
} }

View file

@ -61,7 +61,7 @@ export interface ListStorageAccountKeysOutputArgs {
/** /**
* Specifies type of the key to be listed. Possible value is kerb. * Specifies type of the key to be listed. Possible value is kerb.
*/ */
expand?: pulumi.Input<string>; expand?: pulumi.Input<string | undefined>;
/** /**
* The name of the resource group within the user's subscription. The name is case insensitive. * The name of the resource group within the user's subscription. The name is case insensitive.
*/ */

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior. * @param opts A bag of options that control this resource's behavior.
*/ */
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let resourceInputs: pulumi.Inputs = {}; let inputs: pulumi.Inputs = {};
opts = opts || {}; opts = opts || {};
{ {
} }
if (!opts.version) { if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
} }
super(Provider.__pulumiType, name, resourceInputs, opts); super(Provider.__pulumiType, name, inputs, opts);
} }
} }

View file

@ -35,8 +35,8 @@ func (mocks) NewResource(args pulumi.MockResourceArgs) (string, resource.Propert
} }
func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) { func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
switch args.Token { if args.Token == "mypkg::listStorageAccountKeys" {
case "mypkg::listStorageAccountKeys":
targs := mypkg.ListStorageAccountKeysArgs{} targs := mypkg.ListStorageAccountKeysArgs{}
for k, v := range args.Args { for k, v := range args.Args {
switch k { switch k {
@ -72,11 +72,12 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
"keys": result.Keys, "keys": result.Keys,
} }
return resource.NewPropertyMapFromMap(outputs), nil return resource.NewPropertyMapFromMap(outputs), nil
}
case "mypkg::funcWithDefaultValue", if args.Token == "mypkg::funcWithDefaultValue" ||
"mypkg::funcWithAllOptionalInputs", args.Token == "mypkg::funcWithAllOptionalInputs" ||
"mypkg::funcWithListParam", args.Token == "mypkg::funcWithListParam" ||
"mypkg::funcWithDictParam": args.Token == "mypkg::funcWithDictParam" {
result := mypkg.FuncWithDefaultValueResult{ result := mypkg.FuncWithDefaultValueResult{
R: fmt.Sprintf("%v", args.Args), R: fmt.Sprintf("%v", args.Args),
} }
@ -84,8 +85,9 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
"r": result.R, "r": result.R,
} }
return resource.NewPropertyMapFromMap(outputs), nil return resource.NewPropertyMapFromMap(outputs), nil
}
case "mypkg::getIntegrationRuntimeObjectMetadatum": if args.Token == "mypkg::getIntegrationRuntimeObjectMetadatum" {
targs := mypkg.GetIntegrationRuntimeObjectMetadatumArgs{} targs := mypkg.GetIntegrationRuntimeObjectMetadatumArgs{}
for k, v := range args.Args { for k, v := range args.Args {
switch k { switch k {
@ -149,13 +151,16 @@ func TestListStorageAccountKeysOutput(t *testing.T) {
}) })
} }
// TODO[pulumi/pulumi#7811]: it seems that default values are not
// supported by Go codegen yet, hence we do not observe "B" populated
// to default at all here.
func TestFuncWithDefaultValueOutput(t *testing.T) { func TestFuncWithDefaultValueOutput(t *testing.T) {
pulumiTest(t, func(ctx *pulumi.Context) error { pulumiTest(t, func(ctx *pulumi.Context) error {
output := mypkg.FuncWithDefaultValueOutput(ctx, mypkg.FuncWithDefaultValueOutputArgs{ output := mypkg.FuncWithDefaultValueOutput(ctx, mypkg.FuncWithDefaultValueOutputArgs{
A: pulumi.String("my-a"), A: pulumi.String("my-a"),
}) })
r := waitOut(t, output.R()) r := waitOut(t, output.R())
assert.Equal(t, "map[a:{my-a} b:{b-default}]", r) assert.Equal(t, "map[a:{my-a}]", r)
return nil return nil
}) })
} }

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