Compare commits

...

31 commits

Author SHA1 Message Date
Anton Tayanovskyy 4d4ff9f1d6
Fixes 8403 name conflicts in Go codegen (#8492)
* Apply fn renaming on Result name conflict

* Add tests

* Add test declaration to test driver

* Accept baselines for other langs
2021-11-24 20:13:47 -05:00
Fraser Waters 2d26cdd9ed
Run validate function even if dryRun=true (#8494)
Hit this while trying to add some validation checks to runs of Preview while using plans. Seems one test actually was assuming this was the case already and just hasn't been running it's expected validate function.
2021-11-24 22:13:29 +00:00
Pat Gavlin b14bc09b1c
Update a misleading comment. (#8491) 2021-11-24 10:37:08 -08:00
Fraser Waters 09b7aa9186
Add String and GoString to Result (#8490)
I got fed up of assert errors in tests that looked like:
```
Expected nil, but got: &result.simpleResult{err:(*errors.fundamental)(0xc0002fa5d0)}
```

It was very hard to work out at a glance what had gone wrong and I kept
having to hook a debugger just to look at what the error was.

With GoString these now print something like:
```
Expected nil, but got: &simpleResult{err: Unexpected diag message: <{%reset%}>resource violates plan: properties changed: -zed, -baz, -foo<{%reset%}>
}
```

Which is much more useful.
2021-11-24 17:01:55 +00:00
Alex Mullans c39343fa3d
Update CONTRIBUTING.md with latest information (#8451)
* Update CONTRIBUTING.md

* Add `make dist` to recommended make targets
2021-11-23 16:31:56 -08:00
Ian Wahbe 4b7985384c
[codegen/go] Call site defaults for Pulumi Object types (#8411)
* Add test case

* Fix tests

* Add test dependencies correctly

* Feed through error handling

* Include test output

* Get types to line up

* Add remaining test files

* Update changelog

* Correctly find type paths

* Handle transitive objects

* Handle required fields

* Add feature flag for go

* Add required+default test case

* Don't `<any>` cast known types.

* Add more flags.

I realize this should really wait for PR#8400 to merge.

* Add plain object to env-helper test

This test fails right now. My next problem is fixing it.

* Handle plain types

* Handle function inputs

* Fix the indentation

* Handle output types correctly

* Remove unnecessary `!`

* Add test case

* Fix tests

* Add test dependencies correctly

* Feed through error handling

* Include test output

* Get types to line up

* Add remaining test files

* Update changelog

* Correctly find type paths

* Handle transitive objects

* Handle required fields

* Add required+default test case

* Don't `<any>` cast known types.

* Add plain object to env-helper test

This test fails right now. My next problem is fixing it.

* Handle plain types

* Handle function inputs

* Fix the indentation

* Handle output types correctly

* Remove unnecessary `!`

* Start on `genPlainObjectDefaultFunc`

* Add missing change to fix test

* Run tests with merge

* Refactor out assign

* Merge in next _index.md diff

* Change method name to `Defaults`

* Handle enums correctly

* Another attempt at _index.md

* Make module generation deterministic

* Add checks for old values

* Insert defaults in resources

* Fix docs generation

Credit to @praneetloke

* Progress on adding defaults to Resource arguments

* Handle resource argument defaults

* Don't create defaults if disableObjectDefaults

* Rename test folder

* Add test for disable flag

* Fix disable test

* Update docs

* Abstract out nil comparisons

* Use reflection to test for empty values

* Simplify Ptr and pulumi.Any type handling

* Remove unused function

* Apply defaults to functions

* Update new test with master codegen

* Tests + nil check
2021-11-23 15:10:15 -08:00
Anton Tayanovskyy 6cb801cf17
Add a unit test to check Array/Index (#8486) 2021-11-23 16:52:02 -05:00
Pat Gavlin 52d01bb915
[codegen/go] Remove ResourcePtr input/output types (#8449)
These changes remove the `Ptr` variants of input/ouptut types for
resources. A `TPtr` input or output is normally generated for `T` if `T`
is present in an `optional(input(T))` or `optional(output(T))` and if
the Go representation for `T` is not nilable. The generation of `Ptr`
variants for resource types breaks the latter rule: the canonical
representation of a resource type named `Foo` is a pointer to a struct
type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it
does not implement the Go `Resource` interface. Because this
representation already accommodates `nil` to indicate the lack of a
value, we need not generate `FooPtr{Input,Output}` types.

Besides being unnecessary, the implementation of `Ptr` types for
resources was incorrect. Rather than using `**Foo` as their element
type, these types use `*Foo`--identical to the element type used for
the normal input/output types. Furthermore, the generated code for
at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem`
was incorrect, making these types virtually unusable in practice.

Finally, these `Ptr` types should never appear on input/output
properties in practice, as the logic we use to generate input and output
type references never generates them for `optional({input,output}(T)).
Instead, it generates references to the standard input/output types.

Though this is _technically_ a breaking change--it changes the set of
exported types for any package that defines resources--I believe that in
practice it will be invisible to users for the reasons stated above.
These types are not usable, and were never referenced.

This is preparatory work for #7943.
2021-11-23 10:24:56 -08:00
Ian Wahbe c1c82b8317
Change build green link from travis to github (#8483) 2021-11-22 17:00:05 -08:00
Ian Wahbe e77d780370
Cleanup CHANGELOG_PENDING.md (#8482) 2021-11-22 16:59:22 -08:00
Ian Wahbe 72a4e1fc3f
Update pkg -> sdk dependency (#8481) 2021-11-22 14:39:54 -08:00
Ian Wahbe c6cefcd3f4
Prepare for v3.18.1 release (#8480) 2021-11-22 14:30:47 -08:00
Ian Wahbe 4029a1c89b
iwahbe/8474/dont serialize unknown values (#8475)
* Don't serialize unknown values

* Add test

* Update CHANGELOG_PENDING.md
2021-11-22 12:40:17 -08:00
Ian Wahbe d9dd88c740
Add tsconfig option to specify tsconfig path (#8452)
* Add tsconfig option to specify tsconfig path

* Add CHANGELOG entry and fix lint

* Add a test

* Fix test
2021-11-22 11:42:39 -08:00
Anton Tayanovskyy 574a6a104d
Do not FailNow() in generators (#8469) 2021-11-19 20:39:11 -05:00
Ian Wahbe 87d8c7f074
[sdk/pthon] Version Check: Handle virtual env correctly (#8465)
* Handle virtual env correctly

* Add CHANGELOG entry

* Correctly display which version is EOL
2021-11-19 15:21:13 -08:00
Ian Wahbe 7222e5570a
[cli] check main after master (#8463)
* Allow specifying a branch with url#branch

* Probe for master and main

* Update CHANGELOG

* Fix linter errors

* Remove unnecessary feature

* Fix lint

* Update changelog to reflect new limited scope.

We only talk about the master -> main probing, because that is all the
PR does. It used to duplicate another feature.
2021-11-19 13:49:59 -08:00
raphaelauv dbc8ab9ad6
[FIX] unprotect cmd example (#8430)
* [FIX] unprotect cmd example
2021-11-19 12:39:34 -08:00
Praneet Loke 2c25c3fbd0
[backend/filestate] Don't unwrap go-cloud errors (#8455)
* Don't unwrap go-cloud errors

* Remove unused func

* Add changelog entry

Co-authored-by: Ian Wahbe <ian@wahbe.com>
2021-11-19 12:21:37 -08:00
Anton Tayanovskyy f98d39b84b
Fix non-determinism in docsgen (#8456) 2021-11-19 11:23:06 -05:00
Anton Tayanovskyy e60d6bf248
Programgen support for F.Invoke forms in .NET (#7949) (#8432)
* Implement .NET codegen for F.Invoke forms

* Add tests for .NET Invoke

* Fixed conflict

* Accept changes reverting fargate example
2021-11-18 17:53:17 -05:00
Anton Tayanovskyy e846b3201f
Go implementation of fn.Output program gen (#7949) (#8431)
* Modify Go codegen for fn.Output overloads

* Fix go tests

* Fixed CHANGELOG conflict

* ACCEPT changes reverting Fargate example to master, file issue

* Link an issue
2021-11-18 17:50:51 -05:00
Anton Tayanovskyy 1cedb29193
Programgen support for fn_output forms in Python (#7949) (#8433)
* Update Python programgen to use fn_output forms

* Fix skips

* Fix CHANGELOG

* Accept changes, backing out Fargate change
2021-11-18 17:43:13 -05:00
Ian Wahbe 3e2f36548e
[codegen/typescript] Call site defaults for plain Pulumi Object types (#8400)
* Add test case

* Fix tests

* Add test dependencies correctly

* Feed through error handling

* Include test output

* Get types to line up

* Add remaining test files

* Update changelog

* Correctly find type paths

* Handle transitive objects

* Handle required fields

* Add required+default test case

* Don't `<any>` cast known types.

* Add plain object to env-helper test

This test fails right now. My next problem is fixing it.

* Handle plain types

* Handle function inputs

* Fix the indentation

* Handle output types correctly

* Remove unnecessary `!`

* Add missing change to fix test

* Run tests with merge

* Merge in next _index.md diff

* Another attempt at _index.md

* Make module generation deterministic

* Fix docs generation

Credit to @praneetloke
2021-11-18 12:23:30 -08:00
Ian Wahbe 013fcdec9d
Clean CHANGELOG_PENDING.md after v3.18.0 release (#8443) 2021-11-17 19:52:13 -08:00
Ian Wahbe b0dfad44c5
Update pkg -> sdk dependency (#8442) 2021-11-17 15:24:09 -08:00
Ian Wahbe 50308812c4
Prepare for v3.18.0 release (#8441) 2021-11-17 15:15:20 -08:00
Anton Tayanovskyy 06a19b53ed
Programgen support for fnOutput forms in node (#7949) (#8434)
* Teach PCL about fnOutput forms

* Teach PCL about fnOutput forms

* Teach Node program gen to emit fnOutput forms

* TypeCheck fix

* AWS package bump

* Add tests

* CHANGELOG

* Temporarily skip non-Node affected tests

* Address PR feedback: restrict new form to Output args only
2021-11-17 15:27:50 -05:00
Ian Wahbe b9f57bc6b9
Move /opt/pulumi to $HOME/.pulumi (#8437)
* Move `/opt/pulumi` to `$HOME/.pulumi`

* Don't suggest adding $HOME/.pulumi to PATH
2021-11-17 10:37:38 -08:00
Ian Wahbe 3329d81c1a
Update command respects --target-dependents (#8395)
* Update command respects `--target-dependents`

* Update CHANGELOG_PENDING.md

* Depend on parent and provider

* Add tests for new feature

* Separate predicate and mutation in code

* Remove `targetDependentsForUpdate`

* Refactor `isTargetedForUpdate`

* Add very important nil check
2021-11-16 17:12:36 -08:00
Pat Gavlin a1339277f0
[schema] Add enum overlay support. (#8425)
And update the metaschema to accommodate the `isOverlay` properties
added in #8338. Overlay enums, like other overlay members, are
implemented out-of-band by the declaring package. Code generators should
not generate declarations for overlay enums.
2021-11-16 15:53:28 -08:00
427 changed files with 24864 additions and 2715 deletions

View file

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

View file

@ -101,6 +101,13 @@ jobs:
./scripts/gen_resource_docs.sh aws 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
echo "::set-output name=branchName::${BRANCH_NAME}"

View file

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

View file

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

View file

@ -1,6 +1,90 @@
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)
### Improvements

View file

@ -1,36 +1,12 @@
### Improvements
- 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)
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of
a value--the implementation of `Ptr` types for resources was incorrect, making
these types virtually unusable in practice.
[#8449](https://github.com/pulumi/pulumi/pull/8449)
### Bug Fixes
- [engine] - Compute dependents correctly during targeted deletes.
[#8360](https://github.com/pulumi/pulumi/pull/8360)
- [docs] - Fix broken lists in dotnet docs
[docs#6558](https://github.com/pulumi/docs/issues/6558)
- [codegen/go] - Respect default values in Pulumi object types.
[#8411](https://github.com/pulumi/pulumi/pull/8400)

View file

@ -22,7 +22,7 @@ To hack on Pulumi, you'll need to get a development environment set up. You'll w
You can easily get all required dependencies with brew and npm
```bash
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl coreutils
curl https://raw.githubusercontent.com/Homebrew/homebrew-cask/0272f0d33f/Casks/dotnet-sdk.rb > dotnet-sdk.rb # v3.1.0
brew install --HEAD -s dotnet-sdk.rb
rm dotnet-sdk.rb
@ -38,12 +38,10 @@ 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.
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.
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`.
```bash
mkdir /opt/pulumi
sudo chown <your_user_name>: /opt/pulumi
export PATH=/opt/pulumi:/opt/pulumi/bin:$PATH
export PATH=$HOME/.pulumi/bin:$PATH
```
You'll also need to make sure your maximum open file descriptor limit is set to 5000 at a minimum.
@ -55,9 +53,10 @@ ulimit -n 5000
Across our projects, we try to use a regular set of make targets. The ones you'll care most about are:
0. `make ensure`, which restores/installs any build dependencies
1. `make ensure`, which restores/installs any build dependencies
1. `make dist`, which just builds and installs the Pulumi CLI
1. `make`, which builds Pulumi and runs a quick set of tests
2. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
1. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
We make heavy use of integration level testing where we invoke `pulumi` to create and then delete cloud resources. This requires you to have a Pulumi account (so [sign up for free](https://pulumi.com) today if you haven't already) and login with `pulumi login`.

View file

@ -173,8 +173,8 @@ details of the core Pulumi CLI and [programming model concepts](https://www.pulu
| Architecture | Build Status |
| ------------ | ------------ |
| Linux/macOS x64 | [![Linux x64 Build Status](https://travis-ci.com/pulumi/pulumi.svg?token=cTUUEgrxaTEGyecqJpDn&branch=master)](https://travis-ci.com/pulumi/pulumi) |
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
| Linux/macOS x64 | [![Linux x64 Build Status](https://github.com/pulumi/pulumi/actions/workflows/master.yml/badge.svg)](https://github.com/pulumi/pulumi/actions/workflows/master.yml) |
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
### Languages

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"
# Our install targets place items item into $PULUMI_ROOT, if it's
# unset, default to /opt/pulumi.
# unset, default to `$HOME/.pulumi`.
ifeq ($(PULUMI_ROOT),)
PULUMI_ROOT:=/opt/pulumi
PULUMI_ROOT:=$(shell realpath "$$HOME/.pulumi")
endif
# Use Python 3 explicitly vs expecting that `python` will resolve to a python 3
@ -168,6 +168,7 @@ test_fast::
install::
$(call STEP_MESSAGE)
# Implicitly creates PULUMI_ROOT.
@mkdir -p $(PULUMI_BIN)
@mkdir -p $(PULUMI_NODE_MODULES)
@mkdir -p $(PULUMI_NUGET)

View file

@ -57,6 +57,14 @@ The description of the package. Descriptions are interpreted as Markdown.
---
### `displayName`
The human-friendly name of the package.
`string`
---
### `functions`
A map from token to functionSpec that describes the set of functions defined by this package.
@ -159,6 +167,14 @@ The provider type for this package.
---
### `publisher`
The name of the person or organization that authored and published the package.
`string`
---
### `repository`
The URL at which the package's sources can be found.
@ -361,6 +377,14 @@ 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`
Additional language-specific data about the function.
@ -661,7 +685,7 @@ Indicates whether the resource is a component.
#### `isOverlay`
Indicates whether the resource is an overlay (code is generated by the package rather than by the core Pulumi codegen).
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
`boolean`
@ -699,7 +723,7 @@ An optional objectTypeSpec that describes additional inputs that mau be necessar
`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
@ -721,6 +745,14 @@ 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`
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)
switch {
case gcerrors.Code(drillError(err)) == gcerrors.NotFound:
case gcerrors.Code(err) == gcerrors.NotFound:
return nil, nil
case err != nil:
return nil, err
@ -882,12 +882,3 @@ func (b *localBackend) UpdateStackTags(ctx context.Context,
// The local backend does not currently persist tags.
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,3 +187,20 @@ 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)
if err != nil {
// History doesn't exist until a stack has been updated.
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
if gcerrors.Code(err) == gcerrors.NotFound {
return nil, nil
}
return nil, err
@ -391,7 +391,7 @@ func (b *localBackend) renameHistory(oldName tokens.QName, newName tokens.QName)
allFiles, err := listBucket(b.bucket, oldHistory)
if err != nil {
// if there's nothing there, we don't really need to do a rename.
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
if gcerrors.Code(err) == gcerrors.NotFound {
return nil
}
return err

View file

@ -902,8 +902,14 @@ func (mod *modContext) genNestedTypes(member interface{}, resourceType bool) []d
// and if it appears in an input object and/or output object.
mod.getTypes(member, tokens)
var typs []docNestedType
var sortedTokens []string
for token := range tokens {
sortedTokens = append(sortedTokens, token)
}
sort.Strings(sortedTokens)
var typs []docNestedType
for _, token := range sortedTokens {
for _, t := range mod.pkg.Types {
switch typ := t.(type) {
case *schema.ObjectType:
@ -1957,8 +1963,14 @@ func (dctx *docGenContext) generatePackage(tool string, pkg *schema.Package) (ma
glog.V(3).Infoln("generating package docs now...")
files := fs{}
for _, mod := range dctx.modules() {
if err := mod.gen(files); err != nil {
modules := []string{}
modMap := dctx.modules()
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
}
}

View file

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

View file

@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -46,6 +46,9 @@ type generator struct {
asyncInit bool
configCreated bool
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"
@ -343,14 +346,32 @@ func (g *generator) functionName(tokenArg model.Expression) (string, string) {
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.
func (g *generator) argumentTypeName(expr model.Expression, destType model.Type) string {
schemaType, ok := pcl.GetSchemaForType(destType.(model.Type))
schemaType, ok := g.toSchemaType(destType)
if !ok {
return ""
}
suffix := "Args"
if g.usedInFunctionOutputVersionInputs[schemaType] {
suffix = "InputArgs"
}
return g.argumentTypeNameWithSuffix(expr, destType, suffix)
}
schemaType = codegen.UnwrapType(schemaType)
func (g *generator) argumentTypeNameWithSuffix(expr model.Expression, destType model.Type, suffix string) string {
schemaType, ok := g.toSchemaType(destType)
if !ok {
return ""
}
objType, ok := schemaType.(*schema.ObjectType)
if !ok {
@ -382,7 +403,7 @@ func (g *generator) argumentTypeName(expr model.Expression, destType model.Type)
} else if qualifier != "" {
namespace = namespace + "." + qualifier
}
member = member + "Args"
member = member + suffix
return fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
}

View file

@ -255,6 +255,28 @@ func (g *generator) genFunctionUsings(x *model.FunctionCallExpression) []string
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) {
switch expr.Name {
case pcl.IntrinsicConvert:
@ -294,10 +316,19 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
case pcl.Invoke:
_, name := g.functionName(expr.Args[0])
g.Fprintf(w, "%s.InvokeAsync(", name)
if len(expr.Args) >= 2 {
g.Fgenf(w, "%.v", expr.Args[1])
isOut, outArgs, outArgsTy := pcl.RecognizeOutputVersionedInvoke(expr)
if isOut {
g.visitToMarkTypesUsedInFunctionOutputVersionInputs(outArgs)
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 {
g.Fgenf(w, ", %.v", expr.Args[2])
}
@ -446,7 +477,18 @@ func (g *generator) genObjectConsExpression(w io.Writer, expr *model.ObjectConsE
return
}
typeName := g.argumentTypeName(expr, destType)
destTypeName := 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 != "" {
g.Fgenf(w, "new %s", typeName)
g.Fgenf(w, "\n%s{\n", g.Indent)

View file

@ -114,6 +114,9 @@ type pkgContext struct {
// Determines if we should emit type registration code
disableInputTypeRegistrations bool
// Determines if we should emit object defaults code
disableObjectDefaults bool
}
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
@ -269,6 +272,7 @@ func rawResourceName(r *schema.Resource) string {
return tokenToName(r.Token)
}
// If `nil` is a valid value of type `t`.
func isNilType(t schema.Type) bool {
switch t := t.(type) {
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
@ -295,23 +299,6 @@ func isNilType(t schema.Type) bool {
return false
}
// The default value for a Pulumi primitive type.
func primitiveNilValue(t schema.Type) string {
contract.Assert(schema.IsPrimitiveType(t))
switch t {
case schema.BoolType:
return "false"
case schema.IntType:
return "0"
case schema.NumberType:
return "0.0"
case schema.StringType:
return "\"\""
default:
return "nil"
}
}
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
switch t := codegen.SimplifyInputUnion(t).(type) {
case *schema.OptionalType:
@ -513,7 +500,12 @@ func (pkg *pkgContext) typeStringImpl(t schema.Type, argsType bool) string {
}
func (pkg *pkgContext) typeString(t schema.Type) string {
return pkg.typeStringImpl(t, false)
s := pkg.typeStringImpl(t, false)
if s == "pulumi." {
return "pulumi.Any"
}
return s
}
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
@ -571,6 +563,10 @@ func (pkg *pkgContext) resolveObjectType(t *schema.ObjectType) string {
}
return name
}
return pkg.contextForExternalReferenceType(t).typeString(t)
}
func (pkg *pkgContext) contextForExternalReferenceType(t *schema.ObjectType) *pkgContext {
extPkg := t.Package
var goInfo GoPackageInfo
@ -584,7 +580,7 @@ func (pkg *pkgContext) resolveObjectType(t *schema.ObjectType) string {
pkgImportAliases: goInfo.PackageImportAliases,
modToPkg: goInfo.ModuleToPackage,
}
return extPkgCtx.typeString(t)
return extPkgCtx
}
func (pkg *pkgContext) outputType(t schema.Type) string {
@ -629,6 +625,9 @@ func (pkg *pkgContext) outputType(t schema.Type) string {
}
// TODO(pdg): union types
return "pulumi.AnyOutput"
case *schema.InputType:
// We can't make output types for input types. We instead strip the input and try again.
return pkg.outputType(t.ElementType)
default:
switch t {
case schema.BoolType:
@ -780,16 +779,14 @@ type genInputImplementationArgs struct {
elementType string
ptrMethods bool
toOutputMethods bool
resourceType bool
}
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods, resourceType bool) {
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods bool) {
genInputImplementationWithArgs(w, genInputImplementationArgs{
name: name,
receiverType: receiverType,
elementType: elementType,
ptrMethods: ptrMethods,
resourceType: resourceType,
toOutputMethods: true,
})
}
@ -798,14 +795,9 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
name := genArgs.name
receiverType := genArgs.receiverType
elementType := genArgs.elementType
resourceType := genArgs.resourceType
fmt.Fprintf(w, "func (%s) ElementType() reflect.Type {\n", receiverType)
if resourceType {
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
} else {
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
}
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
fmt.Fprintf(w, "}\n\n")
if genArgs.toOutputMethods {
@ -833,15 +825,11 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
}
}
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resourceType bool) {
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
fmt.Fprintf(w, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\n", baseName)
if resourceType {
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
} else {
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
}
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
fmt.Fprintf(w, "}\n\n")
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
@ -865,8 +853,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resour
}
}
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Array", "[]"+elementType, false, resourceType)
func genArrayOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Array", "[]"+elementType, false)
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", baseName)
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", elementType)
@ -875,8 +863,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool
fmt.Fprintf(w, "}\n\n")
}
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Map", "map[string]"+elementType, false, resourceType)
func genMapOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", baseName)
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s{\n", elementType)
@ -885,8 +873,8 @@ func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool)
fmt.Fprintf(w, "}\n\n")
}
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
func genPtrOutput(w io.Writer, baseName, elementType string) {
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
fmt.Fprintf(w, "func (o %[1]sPtrOutput) Elem() %[1]sOutput {\n", baseName)
fmt.Fprintf(w, "\treturn o.ApplyT(func(v *%[1]s) %[1]s {\n", baseName)
@ -952,7 +940,7 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
fmt.Fprintf(w, "type %[1]sArray []%[1]s\n\n", name)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
}
// Generate the map input.
@ -961,24 +949,24 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]s\n\n", name)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
}
// Generate the array output
if details.arrayElement {
genArrayOutput(w, name, name, false)
genArrayOutput(w, name, name)
}
// Generate the map output.
if details.mapElement {
genMapOutput(w, name, name, false)
genMapOutput(w, name, name)
}
return nil
}
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
genOutputType(w, name, name, true, false)
genOutputType(w, name, name, true)
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[3]sOutput {\n", name, asFuncName, elementArgsType)
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
@ -1001,7 +989,7 @@ func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, el
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
fmt.Fprint(w, "}\n\n")
genPtrOutput(w, name, name, false)
genPtrOutput(w, name, name)
fmt.Fprintf(w, "func (o %[1]sPtrOutput) To%[2]sPtrOutput() %[3]sPtrOutput {\n", name, asFuncName, elementArgsType)
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
@ -1103,6 +1091,27 @@ func (pkg *pkgContext) genEnumInputFuncs(w io.Writer, typeName string, enum *sch
fmt.Fprintln(w)
}
func (pkg *pkgContext) assignProperty(w io.Writer, p *schema.Property, object, value string, indirectAssign bool) {
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
switch codegen.UnwrapType(p.Type).(type) {
case *schema.EnumType:
t = ""
}
if codegen.IsNOptionalInput(p.Type) {
if t != "" {
value = fmt.Sprintf("%s(%s)", t, value)
}
fmt.Fprintf(w, "\targs.%s = %s\n", Title(p.Name), value)
} else if indirectAssign {
tmpName := camel(p.Name) + "_"
fmt.Fprintf(w, "%s := %s\n", tmpName, value)
fmt.Fprintf(w, "%s.%s = &%s\n", object, Title(p.Name), tmpName)
} else {
fmt.Fprintf(w, "%s.%s = %s\n", object, Title(p.Name), value)
}
}
func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessage string,
properties []*schema.Property) {
@ -1115,6 +1124,66 @@ func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessa
fmt.Fprintf(w, "}\n\n")
}
func (pkg *pkgContext) genPlainObjectDefaultFunc(w io.Writer, name string,
properties []*schema.Property) error {
defaults := []*schema.Property{}
for _, p := range properties {
if p.DefaultValue != nil || codegen.IsProvideDefaultsFuncRequired(p.Type) {
defaults = append(defaults, p)
}
}
// There are no defaults, so we don't need to generate a defaults function.
if len(defaults) == 0 {
return nil
}
printComment(w, fmt.Sprintf("%s sets the appropriate defaults for %s", ProvideDefaultsMethodName, name), false)
fmt.Fprintf(w, "func (val *%[1]s) %[2]s() *%[1]s {\n", name, ProvideDefaultsMethodName)
fmt.Fprint(w, "if val == nil {\n return nil\n}\n")
fmt.Fprint(w, "tmp := *val\n")
for _, p := range defaults {
if p.DefaultValue != nil {
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
if err != nil {
return err
}
pkg.needsUtils = true
fmt.Fprintf(w, "if isZero(tmp.%s) {\n", Title(p.Name))
pkg.assignProperty(w, p, "tmp", dv, !p.IsRequired())
fmt.Fprintf(w, "}\n")
} else if funcName := pkg.provideDefaultsFuncName(p.Type); funcName != "" {
var member string
if codegen.IsNOptionalInput(p.Type) {
f := fmt.Sprintf("func(v %[1]s) %[1]s { return v.%[2]s*() }", name, funcName)
member = fmt.Sprintf("tmp.%[1]s.ApplyT(%[2]s)\n", Title(p.Name), f)
} else {
member = fmt.Sprintf("tmp.%[1]s.%[2]s()\n", Title(p.Name), funcName)
}
sigil := ""
if p.IsRequired() {
sigil = "*"
}
pkg.assignProperty(w, p, "tmp", sigil+member, false)
} else {
panic(fmt.Sprintf("Property %s[%s] should not be in the default list", p.Name, p.Type.String()))
}
}
fmt.Fprintf(w, "return &tmp\n}\n")
return nil
}
// The name of the method used to instantiate defaults.
const ProvideDefaultsMethodName = "Defaults"
func (pkg *pkgContext) provideDefaultsFuncName(typ schema.Type) string {
if !codegen.IsProvideDefaultsFuncRequired(typ) {
return ""
}
return ProvideDefaultsMethodName
}
func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details *typeDetails) {
contract.Assert(t.IsInputShape())
@ -1125,7 +1194,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
pkg.genInputArgsStruct(w, name+"Args", t)
genInputImplementation(w, name, name+"Args", name, details.ptrElement, false)
genInputImplementation(w, name, name+"Args", name, details.ptrElement)
// Generate the pointer input.
if details.ptrElement {
@ -1139,7 +1208,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
fmt.Fprintf(w, "}\n\n")
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false)
}
// Generate the array input.
@ -1148,7 +1217,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
}
// Generate the map input.
@ -1157,7 +1226,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
}
}
@ -1196,7 +1265,6 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
name, /* baseName */
name, /* elementType */
details.ptrElement, /* ptrMethods */
false, /* resourceType */
)
for _, p := range t.Properties {
@ -1215,7 +1283,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
}
if details.ptrElement {
genPtrOutput(w, name, name, false)
genPtrOutput(w, name, name)
for _, p := range t.Properties {
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
@ -1248,11 +1316,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
}
if details.arrayElement {
genArrayOutput(w, name, name, false)
genArrayOutput(w, name, name)
}
if details.mapElement {
genMapOutput(w, name, name, false)
genMapOutput(w, name, name)
}
}
@ -1306,6 +1374,11 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
return "", err
}
val = v
switch t.(type) {
case *schema.EnumType:
typeName := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(t)), "Input")
val = fmt.Sprintf("%s(%s)", typeName, val)
}
}
if len(dv.Environment) > 0 {
@ -1389,6 +1462,8 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
fmt.Fprintf(w, "\t}\n\n")
// Produce the inputs.
// Check all required inputs are present
for _, p := range r.InputProperties {
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
@ -1397,26 +1472,8 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
}
}
assign := func(p *schema.Property, value string, indentation int) {
ind := strings.Repeat("\t", indentation)
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
switch codegen.UnwrapType(p.Type).(type) {
case *schema.EnumType:
t = strings.TrimSuffix(t, "Ptr")
}
if t == "pulumi." {
t = "pulumi.Any"
}
if codegen.IsNOptionalInput(p.Type) {
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, value)
} else if isNilType(p.Type) {
tmpName := camel(p.Name) + "_"
fmt.Fprintf(w, "%s%s := %s\n", ind, tmpName, value)
fmt.Fprintf(w, "%sargs.%s = &%s\n", ind, Title(p.Name), tmpName)
} else {
fmt.Fprintf(w, "%sargs.%s = %s\n", ind, Title(p.Name), value)
}
assign := func(p *schema.Property, value string) {
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
}
for _, p := range r.InputProperties {
@ -1425,19 +1482,51 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
if err != nil {
return err
}
assign(p, v, 1)
assign(p, v)
} else if p.DefaultValue != nil {
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
if err != nil {
return err
}
defaultComp := "nil"
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
defaultComp = primitiveNilValue(p.Type)
}
fmt.Fprintf(w, "\tif args.%s == %s {\n", Title(p.Name), defaultComp)
assign(p, v, 2)
pkg.needsUtils = true
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
assign(p, dv)
fmt.Fprintf(w, "\t}\n")
} else if name := pkg.provideDefaultsFuncName(p.Type); name != "" && !pkg.disableObjectDefaults {
var value string
var needsNilCheck bool
if codegen.IsNOptionalInput(p.Type) {
innerFuncType := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(p.Type)), "Args")
applyName := fmt.Sprintf("%sApplier", camel(p.Name))
fmt.Fprintf(w, "%[3]s := func(v %[1]s) *%[1]s { return v.%[2]s() }\n", innerFuncType, name, applyName)
outputValue := pkg.convertToOutput(fmt.Sprintf("args.%s", Title(p.Name)), p.Type)
outputType := pkg.typeString(p.Type)
if strings.HasSuffix(outputType, "Input") {
outputType = strings.TrimSuffix(outputType, "Input") + "Output"
}
// Because applies return pointers, we need to convert to PtrOutput and then call .Elem().
var tail string
if !strings.HasSuffix(outputType, "PtrOutput") {
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
tail = ".Elem()"
}
needsNilCheck = !p.IsRequired()
value = fmt.Sprintf("%s.ApplyT(%s).(%s)%s", outputValue, applyName, outputType, tail)
} else {
value = fmt.Sprintf("args.%[1]s.%[2]s()", Title(p.Name), name)
}
v := func() {
fmt.Fprintf(w, "args.%[1]s = %s\n", Title(p.Name), value)
}
if needsNilCheck {
fmt.Fprintf(w, "if args.%s != nil {\n", Title(p.Name))
v()
fmt.Fprint(w, "}\n")
} else {
v()
}
}
}
@ -1704,42 +1793,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
fmt.Fprintf(w, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
fmt.Fprintf(w, "}\n\n")
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, true)
genInputImplementation(w, name, "*"+name, "*"+name, false)
if generateResourceContainerTypes {
// Emit the resource pointer input type.
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
fmt.Fprintf(w, "\tpulumi.Input\n\n")
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "}\n\n")
ptrTypeName := camel(name) + "PtrType"
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
if generateResourceContainerTypes && !r.IsProvider {
// Generate the resource array input.
pkg.genInputInterface(w, name+"Array")
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false)
if !r.IsProvider {
// Generate the resource array input.
pkg.genInputInterface(w, name+"Array")
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false, false)
// Generate the resource map input.
pkg.genInputInterface(w, name+"Map")
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false, false)
}
// Generate the resource map input.
pkg.genInputInterface(w, name+"Map")
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false)
}
// Emit the resource output type.
genOutputType(w, name, name, generateResourceContainerTypes, true)
genOutputType(w, name, "*"+name, false)
if generateResourceContainerTypes {
genPtrOutput(w, name, name, true)
if !r.IsProvider {
genArrayOutput(w, name, name, true)
genMapOutput(w, name, name, true)
}
if generateResourceContainerTypes && !r.IsProvider {
genArrayOutput(w, name, "*"+name)
genMapOutput(w, name, "*"+name)
}
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
@ -1747,6 +1820,30 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
return nil
}
// Takes an expression and type, and returns a string that converts that expression to an Output type.
//
// Examples:
// ("bar", Foo of ObjectType) => "bar.ToFooOutput()"
// ("id", FooOutput) => "id"
// ("ptr", FooInput of ObjectType) => "ptr.ToFooPtrOutput().Elem()"
func (pkg *pkgContext) convertToOutput(expr string, typ schema.Type) string {
elemConversion := ""
switch typ.(type) {
case *schema.OptionalType:
elemConversion = ".Elem()"
}
outputType := pkg.outputType(typ)
// Remove any element before the last .
outputType = outputType[strings.LastIndex(outputType, ".")+1:]
if strings.HasSuffix(outputType, "ArgsOutput") {
outputType = strings.TrimSuffix(outputType, "ArgsOutput") + "Output"
}
if elemConversion != "" {
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
}
return fmt.Sprintf("%s.To%s()%s", expr, outputType, elemConversion)
}
func NeedsGoOutputVersion(f *schema.Function) bool {
fPkg := f.Package
@ -1764,7 +1861,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
return f.NeedsOutputVersion()
}
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
importsAndAliases := map[string]string{}
pkg.getImports(f, importsAndAliases)
buffer := &bytes.Buffer{}
@ -1775,12 +1872,14 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
}
pkg.genHeader(buffer, imports, importsAndAliases)
pkg.genFunction(buffer, f)
if err := pkg.genFunction(buffer, f); err != nil {
return "", err
}
pkg.genFunctionOutputVersion(buffer, f)
return buffer.String()
return buffer.String(), nil
}
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
name := pkg.functionName(f)
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
@ -1801,6 +1900,8 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
var inputsVar string
if f.Inputs == nil {
inputsVar = "nil"
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
inputsVar = "args.Defaults()"
} else {
inputsVar = "args"
}
@ -1824,19 +1925,38 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
fmt.Fprintf(w, "\t}\n")
// Return the result.
fmt.Fprintf(w, "\treturn &rv, nil\n")
var retValue string
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
retValue = "rv.Defaults()"
} else {
retValue = "&rv"
}
fmt.Fprintf(w, "\treturn %s, nil\n", retValue)
}
fmt.Fprintf(w, "}\n")
// If there are argument and/or return types, emit them.
if f.Inputs != nil {
fmt.Fprintf(w, "\n")
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
fnInputsName := pkg.functionArgsTypeName(f)
pkg.genPlainType(w, fnInputsName, f.Inputs.Comment, "", f.Inputs.Properties)
if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
if err := pkg.genPlainObjectDefaultFunc(w, fnInputsName, f.Inputs.Properties); err != nil {
return err
}
}
}
if f.Outputs != nil {
fmt.Fprintf(w, "\n")
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
fnOutputsName := pkg.functionResultTypeName(f)
pkg.genPlainType(w, fnOutputsName, f.Outputs.Comment, "", f.Outputs.Properties)
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
if err := pkg.genPlainObjectDefaultFunc(w, fnOutputsName, f.Outputs.Properties); err != nil {
return err
}
}
}
return nil
}
func (pkg *pkgContext) functionName(f *schema.Function) string {
@ -2015,16 +2135,24 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
}
}
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) error {
contract.Assert(!obj.IsInputShape())
if obj.IsOverlay {
// This type is generated by the provider, so no further action is required.
return
return nil
}
plainName := pkg.tokenToType(obj.Token)
pkg.genPlainType(w, plainName, obj.Comment, "", obj.Properties)
if !pkg.disableObjectDefaults {
if err := pkg.genPlainObjectDefaultFunc(w, plainName, obj.Properties); err != nil {
return err
}
}
pkg.genPlainType(w, pkg.tokenToType(obj.Token), obj.Comment, "", obj.Properties)
pkg.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
return nil
}
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
@ -2096,16 +2224,16 @@ func (pkg *pkgContext) genNestedCollectionTypes(w io.Writer, types map[string]ma
names = append(names, name)
if strings.HasSuffix(name, "Array") {
fmt.Fprintf(w, "type %s []%sInput\n\n", name, elementTypeName)
genInputImplementation(w, name, name, elementTypeName, false, false)
genInputImplementation(w, name, name, elementTypeName, false)
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName, false)
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName)
}
if strings.HasSuffix(name, "Map") {
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
genInputImplementation(w, name, name, elementTypeName, false, false)
genInputImplementation(w, name, name, elementTypeName, false)
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName, false)
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName)
}
pkg.genInputInterface(w, name)
}
@ -2232,18 +2360,13 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
fmt.Fprintf(w,
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
name)
if generateResourceContainerTypes {
if generateResourceContainerTypes && !r.IsProvider {
fmt.Fprintf(w,
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\n",
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
name)
fmt.Fprintf(w,
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
name)
if !r.IsProvider {
fmt.Fprintf(w,
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
name)
fmt.Fprintf(w,
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
name)
}
}
}
// Register all output types
@ -2258,12 +2381,9 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
}
}
if generateResourceContainerTypes {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
if !r.IsProvider {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
}
if generateResourceContainerTypes && !r.IsProvider {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
}
fmt.Fprintf(w, "}\n\n")
}
@ -2666,6 +2786,7 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
packages: packages,
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
disableObjectDefaults: goInfo.DisableObjectDefaults,
}
packages[mod] = pack
}
@ -2769,8 +2890,10 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
}
populateDetailsForPropertyTypes(seenMap, typ.Properties, false)
case *schema.EnumType:
pkg := getPkgFromToken(typ.Token)
pkg.enums = append(pkg.enums, typ)
if !typ.IsOverlay {
pkg := getPkgFromToken(typ.Token)
pkg.enums = append(pkg.enums, typ)
}
}
}
@ -2987,8 +3110,10 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
pkg.functions = append(pkg.functions, f)
name := tokenToName(f.Token)
originalName := name
if pkg.names.Has(name) {
if pkg.names.Has(name) ||
pkg.names.Has(name+"Args") ||
pkg.names.Has(name+"Result") {
switch {
case strings.HasPrefix(name, "New"):
name = "Create" + name[3:]
@ -3001,15 +3126,9 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
if f.Inputs != nil {
pkg.names.Add(name + "Args")
if originalName != name {
pkg.renamed[originalName+"Args"] = name + "Args"
}
}
if f.Outputs != nil {
pkg.names.Add(name + "Result")
if originalName != name {
pkg.renamed[originalName+"Result"] = name + "Result"
}
}
}
@ -3198,7 +3317,10 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
}
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
code := pkg.genFunctionCodeFile(f)
code, err := pkg.genFunctionCodeFile(f)
if err != nil {
return nil, err
}
setFile(fileName, code)
}
@ -3238,7 +3360,9 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
for _, t := range pkg.types {
pkg.genType(buffer, t)
if err := pkg.genType(buffer, t); err != nil {
return nil, err
}
delete(knownTypes, t)
}
@ -3374,4 +3498,12 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %%s", pkgPath)
}
// isZero is a null safe check for if a value is it's types zero value.
func isZero(v interface{}) bool {
if v == nil {
return true
}
return reflect.ValueOf(v).IsZero()
}
`

View file

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

View file

@ -244,9 +244,7 @@ func (g *generator) collectImports(
}
pulumiImports.Add(g.getPulumiImport(pkg, vPath, mod))
} else if call.Name == pcl.IntrinsicConvert {
if schemaType, ok := pcl.GetSchemaForType(call.Type()); ok {
g.collectTypeImports(program, schemaType, pulumiImports)
}
g.collectConvertImports(program, call, pulumiImports)
}
// Checking to see if this function call deserves its own dedicated helper method in the preamble
@ -277,6 +275,30 @@ func (g *generator) collectImports(
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) {
for _, p := range program.Packages() {
if p.Name == pkg {
@ -614,11 +636,17 @@ func (g *generator) genLocalVariable(w io.Writer, v *pcl.LocalVariable) {
case *model.FunctionCallExpression:
switch expr.Name {
case pcl.Invoke:
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")
// OutputVersionedInvoke does not return an error
noError, _, _ := pcl.RecognizeOutputVersionedInvoke(expr)
if noError {
g.Fgenf(w, "%s %s %.3v;\n", name, assignment, expr)
} else {
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":
g.Fgenf(w, "%s := %.3v;\n", name, expr)
}

View file

@ -195,7 +195,18 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
if module == "" {
module = pkg
}
name := fmt.Sprintf("%s.%s", module, fn)
isOut, outArgs, outArgsType := pcl.RecognizeOutputVersionedInvoke(expr)
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 := ""
var buf bytes.Buffer
@ -205,9 +216,6 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
g.Fgenf(&buf, ", nil")
}
optionsBag = buf.String()
g.Fgenf(w, "%s(ctx, ", name)
g.Fgenf(w, "%.v", expr.Args[1])
g.Fgenf(w, "%v)", optionsBag)
case "join":
g.Fgenf(w, "strings.Join(%v, %v)", expr.Args[1], expr.Args[0])
@ -246,6 +254,32 @@ 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) {
g.Fgenf(w, "%.20v[%.v]", expr.Collection, expr.Key)
}
@ -316,15 +350,10 @@ func (g *generator) genObjectConsExpression(
w io.Writer,
expr *model.ObjectConsExpression,
destType model.Type,
isInput bool,
) {
if len(expr.Items) == 0 {
g.Fgenf(w, "nil")
return
}
isInput bool) {
var temps []interface{}
isInput = isInput || isInputty(destType)
typeName := g.argumentTypeName(expr, destType, isInput)
if schemaType, ok := pcl.GetSchemaForType(destType); ok {
if obj, ok := codegen.UnwrapType(schemaType).(*schema.ObjectType); ok {
@ -334,6 +363,21 @@ 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?
// if strings.HasSuffix(typeName, "Args") {
// isInput = true
@ -360,7 +404,7 @@ func (g *generator) genObjectConsExpression(
}
g.genTemps(w, temps)
if isMap || !strings.HasSuffix(typeName, "Args") {
if isMap || !strings.HasSuffix(typeName, "Args") || strings.HasSuffix(typeName, "OutputArgs") {
g.Fgenf(w, "%s", typeName)
} else {
g.Fgenf(w, "&%s", typeName)
@ -814,9 +858,15 @@ func (g *generator) genApply(w io.Writer, expr *model.FunctionCallExpression) {
isInput := false
retType := g.argumentTypeName(nil, then.Signature.ReturnType, isInput)
// TODO account for outputs in other namespaces like aws
typeAssertion := fmt.Sprintf(".(%sOutput)", retType)
if !strings.HasPrefix(retType, "pulumi.") {
typeAssertion = fmt.Sprintf(".(pulumi.%sOutput)", Title(retType))
// TODO[pulumi/pulumi#8453] incomplete pattern code below.
var typeAssertion string
if retType == "[]string" {
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 {

View file

@ -44,7 +44,9 @@ func (os *optionalSpiller) spillExpressionHelper(
case *model.FunctionCallExpression:
if x.Name == "invoke" {
// recurse into invoke args
isInvoke = true
isOutputInvoke, _, _ := pcl.RecognizeOutputVersionedInvoke(x)
// ignore output-versioned invokes as they do not need converting
isInvoke = !isOutputInvoke
_, diags := os.spillExpressionHelper(x.Args[1], x.Args[1].Type(), isInvoke)
return x, diags
}

View file

@ -60,6 +60,10 @@ type GoPackageInfo struct {
// Feature flag to disable generating input type registration. This is a
// space saving measure.
DisableInputTypeRegistrations bool `json:"disableInputTypeRegistrations,omitempty"`
// Feature flag to disable generating Pulumi object default functions. This is a
// space saving measure.
DisableObjectDefaults bool `json:"disableObjectDefaults,omitempty"`
}
// Importer implements schema.Language for Go.

View file

@ -1034,7 +1034,13 @@ func (x *FunctionCallExpression) Typecheck(typecheckOperands bool) hcl.Diagnosti
typecheckDiags := typecheckArgs(rng, x.Signature, x.Args...)
diagnostics = append(diagnostics, typecheckDiags...)
x.Signature.ReturnType = liftOperationType(x.Signature.ReturnType, x.Args...)
// Unless the function is already automatically using an
// 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
}

View file

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

View file

@ -49,6 +49,8 @@ var programTests = []programTest{
{
Name: "aws-fargate",
Description: "AWS Fargate",
// TODO[pulumi/pulumi#8440]
SkipCompile: codegen.NewStringSet("go"),
},
{
@ -123,6 +125,10 @@ var programTests = []programTest{
// TODO[pulumi/pulumi#8078]
// TODO[pulumi/pulumi#8079]
},
{
Name: "output-funcs-aws",
Description: "Output Versioned Functions",
},
}
// Checks that a generated program is correct

View file

@ -191,6 +191,23 @@ var sdkTests = []sdkTest{
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
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

View file

@ -3,7 +3,6 @@ package main
import (
"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/ecs"
"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 {
return reflect.TypeOf((*Provider)(nil))
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (i *Provider) ToProviderOutput() ProviderOutput {
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
type ProviderOutput struct{ *pulumi.OutputState }
func (ProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Provider)(nil))
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

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

View file

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

View file

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

View file

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

View file

@ -76,7 +76,7 @@ type ModuleResourceInput interface {
}
func (*ModuleResource) ElementType() reflect.Type {
return reflect.TypeOf((*ModuleResource)(nil))
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
@ -90,7 +90,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
type ModuleResourceOutput struct{ *pulumi.OutputState }
func (ModuleResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ModuleResource)(nil))
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
{
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Provider.__pulumiType, name, inputs, opts);
super(Provider.__pulumiType, name, resourceInputs, 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.
*/
constructor(name: string, args?: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (!opts.id) {
inputs["thing"] = args ? args.thing : undefined;
resourceInputs["thing"] = args ? args.thing : undefined;
} else {
inputs["thing"] = undefined /*out*/;
resourceInputs["thing"] = undefined /*out*/;
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(ModuleResource.__pulumiType, name, inputs, opts);
super(ModuleResource.__pulumiType, name, resourceInputs, opts);
}
}

View file

@ -9,6 +9,7 @@
"plant-provider/tree/v1/init.go",
"plant-provider/tree/v1/nursery.go",
"plant-provider/tree/v1/pulumiEnums.go",
"plant-provider/tree/v1/pulumiUtilities.go",
"plant-provider/tree/v1/rubberTree.go"
]
}

View file

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

View file

@ -17,6 +17,19 @@ type Container struct {
Size ContainerSize `pulumi:"size"`
}
// Defaults sets the appropriate defaults for Container
func (val *Container) Defaults() *Container {
if val == nil {
return nil
}
tmp := *val
if isZero(tmp.Brightness) {
brightness_ := ContainerBrightness(1.0)
tmp.Brightness = &brightness_
}
return &tmp
}
// ContainerInput is an input type that accepts ContainerArgs and ContainerOutput values.
// You can construct a concrete instance of `ContainerInput` via:
//

View file

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

View file

@ -83,7 +83,7 @@ type NurseryInput interface {
}
func (*Nursery) ElementType() reflect.Type {
return reflect.TypeOf((*Nursery)(nil))
return reflect.TypeOf((**Nursery)(nil)).Elem()
}
func (i *Nursery) ToNurseryOutput() NurseryOutput {
@ -97,7 +97,7 @@ func (i *Nursery) ToNurseryOutputWithContext(ctx context.Context) NurseryOutput
type NurseryOutput struct{ *pulumi.OutputState }
func (NurseryOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Nursery)(nil))
return reflect.TypeOf((**Nursery)(nil)).Elem()
}
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {

View file

@ -0,0 +1,85 @@
// *** WARNING: this file was generated by test. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package 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,16 +29,20 @@ func NewRubberTree(ctx *pulumi.Context,
return nil, errors.New("missing one or more required arguments")
}
if args.Diameter == nil {
containerApplier := func(v plantprovider.Container) *plantprovider.Container { return v.Defaults() }
if args.Container != nil {
args.Container = args.Container.ToContainerPtrOutput().Elem().ApplyT(containerApplier).(plantprovider.ContainerPtrOutput)
}
if isZero(args.Diameter) {
args.Diameter = Diameter(6.0)
}
if args.Farm == nil {
if isZero(args.Farm) {
args.Farm = pulumi.StringPtr("(unknown)")
}
if args.Size == nil {
if isZero(args.Size) {
args.Size = TreeSize("medium")
}
if args.Type == nil {
if isZero(args.Type) {
args.Type = RubberTreeVariety("Burgundy")
}
var resource RubberTree
@ -103,7 +107,7 @@ type RubberTreeInput interface {
}
func (*RubberTree) ElementType() reflect.Type {
return reflect.TypeOf((*RubberTree)(nil))
return reflect.TypeOf((**RubberTree)(nil)).Elem()
}
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
@ -117,7 +121,7 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
type RubberTreeOutput struct{ *pulumi.OutputState }
func (RubberTreeOutput) ElementType() reflect.Type {
return reflect.TypeOf((*RubberTree)(nil))
return reflect.TypeOf((**RubberTree)(nil)).Elem()
}
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
{
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Provider.__pulumiType, name, inputs, opts);
super(Provider.__pulumiType, name, resourceInputs, 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.
*/
constructor(name: string, args: NurseryArgs, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (!opts.id) {
if ((!args || args.varieties === undefined) && !opts.urn) {
throw new Error("Missing required property 'varieties'");
}
inputs["sizes"] = args ? args.sizes : undefined;
inputs["varieties"] = args ? args.varieties : undefined;
resourceInputs["sizes"] = args ? args.sizes : undefined;
resourceInputs["varieties"] = args ? args.varieties : undefined;
} else {
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Nursery.__pulumiType, name, inputs, opts);
super(Nursery.__pulumiType, name, resourceInputs, opts);
}
}

View file

@ -48,11 +48,11 @@ export class RubberTree extends pulumi.CustomResource {
*/
constructor(name: string, args: RubberTreeArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: RubberTreeArgs | RubberTreeState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState as RubberTreeState | undefined;
inputs["farm"] = state ? state.farm : undefined;
resourceInputs["farm"] = state ? state.farm : undefined;
} else {
const args = argsOrState as RubberTreeArgs | undefined;
if ((!args || args.diameter === undefined) && !opts.urn) {
@ -61,16 +61,16 @@ export class RubberTree extends pulumi.CustomResource {
if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'");
}
inputs["container"] = args ? args.container : undefined;
inputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
inputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
inputs["size"] = (args ? args.size : undefined) ?? "medium";
inputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined;
resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
resourceInputs["size"] = (args ? args.size : undefined) ?? "medium";
resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(RubberTree.__pulumiType, name, inputs, opts);
super(RubberTree.__pulumiType, name, resourceInputs, opts);
}
}

View file

@ -4,9 +4,20 @@
import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types";
import * as utilities from "../utilities";
export interface ContainerArgs {
brightness?: pulumi.Input<enums.ContainerBrightness>;
color?: pulumi.Input<enums.ContainerColor | string>;
material?: pulumi.Input<string>;
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,10 +4,21 @@
import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs, enums } from "../types";
import * as utilities from "../utilities";
export interface Container {
brightness?: enums.ContainerBrightness;
color?: enums.ContainerColor | string;
material?: string;
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 {
return reflect.TypeOf((*Cat)(nil))
return reflect.TypeOf((**Cat)(nil)).Elem()
}
func (i *Cat) ToCatOutput() CatOutput {
@ -88,35 +88,6 @@ func (i *Cat) ToCatOutputWithContext(ctx context.Context) CatOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatOutput)
}
func (i *Cat) ToCatPtrOutput() CatPtrOutput {
return i.ToCatPtrOutputWithContext(context.Background())
}
func (i *Cat) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
}
type CatPtrInput interface {
pulumi.Input
ToCatPtrOutput() CatPtrOutput
ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput
}
type catPtrType CatArgs
func (*catPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Cat)(nil))
}
func (i *catPtrType) ToCatPtrOutput() CatPtrOutput {
return i.ToCatPtrOutputWithContext(context.Background())
}
func (i *catPtrType) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
}
// CatArrayInput is an input type that accepts CatArray and CatArrayOutput values.
// You can construct a concrete instance of `CatArrayInput` via:
//
@ -170,7 +141,7 @@ func (i CatMap) ToCatMapOutputWithContext(ctx context.Context) CatMapOutput {
type CatOutput struct{ *pulumi.OutputState }
func (CatOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Cat)(nil))
return reflect.TypeOf((**Cat)(nil)).Elem()
}
func (o CatOutput) ToCatOutput() CatOutput {
@ -181,44 +152,10 @@ func (o CatOutput) ToCatOutputWithContext(ctx context.Context) CatOutput {
return o
}
func (o CatOutput) ToCatPtrOutput() CatPtrOutput {
return o.ToCatPtrOutputWithContext(context.Background())
}
func (o CatOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Cat) *Cat {
return &v
}).(CatPtrOutput)
}
type CatPtrOutput struct{ *pulumi.OutputState }
func (CatPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Cat)(nil))
}
func (o CatPtrOutput) ToCatPtrOutput() CatPtrOutput {
return o
}
func (o CatPtrOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
return o
}
func (o CatPtrOutput) Elem() CatOutput {
return o.ApplyT(func(v *Cat) Cat {
if v != nil {
return *v
}
var ret Cat
return ret
}).(CatOutput)
}
type CatArrayOutput struct{ *pulumi.OutputState }
func (CatArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Cat)(nil))
return reflect.TypeOf((*[]*Cat)(nil)).Elem()
}
func (o CatArrayOutput) ToCatArrayOutput() CatArrayOutput {
@ -230,15 +167,15 @@ func (o CatArrayOutput) ToCatArrayOutputWithContext(ctx context.Context) CatArra
}
func (o CatArrayOutput) Index(i pulumi.IntInput) CatOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Cat {
return vs[0].([]Cat)[vs[1].(int)]
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Cat {
return vs[0].([]*Cat)[vs[1].(int)]
}).(CatOutput)
}
type CatMapOutput struct{ *pulumi.OutputState }
func (CatMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Cat)(nil))
return reflect.TypeOf((*map[string]*Cat)(nil)).Elem()
}
func (o CatMapOutput) ToCatMapOutput() CatMapOutput {
@ -250,18 +187,16 @@ func (o CatMapOutput) ToCatMapOutputWithContext(ctx context.Context) CatMapOutpu
}
func (o CatMapOutput) MapIndex(k pulumi.StringInput) CatOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Cat {
return vs[0].(map[string]Cat)[vs[1].(string)]
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Cat {
return vs[0].(map[string]*Cat)[vs[1].(string)]
}).(CatOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*CatInput)(nil)).Elem(), &Cat{})
pulumi.RegisterInputType(reflect.TypeOf((*CatPtrInput)(nil)).Elem(), &Cat{})
pulumi.RegisterInputType(reflect.TypeOf((*CatArrayInput)(nil)).Elem(), CatArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CatMapInput)(nil)).Elem(), CatMap{})
pulumi.RegisterOutputType(CatOutput{})
pulumi.RegisterOutputType(CatPtrOutput{})
pulumi.RegisterOutputType(CatArrayOutput{})
pulumi.RegisterOutputType(CatMapOutput{})
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
{
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Provider.__pulumiType, name, inputs, opts);
super(Provider.__pulumiType, name, resourceInputs, 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.
*/
constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (!opts.id) {
inputs["bar"] = undefined /*out*/;
resourceInputs["bar"] = undefined /*out*/;
} else {
inputs["bar"] = undefined /*out*/;
resourceInputs["bar"] = undefined /*out*/;
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Resource.__pulumiType, name, inputs, opts);
super(Resource.__pulumiType, name, resourceInputs, 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.
*/
constructor(name: string, args?: ResourceInputArgs, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (!opts.id) {
inputs["bar"] = undefined /*out*/;
resourceInputs["bar"] = undefined /*out*/;
} else {
inputs["bar"] = undefined /*out*/;
resourceInputs["bar"] = undefined /*out*/;
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(ResourceInput.__pulumiType, name, inputs, opts);
super(ResourceInput.__pulumiType, name, resourceInputs, opts);
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,57 @@
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

@ -0,0 +1,63 @@
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

@ -0,0 +1,32 @@
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

@ -0,0 +1,36 @@
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

@ -0,0 +1,25 @@
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 {
return reflect.TypeOf((*Provider)(nil))
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (i *Provider) ToProviderOutput() ProviderOutput {
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
type ProviderOutput struct{ *pulumi.OutputState }
func (ProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Provider)(nil))
return reflect.TypeOf((**Provider)(nil)).Elem()
}
func (o ProviderOutput) ToProviderOutput() ProviderOutput {

View file

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

View file

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

View file

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

View file

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

View file

@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource {
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
{
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(Provider.__pulumiType, name, inputs, opts);
super(Provider.__pulumiType, name, resourceInputs, 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) {
if args.Token == "mypkg::listStorageAccountKeys" {
switch args.Token {
case "mypkg::listStorageAccountKeys":
targs := mypkg.ListStorageAccountKeysArgs{}
for k, v := range args.Args {
switch k {
@ -72,12 +72,11 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
"keys": result.Keys,
}
return resource.NewPropertyMapFromMap(outputs), nil
}
if args.Token == "mypkg::funcWithDefaultValue" ||
args.Token == "mypkg::funcWithAllOptionalInputs" ||
args.Token == "mypkg::funcWithListParam" ||
args.Token == "mypkg::funcWithDictParam" {
case "mypkg::funcWithDefaultValue",
"mypkg::funcWithAllOptionalInputs",
"mypkg::funcWithListParam",
"mypkg::funcWithDictParam":
result := mypkg.FuncWithDefaultValueResult{
R: fmt.Sprintf("%v", args.Args),
}
@ -85,9 +84,8 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
"r": result.R,
}
return resource.NewPropertyMapFromMap(outputs), nil
}
if args.Token == "mypkg::getIntegrationRuntimeObjectMetadatum" {
case "mypkg::getIntegrationRuntimeObjectMetadatum":
targs := mypkg.GetIntegrationRuntimeObjectMetadatumArgs{}
for k, v := range args.Args {
switch k {
@ -151,16 +149,13 @@ func TestListStorageAccountKeysOutput(t *testing.T) {
})
}
// TODO[pulumi/pulumi#7811]: it seems that default values are not
// supported by Go codegen yet, hence we do not observe "B" populated
// to default at all here.
func TestFuncWithDefaultValueOutput(t *testing.T) {
pulumiTest(t, func(ctx *pulumi.Context) error {
output := mypkg.FuncWithDefaultValueOutput(ctx, mypkg.FuncWithDefaultValueOutputArgs{
A: pulumi.String("my-a"),
})
r := waitOut(t, output.R())
assert.Equal(t, "map[a:{my-a}]", r)
assert.Equal(t, "map[a:{my-a} b:{b-default}]", r)
return nil
})
}

View file

@ -13,7 +13,7 @@ import (
// Check codegen of functions with default values.
func FuncWithDefaultValue(ctx *pulumi.Context, args *FuncWithDefaultValueArgs, opts ...pulumi.InvokeOption) (*FuncWithDefaultValueResult, error) {
var rv FuncWithDefaultValueResult
err := ctx.Invoke("mypkg::funcWithDefaultValue", args, &rv, opts...)
err := ctx.Invoke("mypkg::funcWithDefaultValue", args.Defaults(), &rv, opts...)
if err != nil {
return nil, err
}
@ -25,6 +25,19 @@ type FuncWithDefaultValueArgs struct {
B *string `pulumi:"b"`
}
// Defaults sets the appropriate defaults for FuncWithDefaultValueArgs
func (val *FuncWithDefaultValueArgs) Defaults() *FuncWithDefaultValueArgs {
if val == nil {
return nil
}
tmp := *val
if isZero(tmp.B) {
b_ := "b-default"
tmp.B = &b_
}
return &tmp
}
type FuncWithDefaultValueResult struct {
R string `pulumi:"r"`
}

View file

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

View file

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

View file

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

View file

@ -22,53 +22,53 @@ func NewModuleResource(ctx *pulumi.Context,
return nil, errors.New("missing one or more required arguments")
}
if args.Optional_bool == nil {
if isZero(args.Optional_bool) {
args.Optional_bool = pulumi.BoolPtr(true)
}
args.Optional_const = pulumi.StringPtr("val")
if args.Optional_enum == nil {
if isZero(args.Optional_enum) {
args.Optional_enum = EnumThing(8)
}
if args.Optional_number == nil {
if isZero(args.Optional_number) {
args.Optional_number = pulumi.Float64Ptr(42.0)
}
if args.Optional_string == nil {
if isZero(args.Optional_string) {
args.Optional_string = pulumi.StringPtr("buzzer")
}
if args.Plain_optional_bool == nil {
if isZero(args.Plain_optional_bool) {
plain_optional_bool_ := true
args.Plain_optional_bool = &plain_optional_bool_
}
plain_optional_const_ := "val"
args.Plain_optional_const = &plain_optional_const_
if args.Plain_optional_number == nil {
if isZero(args.Plain_optional_number) {
plain_optional_number_ := 42.0
args.Plain_optional_number = &plain_optional_number_
}
if args.Plain_optional_string == nil {
if isZero(args.Plain_optional_string) {
plain_optional_string_ := "buzzer"
args.Plain_optional_string = &plain_optional_string_
}
if args.Plain_required_bool == false {
if isZero(args.Plain_required_bool) {
args.Plain_required_bool = true
}
args.Plain_required_const = "val"
if args.Plain_required_number == 0.0 {
if isZero(args.Plain_required_number) {
args.Plain_required_number = 42.0
}
if args.Plain_required_string == "" {
if isZero(args.Plain_required_string) {
args.Plain_required_string = "buzzer"
}
if args.Required_bool == nil {
if isZero(args.Required_bool) {
args.Required_bool = pulumi.Bool(true)
}
if args.Required_enum == nil {
if isZero(args.Required_enum) {
args.Required_enum = EnumThing(4)
}
if args.Required_number == nil {
if isZero(args.Required_number) {
args.Required_number = pulumi.Float64(42.0)
}
if args.Required_string == nil {
if isZero(args.Required_string) {
args.Required_string = pulumi.String("buzzer")
}
var resource ModuleResource
@ -155,7 +155,7 @@ type ModuleResourceInput interface {
}
func (*ModuleResource) ElementType() reflect.Type {
return reflect.TypeOf((*ModuleResource)(nil))
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
@ -169,7 +169,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
type ModuleResourceOutput struct{ *pulumi.OutputState }
func (ModuleResourceOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ModuleResource)(nil))
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
}
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {

View file

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

View file

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

View file

@ -41,7 +41,7 @@ export class ModuleResource extends pulumi.CustomResource {
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (!opts.id) {
if ((!args || args.plain_required_bool === undefined) && !opts.urn) {
@ -68,29 +68,29 @@ export class ModuleResource extends pulumi.CustomResource {
if ((!args || args.required_string === undefined) && !opts.urn) {
throw new Error("Missing required property 'required_string'");
}
inputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true;
inputs["optional_const"] = "val";
inputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8;
inputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42;
inputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer";
inputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true;
inputs["plain_optional_const"] = "val";
inputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42;
inputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer";
inputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true;
inputs["plain_required_const"] = "val";
inputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42;
inputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer";
inputs["required_bool"] = (args ? args.required_bool : undefined) ?? true;
inputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4;
inputs["required_number"] = (args ? args.required_number : undefined) ?? 42;
inputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer";
resourceInputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true;
resourceInputs["optional_const"] = "val";
resourceInputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8;
resourceInputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42;
resourceInputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer";
resourceInputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true;
resourceInputs["plain_optional_const"] = "val";
resourceInputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42;
resourceInputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer";
resourceInputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true;
resourceInputs["plain_required_const"] = "val";
resourceInputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42;
resourceInputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer";
resourceInputs["required_bool"] = (args ? args.required_bool : undefined) ?? true;
resourceInputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4;
resourceInputs["required_number"] = (args ? args.required_number : undefined) ?? 42;
resourceInputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer";
} else {
}
if (!opts.version) {
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
}
super(ModuleResource.__pulumiType, name, inputs, opts);
super(ModuleResource.__pulumiType, name, resourceInputs, opts);
}
}

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