Compare commits
2 commits
master
...
lukehoban/
Author | SHA1 | Date | |
---|---|---|---|
|
cf6076d6b0 | ||
|
ae70447a18 |
|
@ -28,8 +28,8 @@ RUN groupadd --gid $USER_GID $USER_NAME \
|
|||
|
||||
RUN mkdir -p /go/bin \
|
||||
&& chown -R $USER_NAME: /go \
|
||||
&& mkdir -p $HOME/.pulumi/bin \
|
||||
&& chown -R $USER_NAME: $HOME/.pulumi
|
||||
&& mkdir -p /opt/pulumi/bin \
|
||||
&& chown -R $USER_NAME: /opt/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=$HOME/.pulumi:$HOME/.pulumi/bin:$GOPATH/bin:/usr/local/go/bin:$PATH" >> ~/.bashrc \
|
||||
RUN echo "export PATH=/opt/pulumi:/opt/pulumi/bin:$GOPATH/bin:/usr/local/go/bin:$PATH" >> ~/.bashrc \
|
||||
&& echo "alias l='ls -aF'" >> ~/.bash_aliases \
|
||||
&& echo "alias ll='ls -ahlF'" >> ~/.bash_aliases \
|
||||
&& echo "alias ls='ls --color=auto --group-directories-first'" >> ~/.bash_aliases
|
||||
|
|
7
.github/workflows/run-docs-generation.yml
vendored
7
.github/workflows/run-docs-generation.yml
vendored
|
@ -101,13 +101,6 @@ 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}"
|
||||
|
|
|
@ -5,7 +5,7 @@ image:
|
|||
tasks:
|
||||
- before: >
|
||||
mkdir -p /workspace/opt-pulumi &&
|
||||
sudo ln -s /workspace/opt-pulumi $HOME/.pulumi
|
||||
sudo ln -s /workspace/opt-pulumi /opt/pulumi
|
||||
init: >
|
||||
make ensure &&
|
||||
make install
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FROM gitpod/workspace-full
|
||||
USER gitpod
|
||||
|
||||
ENV PATH="$HOME/.pulumi:$HOME/.pulumi/bin:$PATH"
|
||||
ENV PATH="/opt/pulumi:/opt/pulumi/bin:$PATH"
|
||||
|
||||
# Install .NET Core 3.1 SDK binaries on Ubuntu 20.04
|
||||
# Source: https://dev.to/carlos487/installing-dotnet-core-in-ubuntu-20-04-6jh
|
||||
|
|
84
CHANGELOG.md
84
CHANGELOG.md
|
@ -1,90 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
## 3.18.1 (2021-11-22)
|
||||
|
||||
### Improvements
|
||||
|
||||
- [cli] - When running `pulumi new https://github.com/name/repo`, check
|
||||
for branch `main` if branch `master` doesn't exist.
|
||||
[#8463](https://github.com/pulumi/pulumi/pull/8463)
|
||||
|
||||
- [codegen/python] - Program generator now uses `fn_output` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8433](https://github.com/pulumi/pulumi/pull/8433)
|
||||
|
||||
- [codegen/go] - Program generator now uses fnOutput forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8431](https://github.com/pulumi/pulumi/pull/8431)
|
||||
|
||||
- [codegen/dotnet] - Program generator now uses `Invoke` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8432](https://github.com/pulumi/pulumi/pull/8432)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [cli/nodejs] - Allow specifying the tsconfig file used in Pulumi.yaml.
|
||||
[#8452](https://github.com/pulumi/pulumi/pull/8452)
|
||||
|
||||
- [codegen/nodejs] - Respect default values in Pulumi object types.
|
||||
[#8400](https://github.com/pulumi/pulumi/pull/8400)
|
||||
|
||||
- [sdk/python] - Correctly handle version checking python virtual environments.
|
||||
[#8465](https://github.com/pulumi/pulumi/pull/8465)
|
||||
|
||||
- [cli] - Catch expected errors in stacks with filestate backends.
|
||||
[#8455](https://github.com/pulumi/pulumi/pull/8455)
|
||||
|
||||
- [sdk/dotnet] - Do not attempt to serialize unknown values.
|
||||
[#8475](https://github.com/pulumi/pulumi/pull/8475)
|
||||
|
||||
## 3.18.0 (2021-11-17)
|
||||
|
||||
### Improvements
|
||||
- [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
|
||||
|
|
|
@ -1,12 +1,42 @@
|
|||
### Improvements
|
||||
|
||||
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being
|
||||
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of
|
||||
a value--the implementation of `Ptr` types for resources was incorrect, making
|
||||
these types virtually unusable in practice.
|
||||
[#8449](https://github.com/pulumi/pulumi/pull/8449)
|
||||
- [sdk/nodejs] - Type optional input properties as `Input<T | undefined> | undefined` instead of
|
||||
`Input<T> | undefined`. This allows users to pass `Output<T | undefined>` for optional input
|
||||
properties.
|
||||
[#6323](https://github.com/pulumi/pulumi/pull/6323)
|
||||
|
||||
- Adds CI detector for Buildkite
|
||||
[#7933](https://github.com/pulumi/pulumi/pull/7933)
|
||||
|
||||
- [cli] - Add `--exclude-protected` flag to `pulumi destroy`.
|
||||
[#8359](https://github.com/pulumi/pulumi/pull/8359)
|
||||
|
||||
- [cli] Adding the ability to use `pulumi org set [name]` to set a default org
|
||||
to use when creating a stacks in the Pulumi Service backend or self-hosted Service
|
||||
[#8352](https://github.com/pulumi/pulumi/pull/8352)
|
||||
|
||||
- [schema] Add IsOverlay option to disable codegen for particular types
|
||||
[#8338](https://github.com/pulumi/pulumi/pull/8338)
|
||||
|
||||
- [sdk/dotnet] - Marshal output values.
|
||||
[#8316](https://github.com/pulumi/pulumi/pull/8316)
|
||||
|
||||
- [sdk/python] - Unmarshal output values in component provider.
|
||||
[#8212](https://github.com/pulumi/pulumi/pull/8212)
|
||||
|
||||
- [sdk/nodejs] - Unmarshal output values in component provider.
|
||||
[#8205](https://github.com/pulumi/pulumi/pull/8205)
|
||||
|
||||
- [sdk/nodejs] - Allow returning failures from Call in the provider without setting result outputs.
|
||||
[#8424](https://github.com/pulumi/pulumi/pull/8424)
|
||||
|
||||
- [sdk/go] - Allow specifying Call failures from the provider.
|
||||
[#8424](https://github.com/pulumi/pulumi/pull/8424)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [codegen/go] - Respect default values in Pulumi object types.
|
||||
[#8411](https://github.com/pulumi/pulumi/pull/8400)
|
||||
- [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)
|
||||
|
|
|
@ -22,7 +22,7 @@ To hack on Pulumi, you'll need to get a development environment set up. You'll w
|
|||
You can easily get all required dependencies with brew and npm
|
||||
|
||||
```bash
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl coreutils
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl
|
||||
curl https://raw.githubusercontent.com/Homebrew/homebrew-cask/0272f0d33f/Casks/dotnet-sdk.rb > dotnet-sdk.rb # v3.1.0
|
||||
brew install --HEAD -s dotnet-sdk.rb
|
||||
rm dotnet-sdk.rb
|
||||
|
@ -38,10 +38,12 @@ If you have a web browser, you can get a fully pre-configured Pulumi development
|
|||
|
||||
We use `make` as our build system, so you'll want to install that as well, if you don't have it already. We have extremely limited support for doing development on Windows (the bare minimum for us to get Windows validation of `pulumi`) so if you're on windows, we recommend that you use the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). We'd like to [make this better](https://github.com/pulumi/pulumi/issues/208) so feel free to pitch in if you can.
|
||||
|
||||
We build Pulumi in `$PULUMI_ROOT`, which defaults to `$HOME/.pulumi`. If you would like to build Pulumi in another location, you do so by setting `$PULUMI_ROOT`.
|
||||
For historical reasons (which we'd [like to address](https://github.com/pulumi/pulumi/issues/1515)) our build system requires that the folder `/opt/pulumi` exists and is writable by the current user. If you'd like, you can override this location by setting `PULUMI_ROOT` in your environment. The build is known to fail if this doesn't exist, so you'll need to create it first.
|
||||
|
||||
```bash
|
||||
export PATH=$HOME/.pulumi/bin:$PATH
|
||||
mkdir /opt/pulumi
|
||||
sudo chown <your_user_name>: /opt/pulumi
|
||||
export PATH=/opt/pulumi:/opt/pulumi/bin:$PATH
|
||||
```
|
||||
|
||||
You'll also need to make sure your maximum open file descriptor limit is set to 5000 at a minimum.
|
||||
|
@ -53,10 +55,9 @@ ulimit -n 5000
|
|||
|
||||
Across our projects, we try to use a regular set of make targets. The ones you'll care most about are:
|
||||
|
||||
1. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make dist`, which just builds and installs the Pulumi CLI
|
||||
0. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make`, which builds Pulumi and runs a quick set of tests
|
||||
1. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
2. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
|
||||
We make heavy use of integration level testing where we invoke `pulumi` to create and then delete cloud resources. This requires you to have a Pulumi account (so [sign up for free](https://pulumi.com) today if you haven't already) and login with `pulumi login`.
|
||||
|
||||
|
|
|
@ -173,8 +173,8 @@ details of the core Pulumi CLI and [programming model concepts](https://www.pulu
|
|||
|
||||
| Architecture | Build Status |
|
||||
| ------------ | ------------ |
|
||||
| Linux/macOS x64 | [![Linux x64 Build Status](https://github.com/pulumi/pulumi/actions/workflows/master.yml/badge.svg)](https://github.com/pulumi/pulumi/actions/workflows/master.yml) |
|
||||
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
|
||||
| Linux/macOS x64 | [![Linux x64 Build Status](https://travis-ci.com/pulumi/pulumi.svg?token=cTUUEgrxaTEGyecqJpDn&branch=master)](https://travis-ci.com/pulumi/pulumi) |
|
||||
| Windows x64 | [![Windows x64 Build Status](https://ci.appveyor.com/api/projects/status/uqrduw6qnoss7g4i?svg=true&branch=master)](https://ci.appveyor.com/project/pulumi/pulumi) |
|
||||
|
||||
### Languages
|
||||
|
||||
|
|
|
@ -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 `$HOME/.pulumi`.
|
||||
# unset, default to /opt/pulumi.
|
||||
ifeq ($(PULUMI_ROOT),)
|
||||
PULUMI_ROOT:=$(shell realpath "$$HOME/.pulumi")
|
||||
PULUMI_ROOT:=/opt/pulumi
|
||||
endif
|
||||
|
||||
# Use Python 3 explicitly vs expecting that `python` will resolve to a python 3
|
||||
|
@ -168,7 +168,6 @@ test_fast::
|
|||
|
||||
install::
|
||||
$(call STEP_MESSAGE)
|
||||
# Implicitly creates PULUMI_ROOT.
|
||||
@mkdir -p $(PULUMI_BIN)
|
||||
@mkdir -p $(PULUMI_NODE_MODULES)
|
||||
@mkdir -p $(PULUMI_NUGET)
|
||||
|
|
|
@ -57,14 +57,6 @@ 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.
|
||||
|
@ -167,14 +159,6 @@ The provider type for this package.
|
|||
|
||||
---
|
||||
|
||||
### `publisher`
|
||||
|
||||
The name of the person or organization that authored and published the package.
|
||||
|
||||
`string`
|
||||
|
||||
---
|
||||
|
||||
### `repository`
|
||||
|
||||
The URL at which the package's sources can be found.
|
||||
|
@ -377,14 +361,6 @@ The bag of input values for the function, if any.
|
|||
|
||||
---
|
||||
|
||||
#### `isOverlay`
|
||||
|
||||
Indicates that the implementation of the function should not be generated from the schema, and is instead provided out-of-band by the package author
|
||||
|
||||
`boolean`
|
||||
|
||||
---
|
||||
|
||||
#### `language`
|
||||
|
||||
Additional language-specific data about the function.
|
||||
|
@ -685,7 +661,7 @@ Indicates whether the resource is a component.
|
|||
|
||||
#### `isOverlay`
|
||||
|
||||
Indicates that the implementation of the resource should not be generated from the schema, and is instead provided out-of-band by the package author
|
||||
Indicates whether the resource is an overlay (code is generated by the package rather than by the core Pulumi codegen).
|
||||
|
||||
`boolean`
|
||||
|
||||
|
@ -723,7 +699,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
|
||||
|
||||
|
@ -745,14 +721,6 @@ The description of the type, if any. Interpreted as Markdown.
|
|||
|
||||
---
|
||||
|
||||
#### `isOverlay`
|
||||
|
||||
Indicates that the implementation of the type should not be generated from the schema, and is instead provided out-of-band by the package author
|
||||
|
||||
`boolean`
|
||||
|
||||
---
|
||||
|
||||
#### `language`
|
||||
|
||||
Additional language-specific data about the type.
|
||||
|
|
|
@ -323,7 +323,7 @@ func (b *localBackend) GetStack(ctx context.Context, stackRef backend.StackRefer
|
|||
snapshot, path, err := b.getStack(stackName)
|
||||
|
||||
switch {
|
||||
case gcerrors.Code(err) == gcerrors.NotFound:
|
||||
case gcerrors.Code(drillError(err)) == gcerrors.NotFound:
|
||||
return nil, nil
|
||||
case err != nil:
|
||||
return nil, err
|
||||
|
@ -882,3 +882,12 @@ 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
|
||||
}
|
||||
|
|
|
@ -187,20 +187,3 @@ func TestListStacksWithMultiplePassphrases(t *testing.T) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDrillError(t *testing.T) {
|
||||
// Login to a temp dir filestate backend
|
||||
tmpDir, err := ioutil.TempDir("", "filestatebackend")
|
||||
assert.NoError(t, err)
|
||||
b, err := New(cmdutil.Diag(), "file://"+filepath.ToSlash(tmpDir))
|
||||
assert.NoError(t, err)
|
||||
ctx := context.Background()
|
||||
|
||||
// Get a non-existent stack and expect a nil error because it won't be found.
|
||||
stackRef, err := b.ParseStackReference("dev")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v when parsing stack reference", err)
|
||||
}
|
||||
_, err = b.GetStack(ctx, stackRef)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ func (b *localBackend) getHistory(name tokens.QName, pageSize int, page int) ([]
|
|||
allFiles, err := listBucket(b.bucket, dir)
|
||||
if err != nil {
|
||||
// History doesn't exist until a stack has been updated.
|
||||
if gcerrors.Code(err) == gcerrors.NotFound {
|
||||
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, 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(err) == gcerrors.NotFound {
|
||||
if gcerrors.Code(drillError(err)) == gcerrors.NotFound {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
|
|
@ -902,14 +902,8 @@ func (mod *modContext) genNestedTypes(member interface{}, resourceType bool) []d
|
|||
// and if it appears in an input object and/or output object.
|
||||
mod.getTypes(member, tokens)
|
||||
|
||||
var sortedTokens []string
|
||||
for token := range tokens {
|
||||
sortedTokens = append(sortedTokens, token)
|
||||
}
|
||||
sort.Strings(sortedTokens)
|
||||
|
||||
var typs []docNestedType
|
||||
for _, token := range sortedTokens {
|
||||
for token := range tokens {
|
||||
for _, t := range mod.pkg.Types {
|
||||
switch typ := t.(type) {
|
||||
case *schema.ObjectType:
|
||||
|
@ -1963,14 +1957,8 @@ func (dctx *docGenContext) generatePackage(tool string, pkg *schema.Package) (ma
|
|||
|
||||
glog.V(3).Infoln("generating package docs now...")
|
||||
files := fs{}
|
||||
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 {
|
||||
for _, mod := range dctx.modules() {
|
||||
if err := mod.gen(files); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2352,10 +2352,8 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod
|
|||
mod := getModFromToken(typ.Token, pkg)
|
||||
mod.types = append(mod.types, typ)
|
||||
case *schema.EnumType:
|
||||
if !typ.IsOverlay {
|
||||
mod := getModFromToken(typ.Token, pkg)
|
||||
mod.enums = append(mod.enums, typ)
|
||||
}
|
||||
mod := getModFromToken(typ.Token, pkg)
|
||||
mod.enums = append(mod.enums, typ)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation.
|
||||
// Copyright 2016-2020, 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,9 +46,6 @@ 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"
|
||||
|
@ -346,32 +343,14 @@ 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 := g.toSchemaType(destType)
|
||||
schemaType, ok := pcl.GetSchemaForType(destType.(model.Type))
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
suffix := "Args"
|
||||
if g.usedInFunctionOutputVersionInputs[schemaType] {
|
||||
suffix = "InputArgs"
|
||||
}
|
||||
return g.argumentTypeNameWithSuffix(expr, destType, suffix)
|
||||
}
|
||||
|
||||
func (g *generator) argumentTypeNameWithSuffix(expr model.Expression, destType model.Type, suffix string) string {
|
||||
schemaType, ok := g.toSchemaType(destType)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
schemaType = codegen.UnwrapType(schemaType)
|
||||
|
||||
objType, ok := schemaType.(*schema.ObjectType)
|
||||
if !ok {
|
||||
|
@ -403,7 +382,7 @@ func (g *generator) argumentTypeNameWithSuffix(expr model.Expression, destType m
|
|||
} else if qualifier != "" {
|
||||
namespace = namespace + "." + qualifier
|
||||
}
|
||||
member = member + suffix
|
||||
member = member + "Args"
|
||||
|
||||
return fmt.Sprintf("%s%s.%s", rootNamespace, namespace, Title(member))
|
||||
}
|
||||
|
|
|
@ -255,28 +255,6 @@ func (g *generator) genFunctionUsings(x *model.FunctionCallExpression) []string
|
|||
return []string{fmt.Sprintf("%s = Pulumi.%[1]s", pkg)}
|
||||
}
|
||||
|
||||
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:
|
||||
|
@ -316,19 +294,10 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
|||
case pcl.Invoke:
|
||||
_, name := g.functionName(expr.Args[0])
|
||||
|
||||
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])
|
||||
}
|
||||
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])
|
||||
}
|
||||
|
@ -477,18 +446,7 @@ func (g *generator) genObjectConsExpression(w io.Writer, expr *model.ObjectConsE
|
|||
return
|
||||
}
|
||||
|
||||
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
|
||||
typeName := g.argumentTypeName(expr, destType)
|
||||
if typeName != "" {
|
||||
g.Fgenf(w, "new %s", typeName)
|
||||
g.Fgenf(w, "\n%s{\n", g.Indent)
|
||||
|
|
|
@ -114,9 +114,6 @@ type pkgContext struct {
|
|||
|
||||
// Determines if we should emit type registration code
|
||||
disableInputTypeRegistrations bool
|
||||
|
||||
// Determines if we should emit object defaults code
|
||||
disableObjectDefaults bool
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
|
||||
|
@ -272,7 +269,6 @@ func rawResourceName(r *schema.Resource) string {
|
|||
return tokenToName(r.Token)
|
||||
}
|
||||
|
||||
// If `nil` is a valid value of type `t`.
|
||||
func isNilType(t schema.Type) bool {
|
||||
switch t := t.(type) {
|
||||
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
|
||||
|
@ -299,6 +295,23 @@ func isNilType(t schema.Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// The default value for a Pulumi primitive type.
|
||||
func primitiveNilValue(t schema.Type) string {
|
||||
contract.Assert(schema.IsPrimitiveType(t))
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
return "false"
|
||||
case schema.IntType:
|
||||
return "0"
|
||||
case schema.NumberType:
|
||||
return "0.0"
|
||||
case schema.StringType:
|
||||
return "\"\""
|
||||
default:
|
||||
return "nil"
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
|
||||
switch t := codegen.SimplifyInputUnion(t).(type) {
|
||||
case *schema.OptionalType:
|
||||
|
@ -500,12 +513,7 @@ func (pkg *pkgContext) typeStringImpl(t schema.Type, argsType bool) string {
|
|||
}
|
||||
|
||||
func (pkg *pkgContext) typeString(t schema.Type) string {
|
||||
s := pkg.typeStringImpl(t, false)
|
||||
if s == "pulumi." {
|
||||
return "pulumi.Any"
|
||||
}
|
||||
return s
|
||||
|
||||
return pkg.typeStringImpl(t, false)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
|
||||
|
@ -563,10 +571,6 @@ 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
|
||||
|
||||
|
@ -580,7 +584,7 @@ func (pkg *pkgContext) contextForExternalReferenceType(t *schema.ObjectType) *pk
|
|||
pkgImportAliases: goInfo.PackageImportAliases,
|
||||
modToPkg: goInfo.ModuleToPackage,
|
||||
}
|
||||
return extPkgCtx
|
||||
return extPkgCtx.typeString(t)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) outputType(t schema.Type) string {
|
||||
|
@ -625,9 +629,6 @@ func (pkg *pkgContext) outputType(t schema.Type) string {
|
|||
}
|
||||
// TODO(pdg): union types
|
||||
return "pulumi.AnyOutput"
|
||||
case *schema.InputType:
|
||||
// We can't make output types for input types. We instead strip the input and try again.
|
||||
return pkg.outputType(t.ElementType)
|
||||
default:
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
|
@ -779,14 +780,16 @@ type genInputImplementationArgs struct {
|
|||
elementType string
|
||||
ptrMethods bool
|
||||
toOutputMethods bool
|
||||
resourceType bool
|
||||
}
|
||||
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods bool) {
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods, resourceType bool) {
|
||||
genInputImplementationWithArgs(w, genInputImplementationArgs{
|
||||
name: name,
|
||||
receiverType: receiverType,
|
||||
elementType: elementType,
|
||||
ptrMethods: ptrMethods,
|
||||
resourceType: resourceType,
|
||||
toOutputMethods: true,
|
||||
})
|
||||
}
|
||||
|
@ -795,9 +798,14 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
name := genArgs.name
|
||||
receiverType := genArgs.receiverType
|
||||
elementType := genArgs.elementType
|
||||
resourceType := genArgs.resourceType
|
||||
|
||||
fmt.Fprintf(w, "func (%s) ElementType() reflect.Type {\n", receiverType)
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
if genArgs.toOutputMethods {
|
||||
|
@ -825,11 +833,15 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
}
|
||||
}
|
||||
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resourceType bool) {
|
||||
fmt.Fprintf(w, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
|
||||
|
||||
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
|
||||
|
@ -853,8 +865,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false)
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", elementType)
|
||||
|
@ -863,8 +875,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string) {
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genMapOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
|
||||
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s{\n", elementType)
|
||||
|
@ -873,8 +885,8 @@ func genMapOutput(w io.Writer, baseName, elementType string) {
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) Elem() %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn o.ApplyT(func(v *%[1]s) %[1]s {\n", baseName)
|
||||
|
@ -940,7 +952,7 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -949,24 +961,24 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the array output
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name)
|
||||
genArrayOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
// Generate the map output.
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name)
|
||||
genMapOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
|
||||
genOutputType(w, name, name, true)
|
||||
genOutputType(w, name, name, true, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[3]sOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -989,7 +1001,7 @@ func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, el
|
|||
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
|
||||
fmt.Fprint(w, "}\n\n")
|
||||
|
||||
genPtrOutput(w, name, name)
|
||||
genPtrOutput(w, name, name, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) To%[2]sPtrOutput() %[3]sPtrOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -1091,27 +1103,6 @@ func (pkg *pkgContext) genEnumInputFuncs(w io.Writer, typeName string, enum *sch
|
|||
fmt.Fprintln(w)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) assignProperty(w io.Writer, p *schema.Property, object, value string, indirectAssign bool) {
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = ""
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
if t != "" {
|
||||
value = fmt.Sprintf("%s(%s)", t, value)
|
||||
}
|
||||
fmt.Fprintf(w, "\targs.%s = %s\n", Title(p.Name), value)
|
||||
} else if indirectAssign {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s := %s\n", tmpName, value)
|
||||
fmt.Fprintf(w, "%s.%s = &%s\n", object, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s.%s = %s\n", object, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessage string,
|
||||
properties []*schema.Property) {
|
||||
|
||||
|
@ -1124,66 +1115,6 @@ func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessa
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainObjectDefaultFunc(w io.Writer, name string,
|
||||
properties []*schema.Property) error {
|
||||
defaults := []*schema.Property{}
|
||||
for _, p := range properties {
|
||||
if p.DefaultValue != nil || codegen.IsProvideDefaultsFuncRequired(p.Type) {
|
||||
defaults = append(defaults, p)
|
||||
}
|
||||
}
|
||||
|
||||
// There are no defaults, so we don't need to generate a defaults function.
|
||||
if len(defaults) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
printComment(w, fmt.Sprintf("%s sets the appropriate defaults for %s", ProvideDefaultsMethodName, name), false)
|
||||
fmt.Fprintf(w, "func (val *%[1]s) %[2]s() *%[1]s {\n", name, ProvideDefaultsMethodName)
|
||||
fmt.Fprint(w, "if val == nil {\n return nil\n}\n")
|
||||
fmt.Fprint(w, "tmp := *val\n")
|
||||
for _, p := range defaults {
|
||||
if p.DefaultValue != nil {
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "if isZero(tmp.%s) {\n", Title(p.Name))
|
||||
pkg.assignProperty(w, p, "tmp", dv, !p.IsRequired())
|
||||
fmt.Fprintf(w, "}\n")
|
||||
} else if funcName := pkg.provideDefaultsFuncName(p.Type); funcName != "" {
|
||||
var member string
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
f := fmt.Sprintf("func(v %[1]s) %[1]s { return v.%[2]s*() }", name, funcName)
|
||||
member = fmt.Sprintf("tmp.%[1]s.ApplyT(%[2]s)\n", Title(p.Name), f)
|
||||
} else {
|
||||
member = fmt.Sprintf("tmp.%[1]s.%[2]s()\n", Title(p.Name), funcName)
|
||||
}
|
||||
sigil := ""
|
||||
if p.IsRequired() {
|
||||
sigil = "*"
|
||||
}
|
||||
pkg.assignProperty(w, p, "tmp", sigil+member, false)
|
||||
} else {
|
||||
panic(fmt.Sprintf("Property %s[%s] should not be in the default list", p.Name, p.Type.String()))
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "return &tmp\n}\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// The name of the method used to instantiate defaults.
|
||||
const ProvideDefaultsMethodName = "Defaults"
|
||||
|
||||
func (pkg *pkgContext) provideDefaultsFuncName(typ schema.Type) string {
|
||||
if !codegen.IsProvideDefaultsFuncRequired(typ) {
|
||||
return ""
|
||||
}
|
||||
return ProvideDefaultsMethodName
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details *typeDetails) {
|
||||
contract.Assert(t.IsInputShape())
|
||||
|
||||
|
@ -1194,7 +1125,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
pkg.genInputArgsStruct(w, name+"Args", t)
|
||||
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement)
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement, false)
|
||||
|
||||
// Generate the pointer input.
|
||||
if details.ptrElement {
|
||||
|
@ -1208,7 +1139,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the array input.
|
||||
|
@ -1217,7 +1148,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -1226,7 +1157,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1265,6 +1196,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
name, /* baseName */
|
||||
name, /* elementType */
|
||||
details.ptrElement, /* ptrMethods */
|
||||
false, /* resourceType */
|
||||
)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
|
@ -1283,7 +1215,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.ptrElement {
|
||||
genPtrOutput(w, name, name)
|
||||
genPtrOutput(w, name, name, false)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
|
||||
|
@ -1316,11 +1248,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name)
|
||||
genArrayOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name)
|
||||
genMapOutput(w, name, name, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1374,11 +1306,6 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
|
|||
return "", err
|
||||
}
|
||||
val = v
|
||||
switch t.(type) {
|
||||
case *schema.EnumType:
|
||||
typeName := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(t)), "Input")
|
||||
val = fmt.Sprintf("%s(%s)", typeName, val)
|
||||
}
|
||||
}
|
||||
|
||||
if len(dv.Environment) > 0 {
|
||||
|
@ -1462,8 +1389,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\t}\n\n")
|
||||
|
||||
// Produce the inputs.
|
||||
|
||||
// Check all required inputs are present
|
||||
for _, p := range r.InputProperties {
|
||||
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
|
||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||
|
@ -1472,8 +1397,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
}
|
||||
}
|
||||
|
||||
assign := func(p *schema.Property, value string) {
|
||||
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
|
||||
assign := func(p *schema.Property, value string, indentation int) {
|
||||
ind := strings.Repeat("\t", indentation)
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = strings.TrimSuffix(t, "Ptr")
|
||||
}
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, value)
|
||||
} else if isNilType(p.Type) {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s%s := %s\n", ind, tmpName, value)
|
||||
fmt.Fprintf(w, "%sargs.%s = &%s\n", ind, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%sargs.%s = %s\n", ind, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range r.InputProperties {
|
||||
|
@ -1482,51 +1425,19 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assign(p, v)
|
||||
assign(p, v, 1)
|
||||
} else if p.DefaultValue != nil {
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
|
||||
assign(p, dv)
|
||||
defaultComp := "nil"
|
||||
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
|
||||
defaultComp = primitiveNilValue(p.Type)
|
||||
}
|
||||
fmt.Fprintf(w, "\tif args.%s == %s {\n", Title(p.Name), defaultComp)
|
||||
assign(p, v, 2)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
} else if name := pkg.provideDefaultsFuncName(p.Type); name != "" && !pkg.disableObjectDefaults {
|
||||
var value string
|
||||
var needsNilCheck bool
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
innerFuncType := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(p.Type)), "Args")
|
||||
applyName := fmt.Sprintf("%sApplier", camel(p.Name))
|
||||
fmt.Fprintf(w, "%[3]s := func(v %[1]s) *%[1]s { return v.%[2]s() }\n", innerFuncType, name, applyName)
|
||||
|
||||
outputValue := pkg.convertToOutput(fmt.Sprintf("args.%s", Title(p.Name)), p.Type)
|
||||
outputType := pkg.typeString(p.Type)
|
||||
if strings.HasSuffix(outputType, "Input") {
|
||||
outputType = strings.TrimSuffix(outputType, "Input") + "Output"
|
||||
}
|
||||
|
||||
// Because applies return pointers, we need to convert to PtrOutput and then call .Elem().
|
||||
var tail string
|
||||
if !strings.HasSuffix(outputType, "PtrOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
tail = ".Elem()"
|
||||
}
|
||||
needsNilCheck = !p.IsRequired()
|
||||
value = fmt.Sprintf("%s.ApplyT(%s).(%s)%s", outputValue, applyName, outputType, tail)
|
||||
} else {
|
||||
value = fmt.Sprintf("args.%[1]s.%[2]s()", Title(p.Name), name)
|
||||
}
|
||||
v := func() {
|
||||
fmt.Fprintf(w, "args.%[1]s = %s\n", Title(p.Name), value)
|
||||
}
|
||||
if needsNilCheck {
|
||||
fmt.Fprintf(w, "if args.%s != nil {\n", Title(p.Name))
|
||||
v()
|
||||
fmt.Fprint(w, "}\n")
|
||||
} else {
|
||||
v()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1793,26 +1704,42 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name, "*"+name, "*"+name, false)
|
||||
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, true)
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false)
|
||||
if generateResourceContainerTypes {
|
||||
// Emit the resource pointer input type.
|
||||
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.Input\n\n")
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
ptrTypeName := camel(name) + "PtrType"
|
||||
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
|
||||
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false)
|
||||
if !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false, false)
|
||||
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
// Emit the resource output type.
|
||||
genOutputType(w, name, "*"+name, false)
|
||||
genOutputType(w, name, name, generateResourceContainerTypes, true)
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
genArrayOutput(w, name, "*"+name)
|
||||
genMapOutput(w, name, "*"+name)
|
||||
if generateResourceContainerTypes {
|
||||
genPtrOutput(w, name, name, true)
|
||||
|
||||
if !r.IsProvider {
|
||||
genArrayOutput(w, name, name, true)
|
||||
genMapOutput(w, name, name, true)
|
||||
}
|
||||
}
|
||||
|
||||
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
|
||||
|
@ -1820,30 +1747,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
return nil
|
||||
}
|
||||
|
||||
// Takes an expression and type, and returns a string that converts that expression to an Output type.
|
||||
//
|
||||
// Examples:
|
||||
// ("bar", Foo of ObjectType) => "bar.ToFooOutput()"
|
||||
// ("id", FooOutput) => "id"
|
||||
// ("ptr", FooInput of ObjectType) => "ptr.ToFooPtrOutput().Elem()"
|
||||
func (pkg *pkgContext) convertToOutput(expr string, typ schema.Type) string {
|
||||
elemConversion := ""
|
||||
switch typ.(type) {
|
||||
case *schema.OptionalType:
|
||||
elemConversion = ".Elem()"
|
||||
}
|
||||
outputType := pkg.outputType(typ)
|
||||
// Remove any element before the last .
|
||||
outputType = outputType[strings.LastIndex(outputType, ".")+1:]
|
||||
if strings.HasSuffix(outputType, "ArgsOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "ArgsOutput") + "Output"
|
||||
}
|
||||
if elemConversion != "" {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
}
|
||||
return fmt.Sprintf("%s.To%s()%s", expr, outputType, elemConversion)
|
||||
}
|
||||
|
||||
func NeedsGoOutputVersion(f *schema.Function) bool {
|
||||
fPkg := f.Package
|
||||
|
||||
|
@ -1861,7 +1764,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
|
|||
return f.NeedsOutputVersion()
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
|
||||
importsAndAliases := map[string]string{}
|
||||
pkg.getImports(f, importsAndAliases)
|
||||
buffer := &bytes.Buffer{}
|
||||
|
@ -1872,14 +1775,12 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
|||
}
|
||||
|
||||
pkg.genHeader(buffer, imports, importsAndAliases)
|
||||
if err := pkg.genFunction(buffer, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
pkg.genFunction(buffer, f)
|
||||
pkg.genFunctionOutputVersion(buffer, f)
|
||||
return buffer.String(), nil
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
|
||||
name := pkg.functionName(f)
|
||||
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
|
||||
|
||||
|
@ -1900,8 +1801,6 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
|||
var inputsVar string
|
||||
if f.Inputs == nil {
|
||||
inputsVar = "nil"
|
||||
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
inputsVar = "args.Defaults()"
|
||||
} else {
|
||||
inputsVar = "args"
|
||||
}
|
||||
|
@ -1925,38 +1824,19 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
|||
fmt.Fprintf(w, "\t}\n")
|
||||
|
||||
// Return the result.
|
||||
var retValue string
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
retValue = "rv.Defaults()"
|
||||
} else {
|
||||
retValue = "&rv"
|
||||
}
|
||||
fmt.Fprintf(w, "\treturn %s, nil\n", retValue)
|
||||
fmt.Fprintf(w, "\treturn &rv, nil\n")
|
||||
}
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// If there are argument and/or return types, emit them.
|
||||
if f.Inputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
fnInputsName := pkg.functionArgsTypeName(f)
|
||||
pkg.genPlainType(w, fnInputsName, f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnInputsName, f.Inputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
fnOutputsName := pkg.functionResultTypeName(f)
|
||||
pkg.genPlainType(w, fnOutputsName, f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnOutputsName, f.Outputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) functionName(f *schema.Function) string {
|
||||
|
@ -2135,24 +2015,16 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
|
|||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) error {
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
|
||||
contract.Assert(!obj.IsInputShape())
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
return nil
|
||||
}
|
||||
|
||||
plainName := pkg.tokenToType(obj.Token)
|
||||
pkg.genPlainType(w, plainName, obj.Comment, "", obj.Properties)
|
||||
if !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, plainName, obj.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
pkg.genPlainType(w, pkg.tokenToType(obj.Token), obj.Comment, "", obj.Properties)
|
||||
pkg.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
|
||||
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
|
||||
|
@ -2224,16 +2096,16 @@ func (pkg *pkgContext) genNestedCollectionTypes(w io.Writer, types map[string]ma
|
|||
names = append(names, name)
|
||||
if strings.HasSuffix(name, "Array") {
|
||||
fmt.Fprintf(w, "type %s []%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName)
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName, false)
|
||||
}
|
||||
|
||||
if strings.HasSuffix(name, "Map") {
|
||||
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName)
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName, false)
|
||||
}
|
||||
pkg.genInputInterface(w, name)
|
||||
}
|
||||
|
@ -2360,13 +2232,18 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
name)
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
if generateResourceContainerTypes {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
name)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Register all output types
|
||||
|
@ -2381,9 +2258,12 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
}
|
||||
}
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
if generateResourceContainerTypes {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
@ -2786,7 +2666,6 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
packages: packages,
|
||||
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
|
||||
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
|
||||
disableObjectDefaults: goInfo.DisableObjectDefaults,
|
||||
}
|
||||
packages[mod] = pack
|
||||
}
|
||||
|
@ -2890,10 +2769,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
}
|
||||
populateDetailsForPropertyTypes(seenMap, typ.Properties, false)
|
||||
case *schema.EnumType:
|
||||
if !typ.IsOverlay {
|
||||
pkg := getPkgFromToken(typ.Token)
|
||||
pkg.enums = append(pkg.enums, typ)
|
||||
}
|
||||
pkg := getPkgFromToken(typ.Token)
|
||||
pkg.enums = append(pkg.enums, typ)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3110,10 +2987,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
pkg.functions = append(pkg.functions, f)
|
||||
|
||||
name := tokenToName(f.Token)
|
||||
|
||||
if pkg.names.Has(name) ||
|
||||
pkg.names.Has(name+"Args") ||
|
||||
pkg.names.Has(name+"Result") {
|
||||
originalName := name
|
||||
if pkg.names.Has(name) {
|
||||
switch {
|
||||
case strings.HasPrefix(name, "New"):
|
||||
name = "Create" + name[3:]
|
||||
|
@ -3126,9 +3001,15 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
|
||||
if f.Inputs != nil {
|
||||
pkg.names.Add(name + "Args")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Args"] = name + "Args"
|
||||
}
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
pkg.names.Add(name + "Result")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Result"] = name + "Result"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3317,10 +3198,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
}
|
||||
|
||||
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
||||
code, err := pkg.genFunctionCodeFile(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
code := pkg.genFunctionCodeFile(f)
|
||||
setFile(fileName, code)
|
||||
}
|
||||
|
||||
|
@ -3360,9 +3238,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
|
||||
|
||||
for _, t := range pkg.types {
|
||||
if err := pkg.genType(buffer, t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkg.genType(buffer, t)
|
||||
delete(knownTypes, t)
|
||||
}
|
||||
|
||||
|
@ -3498,12 +3374,4 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %%s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
`
|
||||
|
|
|
@ -43,9 +43,7 @@ func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error
|
|||
|
||||
if len(pkg.types) > 0 {
|
||||
for _, t := range pkg.types {
|
||||
if err := pkg.genType(buffer, t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkg.genType(buffer, t)
|
||||
}
|
||||
pkg.genTypeRegistrations(buffer, pkg.types)
|
||||
}
|
||||
|
|
|
@ -244,7 +244,9 @@ func (g *generator) collectImports(
|
|||
}
|
||||
pulumiImports.Add(g.getPulumiImport(pkg, vPath, mod))
|
||||
} else if call.Name == pcl.IntrinsicConvert {
|
||||
g.collectConvertImports(program, call, pulumiImports)
|
||||
if schemaType, ok := pcl.GetSchemaForType(call.Type()); ok {
|
||||
g.collectTypeImports(program, schemaType, pulumiImports)
|
||||
}
|
||||
}
|
||||
|
||||
// Checking to see if this function call deserves its own dedicated helper method in the preamble
|
||||
|
@ -275,30 +277,6 @@ 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 {
|
||||
|
@ -636,17 +614,11 @@ func (g *generator) genLocalVariable(w io.Writer, v *pcl.LocalVariable) {
|
|||
case *model.FunctionCallExpression:
|
||||
switch expr.Name {
|
||||
case pcl.Invoke:
|
||||
// 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")
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -195,18 +195,7 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
|||
if module == "" {
|
||||
module = pkg
|
||||
}
|
||||
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])
|
||||
}
|
||||
name := fmt.Sprintf("%s.%s", module, fn)
|
||||
|
||||
optionsBag := ""
|
||||
var buf bytes.Buffer
|
||||
|
@ -216,6 +205,9 @@ 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])
|
||||
|
@ -254,32 +246,6 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
|
|||
}
|
||||
}
|
||||
|
||||
// Currently args type for output-versioned invokes are named
|
||||
// `FOutputArgs`, but this is not yet understood by `tokenToType`. Use
|
||||
// this function to compensate.
|
||||
func outputVersionFunctionArgTypeName(t model.Type) (string, error) {
|
||||
schemaType, ok := pcl.GetSchemaForType(t)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("No schema.Type type found for the given model.Type")
|
||||
}
|
||||
|
||||
objType, ok := schemaType.(*schema.ObjectType)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("Expected a schema.ObjectType, got %s", schemaType.String())
|
||||
}
|
||||
|
||||
pkg := &pkgContext{pkg: &schema.Package{Name: "main"}}
|
||||
|
||||
var ty string
|
||||
if pkg.isExternalReference(objType) {
|
||||
ty = pkg.contextForExternalReferenceType(objType).tokenToType(objType.Token)
|
||||
} else {
|
||||
ty = pkg.tokenToType(objType.Token)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%sOutputArgs", strings.TrimSuffix(ty, "Args")), nil
|
||||
}
|
||||
|
||||
func (g *generator) GenIndexExpression(w io.Writer, expr *model.IndexExpression) {
|
||||
g.Fgenf(w, "%.20v[%.v]", expr.Collection, expr.Key)
|
||||
}
|
||||
|
@ -350,10 +316,15 @@ func (g *generator) genObjectConsExpression(
|
|||
w io.Writer,
|
||||
expr *model.ObjectConsExpression,
|
||||
destType model.Type,
|
||||
isInput bool) {
|
||||
isInput bool,
|
||||
) {
|
||||
if len(expr.Items) == 0 {
|
||||
g.Fgenf(w, "nil")
|
||||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -363,21 +334,6 @@ func (g *generator) genObjectConsExpression(
|
|||
}
|
||||
}
|
||||
|
||||
g.genObjectConsExpressionWithTypeName(w, expr, destType, typeName)
|
||||
}
|
||||
|
||||
func (g *generator) genObjectConsExpressionWithTypeName(
|
||||
w io.Writer,
|
||||
expr *model.ObjectConsExpression,
|
||||
destType model.Type,
|
||||
typeName string) {
|
||||
|
||||
if len(expr.Items) == 0 {
|
||||
g.Fgenf(w, "nil")
|
||||
return
|
||||
}
|
||||
|
||||
var temps []interface{}
|
||||
// TODO: @pgavlin --- ineffectual assignment, was there some work in flight here?
|
||||
// if strings.HasSuffix(typeName, "Args") {
|
||||
// isInput = true
|
||||
|
@ -404,7 +360,7 @@ func (g *generator) genObjectConsExpressionWithTypeName(
|
|||
}
|
||||
g.genTemps(w, temps)
|
||||
|
||||
if isMap || !strings.HasSuffix(typeName, "Args") || strings.HasSuffix(typeName, "OutputArgs") {
|
||||
if isMap || !strings.HasSuffix(typeName, "Args") {
|
||||
g.Fgenf(w, "%s", typeName)
|
||||
} else {
|
||||
g.Fgenf(w, "&%s", typeName)
|
||||
|
@ -858,15 +814,9 @@ 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
|
||||
// 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))
|
||||
}
|
||||
typeAssertion := fmt.Sprintf(".(%sOutput)", retType)
|
||||
if !strings.HasPrefix(retType, "pulumi.") {
|
||||
typeAssertion = fmt.Sprintf(".(pulumi.%sOutput)", Title(retType))
|
||||
}
|
||||
|
||||
if len(applyArgs) == 1 {
|
||||
|
|
|
@ -44,9 +44,7 @@ func (os *optionalSpiller) spillExpressionHelper(
|
|||
case *model.FunctionCallExpression:
|
||||
if x.Name == "invoke" {
|
||||
// recurse into invoke args
|
||||
isOutputInvoke, _, _ := pcl.RecognizeOutputVersionedInvoke(x)
|
||||
// ignore output-versioned invokes as they do not need converting
|
||||
isInvoke = !isOutputInvoke
|
||||
isInvoke = true
|
||||
_, diags := os.spillExpressionHelper(x.Args[1], x.Args[1].Type(), isInvoke)
|
||||
return x, diags
|
||||
}
|
||||
|
|
|
@ -60,10 +60,6 @@ type GoPackageInfo struct {
|
|||
// Feature flag to disable generating input type registration. This is a
|
||||
// space saving measure.
|
||||
DisableInputTypeRegistrations bool `json:"disableInputTypeRegistrations,omitempty"`
|
||||
|
||||
// Feature flag to disable generating Pulumi object default functions. This is a
|
||||
// space saving measure.
|
||||
DisableObjectDefaults bool `json:"disableObjectDefaults,omitempty"`
|
||||
}
|
||||
|
||||
// Importer implements schema.Language for Go.
|
||||
|
|
|
@ -1034,13 +1034,7 @@ func (x *FunctionCallExpression) Typecheck(typecheckOperands bool) hcl.Diagnosti
|
|||
typecheckDiags := typecheckArgs(rng, x.Signature, x.Args...)
|
||||
diagnostics = append(diagnostics, typecheckDiags...)
|
||||
|
||||
// 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...)
|
||||
}
|
||||
x.Signature.ReturnType = liftOperationType(x.Signature.ReturnType, x.Args...)
|
||||
return diagnostics
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ func RunCommandWithOptions(
|
|||
type SchemaVersion = string
|
||||
|
||||
const (
|
||||
AwsSchema SchemaVersion = "4.26.0"
|
||||
AwsSchema SchemaVersion = "4.21.1"
|
||||
AzureNativeSchema SchemaVersion = "1.29.0"
|
||||
AzureSchema SchemaVersion = "4.18.0"
|
||||
KubernetesSchema SchemaVersion = "3.7.2"
|
||||
|
|
|
@ -49,8 +49,6 @@ var programTests = []programTest{
|
|||
{
|
||||
Name: "aws-fargate",
|
||||
Description: "AWS Fargate",
|
||||
|
||||
// TODO[pulumi/pulumi#8440]
|
||||
SkipCompile: codegen.NewStringSet("go"),
|
||||
},
|
||||
{
|
||||
|
@ -125,10 +123,6 @@ 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
|
||||
|
|
|
@ -191,23 +191,6 @@ 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
|
||||
|
|
|
@ -3,6 +3,7 @@ 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"
|
||||
|
|
6286
pkg/codegen/internal/test/testdata/aws.json
vendored
6286
pkg/codegen/internal/test/testdata/aws.json
vendored
File diff suppressed because one or more lines are too long
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ type ModuleResourceInput interface {
|
|||
}
|
||||
|
||||
func (*ModuleResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
}
|
||||
|
||||
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
@ -90,7 +90,7 @@ func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context)
|
|||
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
}
|
||||
|
||||
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["thing"] = args ? args.thing : undefined;
|
||||
inputs["thing"] = args ? args.thing : undefined;
|
||||
} else {
|
||||
resourceInputs["thing"] = undefined /*out*/;
|
||||
inputs["thing"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(ModuleResource.__pulumiType, name, resourceInputs, opts);
|
||||
super(ModuleResource.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,5 +60,5 @@ export class ModuleResource extends pulumi.CustomResource {
|
|||
* The set of arguments for constructing a ModuleResource resource.
|
||||
*/
|
||||
export interface ModuleResourceArgs {
|
||||
thing?: pulumi.Input<inputs.TopLevelArgs>;
|
||||
thing?: pulumi.Input<inputs.TopLevelArgs | undefined>;
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ import * as pulumi from "@pulumi/pulumi";
|
|||
import { input as inputs, output as outputs } from "../types";
|
||||
|
||||
export interface TopLevelArgs {
|
||||
buzz?: pulumi.Input<string>;
|
||||
buzz?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
"plant-provider/tree/v1/init.go",
|
||||
"plant-provider/tree/v1/nursery.go",
|
||||
"plant-provider/tree/v1/pulumiEnums.go",
|
||||
"plant-provider/tree/v1/pulumiUtilities.go",
|
||||
"plant-provider/tree/v1/rubberTree.go"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -17,19 +17,6 @@ type Container struct {
|
|||
Size ContainerSize `pulumi:"size"`
|
||||
}
|
||||
|
||||
// Defaults sets the appropriate defaults for Container
|
||||
func (val *Container) Defaults() *Container {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
tmp := *val
|
||||
if isZero(tmp.Brightness) {
|
||||
brightness_ := ContainerBrightness(1.0)
|
||||
tmp.Brightness = &brightness_
|
||||
}
|
||||
return &tmp
|
||||
}
|
||||
|
||||
// ContainerInput is an input type that accepts ContainerArgs and ContainerOutput values.
|
||||
// You can construct a concrete instance of `ContainerInput` via:
|
||||
//
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ type NurseryInput interface {
|
|||
}
|
||||
|
||||
func (*Nursery) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
||||
return reflect.TypeOf((*Nursery)(nil))
|
||||
}
|
||||
|
||||
func (i *Nursery) ToNurseryOutput() NurseryOutput {
|
||||
|
@ -97,7 +97,7 @@ func (i *Nursery) ToNurseryOutputWithContext(ctx context.Context) NurseryOutput
|
|||
type NurseryOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (NurseryOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Nursery)(nil)).Elem()
|
||||
return reflect.TypeOf((*Nursery)(nil))
|
||||
}
|
||||
|
||||
func (o NurseryOutput) ToNurseryOutput() NurseryOutput {
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type envParser func(v string) interface{}
|
||||
|
||||
func parseEnvBool(v string) interface{} {
|
||||
b, err := strconv.ParseBool(v)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func parseEnvInt(v string) interface{} {
|
||||
i, err := strconv.ParseInt(v, 0, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func parseEnvFloat(v string) interface{} {
|
||||
f, err := strconv.ParseFloat(v, 64)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func parseEnvStringArray(v string) interface{} {
|
||||
var result pulumi.StringArray
|
||||
for _, item := range strings.Split(v, ";") {
|
||||
result = append(result, pulumi.String(item))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
|
||||
for _, v := range vars {
|
||||
if value := os.Getenv(v); value != "" {
|
||||
if parser != nil {
|
||||
return parser(value)
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
// PkgVersion uses reflection to determine the version of the current package.
|
||||
func PkgVersion() (semver.Version, error) {
|
||||
type sentinal struct{}
|
||||
pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
|
||||
re := regexp.MustCompile("^.*/pulumi-plant/sdk(/v\\d+)?")
|
||||
if match := re.FindStringSubmatch(pkgPath); match != nil {
|
||||
vStr := match[1]
|
||||
if len(vStr) == 0 { // If the version capture group was empty, default to v1.
|
||||
return semver.Version{Major: 1}, nil
|
||||
}
|
||||
return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
|
||||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
|
@ -29,20 +29,16 @@ func NewRubberTree(ctx *pulumi.Context,
|
|||
return nil, errors.New("missing one or more required arguments")
|
||||
}
|
||||
|
||||
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) {
|
||||
if args.Diameter == nil {
|
||||
args.Diameter = Diameter(6.0)
|
||||
}
|
||||
if isZero(args.Farm) {
|
||||
if args.Farm == nil {
|
||||
args.Farm = pulumi.StringPtr("(unknown)")
|
||||
}
|
||||
if isZero(args.Size) {
|
||||
if args.Size == nil {
|
||||
args.Size = TreeSize("medium")
|
||||
}
|
||||
if isZero(args.Type) {
|
||||
if args.Type == nil {
|
||||
args.Type = RubberTreeVariety("Burgundy")
|
||||
}
|
||||
var resource RubberTree
|
||||
|
@ -107,7 +103,7 @@ type RubberTreeInput interface {
|
|||
}
|
||||
|
||||
func (*RubberTree) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
||||
return reflect.TypeOf((*RubberTree)(nil))
|
||||
}
|
||||
|
||||
func (i *RubberTree) ToRubberTreeOutput() RubberTreeOutput {
|
||||
|
@ -121,7 +117,7 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
|
|||
type RubberTreeOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RubberTreeOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RubberTree)(nil)).Elem()
|
||||
return reflect.TypeOf((*RubberTree)(nil))
|
||||
}
|
||||
|
||||
func (o RubberTreeOutput) ToRubberTreeOutput() RubberTreeOutput {
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
if ((!args || args.varieties === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'varieties'");
|
||||
}
|
||||
resourceInputs["sizes"] = args ? args.sizes : undefined;
|
||||
resourceInputs["varieties"] = args ? args.varieties : undefined;
|
||||
inputs["sizes"] = args ? args.sizes : undefined;
|
||||
inputs["varieties"] = args ? args.varieties : undefined;
|
||||
} else {
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Nursery.__pulumiType, name, resourceInputs, opts);
|
||||
super(Nursery.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ export interface NurseryArgs {
|
|||
/**
|
||||
* The sizes of trees available
|
||||
*/
|
||||
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>}>;
|
||||
sizes?: pulumi.Input<{[key: string]: pulumi.Input<enums.tree.v1.TreeSize>} | undefined>;
|
||||
/**
|
||||
* The varieties available
|
||||
*/
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (opts.id) {
|
||||
const state = argsOrState as RubberTreeState | undefined;
|
||||
resourceInputs["farm"] = state ? state.farm : undefined;
|
||||
inputs["farm"] = state ? state.farm : undefined;
|
||||
} else {
|
||||
const args = argsOrState as RubberTreeArgs | undefined;
|
||||
if ((!args || args.diameter === undefined) && !opts.urn) {
|
||||
|
@ -61,30 +61,30 @@ export class RubberTree extends pulumi.CustomResource {
|
|||
if ((!args || args.type === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'type'");
|
||||
}
|
||||
resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined;
|
||||
resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
|
||||
resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
|
||||
resourceInputs["size"] = (args ? args.size : undefined) ?? "medium";
|
||||
resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
|
||||
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";
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(RubberTree.__pulumiType, name, resourceInputs, opts);
|
||||
super(RubberTree.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
export interface RubberTreeState {
|
||||
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
|
||||
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of arguments for constructing a RubberTree resource.
|
||||
*/
|
||||
export interface RubberTreeArgs {
|
||||
container?: pulumi.Input<inputs.ContainerArgs>;
|
||||
container?: pulumi.Input<inputs.ContainerArgs | undefined>;
|
||||
diameter: pulumi.Input<enums.tree.v1.Diameter>;
|
||||
farm?: pulumi.Input<enums.tree.v1.Farm | string>;
|
||||
size?: pulumi.Input<enums.tree.v1.TreeSize>;
|
||||
farm?: pulumi.Input<enums.tree.v1.Farm | string | undefined>;
|
||||
size?: pulumi.Input<enums.tree.v1.TreeSize | undefined>;
|
||||
type: pulumi.Input<enums.tree.v1.RubberTreeVariety>;
|
||||
}
|
||||
|
|
|
@ -4,20 +4,9 @@
|
|||
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>;
|
||||
brightness?: pulumi.Input<enums.ContainerBrightness | undefined>;
|
||||
color?: pulumi.Input<enums.ContainerColor | string | undefined>;
|
||||
material?: pulumi.Input<string | undefined>;
|
||||
size: pulumi.Input<enums.ContainerSize>;
|
||||
}
|
||||
/**
|
||||
* containerArgsProvideDefaults sets the appropriate defaults for ContainerArgs
|
||||
*/
|
||||
export function containerArgsProvideDefaults(val: ContainerArgs): ContainerArgs {
|
||||
return {
|
||||
...val,
|
||||
brightness: (val.brightness) ?? 1,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,21 +4,10 @@
|
|||
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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ type CatInput interface {
|
|||
}
|
||||
|
||||
func (*Cat) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
||||
return reflect.TypeOf((*Cat)(nil))
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatOutput() CatOutput {
|
||||
|
@ -88,6 +88,35 @@ func (i *Cat) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
|||
return pulumi.ToOutputWithContext(ctx, i).(CatOutput)
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatPtrOutput() CatPtrOutput {
|
||||
return i.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Cat) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
|
||||
}
|
||||
|
||||
type CatPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToCatPtrOutput() CatPtrOutput
|
||||
ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput
|
||||
}
|
||||
|
||||
type catPtrType CatArgs
|
||||
|
||||
func (*catPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil))
|
||||
}
|
||||
|
||||
func (i *catPtrType) ToCatPtrOutput() CatPtrOutput {
|
||||
return i.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *catPtrType) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(CatPtrOutput)
|
||||
}
|
||||
|
||||
// CatArrayInput is an input type that accepts CatArray and CatArrayOutput values.
|
||||
// You can construct a concrete instance of `CatArrayInput` via:
|
||||
//
|
||||
|
@ -141,7 +170,7 @@ func (i CatMap) ToCatMapOutputWithContext(ctx context.Context) CatMapOutput {
|
|||
type CatOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil)).Elem()
|
||||
return reflect.TypeOf((*Cat)(nil))
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatOutput() CatOutput {
|
||||
|
@ -152,10 +181,44 @@ func (o CatOutput) ToCatOutputWithContext(ctx context.Context) CatOutput {
|
|||
return o
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatPtrOutput() CatPtrOutput {
|
||||
return o.ToCatPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CatOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Cat) *Cat {
|
||||
return &v
|
||||
}).(CatPtrOutput)
|
||||
}
|
||||
|
||||
type CatPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Cat)(nil))
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) ToCatPtrOutput() CatPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) ToCatPtrOutputWithContext(ctx context.Context) CatPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CatPtrOutput) Elem() CatOutput {
|
||||
return o.ApplyT(func(v *Cat) Cat {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Cat
|
||||
return ret
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
type CatArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]*Cat)(nil)).Elem()
|
||||
return reflect.TypeOf((*[]Cat)(nil))
|
||||
}
|
||||
|
||||
func (o CatArrayOutput) ToCatArrayOutput() CatArrayOutput {
|
||||
|
@ -167,15 +230,15 @@ func (o CatArrayOutput) ToCatArrayOutputWithContext(ctx context.Context) CatArra
|
|||
}
|
||||
|
||||
func (o CatArrayOutput) Index(i pulumi.IntInput) CatOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Cat {
|
||||
return vs[0].([]*Cat)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Cat {
|
||||
return vs[0].([]Cat)[vs[1].(int)]
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
type CatMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CatMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]*Cat)(nil)).Elem()
|
||||
return reflect.TypeOf((*map[string]Cat)(nil))
|
||||
}
|
||||
|
||||
func (o CatMapOutput) ToCatMapOutput() CatMapOutput {
|
||||
|
@ -187,16 +250,18 @@ func (o CatMapOutput) ToCatMapOutputWithContext(ctx context.Context) CatMapOutpu
|
|||
}
|
||||
|
||||
func (o CatMapOutput) MapIndex(k pulumi.StringInput) CatOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Cat {
|
||||
return vs[0].(map[string]*Cat)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Cat {
|
||||
return vs[0].(map[string]Cat)[vs[1].(string)]
|
||||
}).(CatOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatInput)(nil)).Elem(), &Cat{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatPtrInput)(nil)).Elem(), &Cat{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatArrayInput)(nil)).Elem(), CatArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*CatMapInput)(nil)).Elem(), CatMap{})
|
||||
pulumi.RegisterOutputType(CatOutput{})
|
||||
pulumi.RegisterOutputType(CatPtrOutput{})
|
||||
pulumi.RegisterOutputType(CatArrayOutput{})
|
||||
pulumi.RegisterOutputType(CatMapOutput{})
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ type ComponentInput interface {
|
|||
}
|
||||
|
||||
func (*Component) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil)).Elem()
|
||||
return reflect.TypeOf((*Component)(nil))
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentOutput() ComponentOutput {
|
||||
|
@ -112,6 +112,35 @@ func (i *Component) ToComponentOutputWithContext(ctx context.Context) ComponentO
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput)
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return i.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Component) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
type ComponentPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToComponentPtrOutput() ComponentPtrOutput
|
||||
ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput
|
||||
}
|
||||
|
||||
type componentPtrType ComponentArgs
|
||||
|
||||
func (*componentPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil))
|
||||
}
|
||||
|
||||
func (i *componentPtrType) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return i.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *componentPtrType) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
// ComponentArrayInput is an input type that accepts ComponentArray and ComponentArrayOutput values.
|
||||
// You can construct a concrete instance of `ComponentArrayInput` via:
|
||||
//
|
||||
|
@ -165,7 +194,7 @@ func (i ComponentMap) ToComponentMapOutputWithContext(ctx context.Context) Compo
|
|||
type ComponentOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil)).Elem()
|
||||
return reflect.TypeOf((*Component)(nil))
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentOutput() ComponentOutput {
|
||||
|
@ -176,10 +205,44 @@ func (o ComponentOutput) ToComponentOutputWithContext(ctx context.Context) Compo
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return o.ToComponentPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ComponentOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Component) *Component {
|
||||
return &v
|
||||
}).(ComponentPtrOutput)
|
||||
}
|
||||
|
||||
type ComponentPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Component)(nil))
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) ToComponentPtrOutput() ComponentPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) ToComponentPtrOutputWithContext(ctx context.Context) ComponentPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ComponentPtrOutput) Elem() ComponentOutput {
|
||||
return o.ApplyT(func(v *Component) Component {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Component
|
||||
return ret
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
type ComponentArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]*Component)(nil)).Elem()
|
||||
return reflect.TypeOf((*[]Component)(nil))
|
||||
}
|
||||
|
||||
func (o ComponentArrayOutput) ToComponentArrayOutput() ComponentArrayOutput {
|
||||
|
@ -191,15 +254,15 @@ func (o ComponentArrayOutput) ToComponentArrayOutputWithContext(ctx context.Cont
|
|||
}
|
||||
|
||||
func (o ComponentArrayOutput) Index(i pulumi.IntInput) ComponentOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Component {
|
||||
return vs[0].([]*Component)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Component {
|
||||
return vs[0].([]Component)[vs[1].(int)]
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
type ComponentMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ComponentMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]*Component)(nil)).Elem()
|
||||
return reflect.TypeOf((*map[string]Component)(nil))
|
||||
}
|
||||
|
||||
func (o ComponentMapOutput) ToComponentMapOutput() ComponentMapOutput {
|
||||
|
@ -211,16 +274,18 @@ func (o ComponentMapOutput) ToComponentMapOutputWithContext(ctx context.Context)
|
|||
}
|
||||
|
||||
func (o ComponentMapOutput) MapIndex(k pulumi.StringInput) ComponentOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Component {
|
||||
return vs[0].(map[string]*Component)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Component {
|
||||
return vs[0].(map[string]Component)[vs[1].(string)]
|
||||
}).(ComponentOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentPtrInput)(nil)).Elem(), &Component{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentArrayInput)(nil)).Elem(), ComponentArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ComponentMapInput)(nil)).Elem(), ComponentMap{})
|
||||
pulumi.RegisterOutputType(ComponentOutput{})
|
||||
pulumi.RegisterOutputType(ComponentPtrOutput{})
|
||||
pulumi.RegisterOutputType(ComponentArrayOutput{})
|
||||
pulumi.RegisterOutputType(ComponentMapOutput{})
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -59,10 +59,39 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderPtrOutput() ProviderPtrOutput
|
||||
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
|
||||
}
|
||||
|
||||
type providerPtrType ProviderArgs
|
||||
|
||||
func (*providerPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
@ -73,7 +102,43 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
|
||||
return &v
|
||||
}).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) Elem() ProviderOutput {
|
||||
return o.ApplyT(func(v *Provider) Provider {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Provider
|
||||
return ret
|
||||
}).(ProviderOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
pulumi.RegisterOutputType(ProviderPtrOutput{})
|
||||
}
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ type WorkloadInput interface {
|
|||
}
|
||||
|
||||
func (*Workload) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil)).Elem()
|
||||
return reflect.TypeOf((*Workload)(nil))
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadOutput() WorkloadOutput {
|
||||
|
@ -85,6 +85,35 @@ func (i *Workload) ToWorkloadOutputWithContext(ctx context.Context) WorkloadOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadOutput)
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return i.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Workload) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
type WorkloadPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToWorkloadPtrOutput() WorkloadPtrOutput
|
||||
ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput
|
||||
}
|
||||
|
||||
type workloadPtrType WorkloadArgs
|
||||
|
||||
func (*workloadPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil))
|
||||
}
|
||||
|
||||
func (i *workloadPtrType) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return i.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *workloadPtrType) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
// WorkloadArrayInput is an input type that accepts WorkloadArray and WorkloadArrayOutput values.
|
||||
// You can construct a concrete instance of `WorkloadArrayInput` via:
|
||||
//
|
||||
|
@ -138,7 +167,7 @@ func (i WorkloadMap) ToWorkloadMapOutputWithContext(ctx context.Context) Workloa
|
|||
type WorkloadOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil)).Elem()
|
||||
return reflect.TypeOf((*Workload)(nil))
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadOutput() WorkloadOutput {
|
||||
|
@ -149,10 +178,44 @@ func (o WorkloadOutput) ToWorkloadOutputWithContext(ctx context.Context) Workloa
|
|||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return o.ToWorkloadPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o WorkloadOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Workload) *Workload {
|
||||
return &v
|
||||
}).(WorkloadPtrOutput)
|
||||
}
|
||||
|
||||
type WorkloadPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Workload)(nil))
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) ToWorkloadPtrOutput() WorkloadPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) ToWorkloadPtrOutputWithContext(ctx context.Context) WorkloadPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o WorkloadPtrOutput) Elem() WorkloadOutput {
|
||||
return o.ApplyT(func(v *Workload) Workload {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Workload
|
||||
return ret
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
type WorkloadArrayOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadArrayOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*[]*Workload)(nil)).Elem()
|
||||
return reflect.TypeOf((*[]Workload)(nil))
|
||||
}
|
||||
|
||||
func (o WorkloadArrayOutput) ToWorkloadArrayOutput() WorkloadArrayOutput {
|
||||
|
@ -164,15 +227,15 @@ func (o WorkloadArrayOutput) ToWorkloadArrayOutputWithContext(ctx context.Contex
|
|||
}
|
||||
|
||||
func (o WorkloadArrayOutput) Index(i pulumi.IntInput) WorkloadOutput {
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Workload {
|
||||
return vs[0].([]*Workload)[vs[1].(int)]
|
||||
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Workload {
|
||||
return vs[0].([]Workload)[vs[1].(int)]
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
type WorkloadMapOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (WorkloadMapOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*map[string]*Workload)(nil)).Elem()
|
||||
return reflect.TypeOf((*map[string]Workload)(nil))
|
||||
}
|
||||
|
||||
func (o WorkloadMapOutput) ToWorkloadMapOutput() WorkloadMapOutput {
|
||||
|
@ -184,16 +247,18 @@ func (o WorkloadMapOutput) ToWorkloadMapOutputWithContext(ctx context.Context) W
|
|||
}
|
||||
|
||||
func (o WorkloadMapOutput) MapIndex(k pulumi.StringInput) WorkloadOutput {
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Workload {
|
||||
return vs[0].(map[string]*Workload)[vs[1].(string)]
|
||||
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Workload {
|
||||
return vs[0].(map[string]Workload)[vs[1].(string)]
|
||||
}).(WorkloadOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadInput)(nil)).Elem(), &Workload{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadPtrInput)(nil)).Elem(), &Workload{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadArrayInput)(nil)).Elem(), WorkloadArray{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*WorkloadMapInput)(nil)).Elem(), WorkloadMap{})
|
||||
pulumi.RegisterOutputType(WorkloadOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadPtrOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadArrayOutput{})
|
||||
pulumi.RegisterOutputType(WorkloadMapOutput{})
|
||||
}
|
||||
|
|
|
@ -33,5 +33,5 @@ export function argFunctionOutput(args?: ArgFunctionOutputArgs, opts?: pulumi.In
|
|||
}
|
||||
|
||||
export interface ArgFunctionOutputArgs {
|
||||
name?: pulumi.Input<pulumiRandom.RandomPet>;
|
||||
name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["age"] = args ? args.age : undefined;
|
||||
resourceInputs["pet"] = args ? args.pet : undefined;
|
||||
resourceInputs["name"] = undefined /*out*/;
|
||||
inputs["age"] = args ? args.age : undefined;
|
||||
inputs["pet"] = args ? args.pet : undefined;
|
||||
inputs["name"] = undefined /*out*/;
|
||||
} else {
|
||||
resourceInputs["name"] = undefined /*out*/;
|
||||
inputs["name"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Cat.__pulumiType, name, resourceInputs, opts);
|
||||
super(Cat.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,6 @@ export class Cat extends pulumi.CustomResource {
|
|||
* The set of arguments for constructing a Cat resource.
|
||||
*/
|
||||
export interface CatArgs {
|
||||
age?: pulumi.Input<number>;
|
||||
pet?: pulumi.Input<inputs.PetArgs>;
|
||||
age?: pulumi.Input<number | undefined>;
|
||||
pet?: pulumi.Input<inputs.PetArgs | undefined>;
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: 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'");
|
||||
}
|
||||
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*/;
|
||||
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*/;
|
||||
} else {
|
||||
resourceInputs["provider"] = undefined /*out*/;
|
||||
resourceInputs["securityGroup"] = undefined /*out*/;
|
||||
resourceInputs["storageClasses"] = undefined /*out*/;
|
||||
inputs["provider"] = undefined /*out*/;
|
||||
inputs["securityGroup"] = undefined /*out*/;
|
||||
inputs["storageClasses"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Component.__pulumiType, name, resourceInputs, opts);
|
||||
super(Component.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,9 +83,9 @@ export class Component extends pulumi.CustomResource {
|
|||
* The set of arguments for constructing a Component resource.
|
||||
*/
|
||||
export interface ComponentArgs {
|
||||
metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>;
|
||||
metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>;
|
||||
metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>;
|
||||
metadata?: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs | undefined>;
|
||||
metadataArray?: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[] | undefined>;
|
||||
metadataMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>} | undefined>;
|
||||
requiredMetadata: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>;
|
||||
requiredMetadataArray: pulumi.Input<pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>[]>;
|
||||
requiredMetadataMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiKubernetes.types.input.meta.v1.ObjectMetaArgs>}>;
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import { input as inputs, output as outputs } from "../types";
|
|||
import * as pulumiRandom from "@pulumi/random";
|
||||
|
||||
export interface PetArgs {
|
||||
age?: pulumi.Input<number>;
|
||||
name?: pulumi.Input<pulumiRandom.RandomPet>;
|
||||
nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>;
|
||||
nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>;
|
||||
age?: pulumi.Input<number | undefined>;
|
||||
name?: pulumi.Input<pulumiRandom.RandomPet | undefined>;
|
||||
nameArray?: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[] | undefined>;
|
||||
nameMap?: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>} | undefined>;
|
||||
requiredName: pulumi.Input<pulumiRandom.RandomPet>;
|
||||
requiredNameArray: pulumi.Input<pulumi.Input<pulumiRandom.RandomPet>[]>;
|
||||
requiredNameMap: pulumi.Input<{[key: string]: pulumi.Input<pulumiRandom.RandomPet>}>;
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["pod"] = undefined /*out*/;
|
||||
inputs["pod"] = undefined /*out*/;
|
||||
} else {
|
||||
resourceInputs["pod"] = undefined /*out*/;
|
||||
inputs["pod"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Workload.__pulumiType, name, resourceInputs, opts);
|
||||
super(Workload.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -59,10 +59,39 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToProviderPtrOutput() ProviderPtrOutput
|
||||
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
|
||||
}
|
||||
|
||||
type providerPtrType ProviderArgs
|
||||
|
||||
func (*providerPtrType) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return i.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
@ -73,7 +102,43 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
|
|||
return o
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o.ToProviderPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v Provider) *Provider {
|
||||
return &v
|
||||
}).(ProviderPtrOutput)
|
||||
}
|
||||
|
||||
type ProviderPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ProviderPtrOutput) Elem() ProviderOutput {
|
||||
return o.ApplyT(func(v *Provider) Provider {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret Provider
|
||||
return ret
|
||||
}).(ProviderOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ProviderPtrInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
pulumi.RegisterOutputType(ProviderPtrOutput{})
|
||||
}
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ type RegistryGeoReplicationInput interface {
|
|||
}
|
||||
|
||||
func (*RegistryGeoReplication) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem()
|
||||
return reflect.TypeOf((*RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (i *RegistryGeoReplication) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
|
||||
|
@ -76,6 +76,35 @@ 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:
|
||||
//
|
||||
|
@ -129,7 +158,7 @@ func (i RegistryGeoReplicationMap) ToRegistryGeoReplicationMapOutputWithContext(
|
|||
type RegistryGeoReplicationOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (RegistryGeoReplicationOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**RegistryGeoReplication)(nil)).Elem()
|
||||
return reflect.TypeOf((*RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationOutput) ToRegistryGeoReplicationOutput() RegistryGeoReplicationOutput {
|
||||
|
@ -140,10 +169,44 @@ 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)).Elem()
|
||||
return reflect.TypeOf((*[]RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationArrayOutput) ToRegistryGeoReplicationArrayOutput() RegistryGeoReplicationArrayOutput {
|
||||
|
@ -155,15 +218,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)).Elem()
|
||||
return reflect.TypeOf((*map[string]RegistryGeoReplication)(nil))
|
||||
}
|
||||
|
||||
func (o RegistryGeoReplicationMapOutput) ToRegistryGeoReplicationMapOutput() RegistryGeoReplicationMapOutput {
|
||||
|
@ -175,16 +238,18 @@ 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{})
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
if ((!args || args.resourceGroup === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'resourceGroup'");
|
||||
}
|
||||
resourceInputs["resourceGroup"] = args ? args.resourceGroup : undefined;
|
||||
resourceInputs["acrLoginServerOut"] = undefined /*out*/;
|
||||
resourceInputs["registry"] = undefined /*out*/;
|
||||
resourceInputs["replication"] = undefined /*out*/;
|
||||
inputs["resourceGroup"] = args ? args.resourceGroup : undefined;
|
||||
inputs["acrLoginServerOut"] = undefined /*out*/;
|
||||
inputs["registry"] = undefined /*out*/;
|
||||
inputs["replication"] = undefined /*out*/;
|
||||
} else {
|
||||
resourceInputs["acrLoginServerOut"] = undefined /*out*/;
|
||||
resourceInputs["registry"] = undefined /*out*/;
|
||||
resourceInputs["replication"] = undefined /*out*/;
|
||||
inputs["acrLoginServerOut"] = undefined /*out*/;
|
||||
inputs["registry"] = undefined /*out*/;
|
||||
inputs["replication"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(RegistryGeoReplication.__pulumiType, name, resourceInputs, opts, true /*remote*/);
|
||||
super(RegistryGeoReplication.__pulumiType, name, inputs, opts, true /*remote*/);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
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)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -73,7 +73,7 @@ type ResourceInputResourceInput interface {
|
|||
}
|
||||
|
||||
func (*ResourceInputResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ResourceInputResource)(nil)).Elem()
|
||||
return reflect.TypeOf((*ResourceInputResource)(nil))
|
||||
}
|
||||
|
||||
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)).Elem()
|
||||
return reflect.TypeOf((*ResourceInputResource)(nil))
|
||||
}
|
||||
|
||||
func (o ResourceInputResourceOutput) ToResourceInputResourceOutput() ResourceInputResourceOutput {
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["bar"] = undefined /*out*/;
|
||||
inputs["bar"] = undefined /*out*/;
|
||||
} else {
|
||||
resourceInputs["bar"] = undefined /*out*/;
|
||||
inputs["bar"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Resource.__pulumiType, name, resourceInputs, opts);
|
||||
super(Resource.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["bar"] = undefined /*out*/;
|
||||
inputs["bar"] = undefined /*out*/;
|
||||
} else {
|
||||
resourceInputs["bar"] = undefined /*out*/;
|
||||
inputs["bar"] = undefined /*out*/;
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(ResourceInput.__pulumiType, name, resourceInputs, opts);
|
||||
super(ResourceInput.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
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)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined;
|
||||
inputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined;
|
||||
} else {
|
||||
resourceInputs["baz"] = undefined /*out*/;
|
||||
inputs["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, resourceInputs, opts);
|
||||
super(Resource.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
|
|||
* The set of arguments for constructing a Resource resource.
|
||||
*/
|
||||
export interface ResourceArgs {
|
||||
baz?: pulumi.Input<string>;
|
||||
baz?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ type ResourceInput interface {
|
|||
}
|
||||
|
||||
func (*Resource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Resource)(nil)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
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)).Elem()
|
||||
return reflect.TypeOf((*Resource)(nil))
|
||||
}
|
||||
|
||||
func (o ResourceOutput) ToResourceOutput() ResourceOutput {
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
resourceInputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined;
|
||||
inputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined;
|
||||
} else {
|
||||
resourceInputs["bar"] = undefined /*out*/;
|
||||
inputs["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, resourceInputs, opts);
|
||||
super(Resource.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,5 +61,5 @@ export class Resource extends pulumi.CustomResource {
|
|||
* The set of arguments for constructing a Resource resource.
|
||||
*/
|
||||
export interface ResourceArgs {
|
||||
bar?: pulumi.Input<string>;
|
||||
bar?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
using Pulumi;
|
||||
using Aws = Pulumi.Aws;
|
||||
|
||||
class MyStack : Stack
|
||||
{
|
||||
public MyStack()
|
||||
{
|
||||
var aws_vpc = new Aws.Ec2.Vpc("aws_vpc", new Aws.Ec2.VpcArgs
|
||||
{
|
||||
CidrBlock = "10.0.0.0/16",
|
||||
InstanceTenancy = "default",
|
||||
});
|
||||
var privateS3VpcEndpoint = new Aws.Ec2.VpcEndpoint("privateS3VpcEndpoint", new Aws.Ec2.VpcEndpointArgs
|
||||
{
|
||||
VpcId = aws_vpc.Id,
|
||||
ServiceName = "com.amazonaws.us-west-2.s3",
|
||||
});
|
||||
var privateS3PrefixList = Aws.Ec2.GetPrefixList.Invoke(new Aws.Ec2.GetPrefixListInvokeArgs
|
||||
{
|
||||
PrefixListId = privateS3VpcEndpoint.PrefixListId,
|
||||
});
|
||||
var bar = new Aws.Ec2.NetworkAcl("bar", new Aws.Ec2.NetworkAclArgs
|
||||
{
|
||||
VpcId = aws_vpc.Id,
|
||||
});
|
||||
var privateS3NetworkAclRule = new Aws.Ec2.NetworkAclRule("privateS3NetworkAclRule", new Aws.Ec2.NetworkAclRuleArgs
|
||||
{
|
||||
NetworkAclId = bar.Id,
|
||||
RuleNumber = 200,
|
||||
Egress = false,
|
||||
Protocol = "tcp",
|
||||
RuleAction = "allow",
|
||||
CidrBlock = privateS3PrefixList.Apply(privateS3PrefixList => privateS3PrefixList.CidrBlocks[0]),
|
||||
FromPort = 443,
|
||||
ToPort = 443,
|
||||
});
|
||||
var amis = Aws.Ec2.GetAmiIds.Invoke(new Aws.Ec2.GetAmiIdsInvokeArgs
|
||||
{
|
||||
Owners =
|
||||
{
|
||||
bar.Id,
|
||||
},
|
||||
Filters =
|
||||
{
|
||||
new Aws.Ec2.Inputs.GetAmiIdsFilterInputArgs
|
||||
{
|
||||
Name = bar.Id,
|
||||
Values =
|
||||
{
|
||||
"pulumi*",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pulumi.Run(func(ctx *pulumi.Context) error {
|
||||
aws_vpc, err := ec2.NewVpc(ctx, "aws_vpc", &ec2.VpcArgs{
|
||||
CidrBlock: pulumi.String("10.0.0.0/16"),
|
||||
InstanceTenancy: pulumi.String("default"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
privateS3VpcEndpoint, err := ec2.NewVpcEndpoint(ctx, "privateS3VpcEndpoint", &ec2.VpcEndpointArgs{
|
||||
VpcId: aws_vpc.ID(),
|
||||
ServiceName: pulumi.String("com.amazonaws.us-west-2.s3"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
privateS3PrefixList := ec2.GetPrefixListOutput(ctx, ec2.GetPrefixListOutputArgs{
|
||||
PrefixListId: privateS3VpcEndpoint.PrefixListId,
|
||||
}, nil)
|
||||
bar, err := ec2.NewNetworkAcl(ctx, "bar", &ec2.NetworkAclArgs{
|
||||
VpcId: aws_vpc.ID(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = ec2.NewNetworkAclRule(ctx, "privateS3NetworkAclRule", &ec2.NetworkAclRuleArgs{
|
||||
NetworkAclId: bar.ID(),
|
||||
RuleNumber: pulumi.Int(200),
|
||||
Egress: pulumi.Bool(false),
|
||||
Protocol: pulumi.String("tcp"),
|
||||
RuleAction: pulumi.String("allow"),
|
||||
CidrBlock: privateS3PrefixList.ApplyT(func(privateS3PrefixList ec2.GetPrefixListResult) (string, error) {
|
||||
return privateS3PrefixList.CidrBlocks[0], nil
|
||||
}).(pulumi.StringOutput),
|
||||
FromPort: pulumi.Int(443),
|
||||
ToPort: pulumi.Int(443),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = ec2.GetAmiIdsOutput(ctx, ec2.GetAmiIdsOutputArgs{
|
||||
Owners: pulumi.StringArray{
|
||||
bar.ID(),
|
||||
},
|
||||
Filters: ec2.GetAmiIdsFilterArray{
|
||||
&ec2.GetAmiIdsFilterArgs{
|
||||
Name: bar.ID(),
|
||||
Values: pulumi.StringArray{
|
||||
pulumi.String("pulumi*"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as aws from "@pulumi/aws";
|
||||
|
||||
const aws_vpc = new aws.ec2.Vpc("aws_vpc", {
|
||||
cidrBlock: "10.0.0.0/16",
|
||||
instanceTenancy: "default",
|
||||
});
|
||||
const privateS3VpcEndpoint = new aws.ec2.VpcEndpoint("privateS3VpcEndpoint", {
|
||||
vpcId: aws_vpc.id,
|
||||
serviceName: "com.amazonaws.us-west-2.s3",
|
||||
});
|
||||
const privateS3PrefixList = aws.ec2.getPrefixListOutput({
|
||||
prefixListId: privateS3VpcEndpoint.prefixListId,
|
||||
});
|
||||
const bar = new aws.ec2.NetworkAcl("bar", {vpcId: aws_vpc.id});
|
||||
const privateS3NetworkAclRule = new aws.ec2.NetworkAclRule("privateS3NetworkAclRule", {
|
||||
networkAclId: bar.id,
|
||||
ruleNumber: 200,
|
||||
egress: false,
|
||||
protocol: "tcp",
|
||||
ruleAction: "allow",
|
||||
cidrBlock: privateS3PrefixList.cidrBlocks[0],
|
||||
fromPort: 443,
|
||||
toPort: 443,
|
||||
});
|
||||
const amis = aws.ec2.getAmiIdsOutput({
|
||||
owners: [bar.id],
|
||||
filters: [{
|
||||
name: bar.id,
|
||||
values: ["pulumi*"],
|
||||
}],
|
||||
});
|
|
@ -1,36 +0,0 @@
|
|||
resource aws_vpc "aws:ec2/vpc:Vpc" {
|
||||
cidrBlock = "10.0.0.0/16"
|
||||
instanceTenancy = "default"
|
||||
}
|
||||
|
||||
resource privateS3VpcEndpoint "aws:ec2/vpcEndpoint:VpcEndpoint" {
|
||||
vpcId = aws_vpc.id
|
||||
serviceName = "com.amazonaws.us-west-2.s3"
|
||||
}
|
||||
|
||||
privateS3PrefixList = invoke("aws:ec2:getPrefixList", {
|
||||
prefixListId = privateS3VpcEndpoint.prefixListId
|
||||
})
|
||||
|
||||
resource bar "aws:ec2/networkAcl:NetworkAcl" {
|
||||
vpcId = aws_vpc.id
|
||||
}
|
||||
|
||||
resource privateS3NetworkAclRule "aws:ec2/networkAclRule:NetworkAclRule" {
|
||||
networkAclId = bar.id
|
||||
ruleNumber = 200
|
||||
egress = false
|
||||
protocol = "tcp"
|
||||
ruleAction = "allow"
|
||||
cidrBlock = privateS3PrefixList.cidrBlocks[0]
|
||||
fromPort = 443
|
||||
toPort = 443
|
||||
}
|
||||
|
||||
# A contrived example to test that helper nested records ( `filters`
|
||||
# below) generate correctly when using output-versioned function
|
||||
# invoke forms.
|
||||
amis = invoke("aws:ec2:getAmiIds", {
|
||||
owners = [bar.id]
|
||||
filters = [{name=bar.id, values=["pulumi*"]}]
|
||||
})
|
|
@ -1,25 +0,0 @@
|
|||
import pulumi
|
||||
import pulumi_aws as aws
|
||||
|
||||
aws_vpc = aws.ec2.Vpc("aws_vpc",
|
||||
cidr_block="10.0.0.0/16",
|
||||
instance_tenancy="default")
|
||||
private_s3_vpc_endpoint = aws.ec2.VpcEndpoint("privateS3VpcEndpoint",
|
||||
vpc_id=aws_vpc.id,
|
||||
service_name="com.amazonaws.us-west-2.s3")
|
||||
private_s3_prefix_list = aws.ec2.get_prefix_list_output(prefix_list_id=private_s3_vpc_endpoint.prefix_list_id)
|
||||
bar = aws.ec2.NetworkAcl("bar", vpc_id=aws_vpc.id)
|
||||
private_s3_network_acl_rule = aws.ec2.NetworkAclRule("privateS3NetworkAclRule",
|
||||
network_acl_id=bar.id,
|
||||
rule_number=200,
|
||||
egress=False,
|
||||
protocol="tcp",
|
||||
rule_action="allow",
|
||||
cidr_block=private_s3_prefix_list.cidr_blocks[0],
|
||||
from_port=443,
|
||||
to_port=443)
|
||||
amis = aws.ec2.get_ami_ids_output(owners=[bar.id],
|
||||
filters=[aws.ec2.GetAmiIdsFilterArgs(
|
||||
name=bar.id,
|
||||
values=["pulumi*"],
|
||||
)])
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ export interface ListConfigurationsOutputArgs {
|
|||
/**
|
||||
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
|
||||
*/
|
||||
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>;
|
||||
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
|
||||
/**
|
||||
* $skipToken is supported on list of configurations, which provides the next page in the list of configurations.
|
||||
*/
|
||||
skipToken?: pulumi.Input<string>;
|
||||
skipToken?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
|
|
@ -66,11 +66,11 @@ export interface ListProductFamiliesOutputArgs {
|
|||
/**
|
||||
* Customer subscription properties. Clients can display available products to unregistered customers by explicitly passing subscription details
|
||||
*/
|
||||
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs>;
|
||||
customerSubscriptionDetails?: pulumi.Input<inputs.CustomerSubscriptionDetailsArgs | undefined>;
|
||||
/**
|
||||
* $expand is supported on configurations parameter for product, which provides details on the configurations for the product.
|
||||
*/
|
||||
expand?: pulumi.Input<string>;
|
||||
expand?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* Dictionary of filterable properties on product family.
|
||||
*/
|
||||
|
@ -78,5 +78,5 @@ export interface ListProductFamiliesOutputArgs {
|
|||
/**
|
||||
* $skipToken is supported on list of product families, which provides the next page in the list of product families.
|
||||
*/
|
||||
skipToken?: pulumi.Input<string>;
|
||||
skipToken?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export interface ConfigurationFiltersArgs {
|
|||
/**
|
||||
* Filters specific to product
|
||||
*/
|
||||
filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[]>;
|
||||
filterableProperty?: pulumi.Input<pulumi.Input<inputs.FilterablePropertyArgs>[] | undefined>;
|
||||
/**
|
||||
* Product hierarchy information
|
||||
*/
|
||||
|
@ -57,7 +57,7 @@ export interface CustomerSubscriptionDetailsArgs {
|
|||
/**
|
||||
* Location placement Id of a subscription
|
||||
*/
|
||||
locationPlacementId?: pulumi.Input<string>;
|
||||
locationPlacementId?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* Quota ID of a subscription
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ export interface CustomerSubscriptionDetailsArgs {
|
|||
/**
|
||||
* List of registered feature flags for subscription
|
||||
*/
|
||||
registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[]>;
|
||||
registeredFeatures?: pulumi.Input<pulumi.Input<inputs.CustomerSubscriptionRegisteredFeaturesArgs>[] | undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,11 +89,11 @@ export interface CustomerSubscriptionRegisteredFeaturesArgs {
|
|||
/**
|
||||
* Name of subscription registered feature
|
||||
*/
|
||||
name?: pulumi.Input<string>;
|
||||
name?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* State of subscription registered feature
|
||||
*/
|
||||
state?: pulumi.Input<string>;
|
||||
state?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,18 +153,18 @@ export interface HierarchyInformationArgs {
|
|||
/**
|
||||
* Represents configuration name that uniquely identifies configuration
|
||||
*/
|
||||
configurationName?: pulumi.Input<string>;
|
||||
configurationName?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* Represents product family name that uniquely identifies product family
|
||||
*/
|
||||
productFamilyName?: pulumi.Input<string>;
|
||||
productFamilyName?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* Represents product line name that uniquely identifies product line
|
||||
*/
|
||||
productLineName?: pulumi.Input<string>;
|
||||
productLineName?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* Represents product name that uniquely identifies product
|
||||
*/
|
||||
productName?: pulumi.Input<string>;
|
||||
productName?: pulumi.Input<string | undefined>;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -62,7 +62,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
||||
|
|
|
@ -75,11 +75,3 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
|
|
|
@ -88,13 +88,13 @@ export interface GetAmiIdsOutputArgs {
|
|||
* Limit search to users with *explicit* launch
|
||||
* permission on the image. Valid items are the numeric account ID or `self`.
|
||||
*/
|
||||
executableUsers?: pulumi.Input<pulumi.Input<string>[]>;
|
||||
executableUsers?: pulumi.Input<pulumi.Input<string>[] | undefined>;
|
||||
/**
|
||||
* One or more name/value pairs to filter off of. There
|
||||
* are several valid keys, for a full reference, check out
|
||||
* [describe-images in the AWS CLI reference][1].
|
||||
*/
|
||||
filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[]>;
|
||||
filters?: pulumi.Input<pulumi.Input<inputs.GetAmiIdsFilterArgs>[] | undefined>;
|
||||
/**
|
||||
* A regex string to apply to the AMI list returned
|
||||
* by AWS. This allows more advanced filtering not supported from the AWS API.
|
||||
|
@ -102,7 +102,7 @@ export interface GetAmiIdsOutputArgs {
|
|||
* impact if the result is large. It is recommended to combine this with other
|
||||
* options to narrow down the list AWS returns.
|
||||
*/
|
||||
nameRegex?: pulumi.Input<string>;
|
||||
nameRegex?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* List of AMI owners to limit search. At least 1 value must be specified. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g. `amazon`, `aws-marketplace`, `microsoft`).
|
||||
*/
|
||||
|
@ -110,5 +110,5 @@ export interface GetAmiIdsOutputArgs {
|
|||
/**
|
||||
* Used to sort AMIs by creation time.
|
||||
*/
|
||||
sortAscending?: pulumi.Input<boolean>;
|
||||
sortAscending?: pulumi.Input<boolean | undefined>;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ export interface ListStorageAccountKeysOutputArgs {
|
|||
/**
|
||||
* Specifies type of the key to be listed. Possible value is kerb.
|
||||
*/
|
||||
expand?: pulumi.Input<string>;
|
||||
expand?: pulumi.Input<string | undefined>;
|
||||
/**
|
||||
* The name of the resource group within the user's subscription. The name is case insensitive.
|
||||
*/
|
||||
|
|
|
@ -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 resourceInputs: pulumi.Inputs = {};
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, resourceInputs, opts);
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ func (mocks) NewResource(args pulumi.MockResourceArgs) (string, resource.Propert
|
|||
}
|
||||
|
||||
func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
||||
switch args.Token {
|
||||
case "mypkg::listStorageAccountKeys":
|
||||
if args.Token == "mypkg::listStorageAccountKeys" {
|
||||
|
||||
targs := mypkg.ListStorageAccountKeysArgs{}
|
||||
for k, v := range args.Args {
|
||||
switch k {
|
||||
|
@ -72,11 +72,12 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
|||
"keys": result.Keys,
|
||||
}
|
||||
return resource.NewPropertyMapFromMap(outputs), nil
|
||||
}
|
||||
|
||||
case "mypkg::funcWithDefaultValue",
|
||||
"mypkg::funcWithAllOptionalInputs",
|
||||
"mypkg::funcWithListParam",
|
||||
"mypkg::funcWithDictParam":
|
||||
if args.Token == "mypkg::funcWithDefaultValue" ||
|
||||
args.Token == "mypkg::funcWithAllOptionalInputs" ||
|
||||
args.Token == "mypkg::funcWithListParam" ||
|
||||
args.Token == "mypkg::funcWithDictParam" {
|
||||
result := mypkg.FuncWithDefaultValueResult{
|
||||
R: fmt.Sprintf("%v", args.Args),
|
||||
}
|
||||
|
@ -84,8 +85,9 @@ func (mocks) Call(args pulumi.MockCallArgs) (resource.PropertyMap, error) {
|
|||
"r": result.R,
|
||||
}
|
||||
return resource.NewPropertyMapFromMap(outputs), nil
|
||||
}
|
||||
|
||||
case "mypkg::getIntegrationRuntimeObjectMetadatum":
|
||||
if args.Token == "mypkg::getIntegrationRuntimeObjectMetadatum" {
|
||||
targs := mypkg.GetIntegrationRuntimeObjectMetadatumArgs{}
|
||||
for k, v := range args.Args {
|
||||
switch k {
|
||||
|
@ -149,13 +151,16 @@ func TestListStorageAccountKeysOutput(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO[pulumi/pulumi#7811]: it seems that default values are not
|
||||
// supported by Go codegen yet, hence we do not observe "B" populated
|
||||
// to default at all here.
|
||||
func TestFuncWithDefaultValueOutput(t *testing.T) {
|
||||
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} b:{b-default}]", r)
|
||||
assert.Equal(t, "map[a:{my-a}]", r)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue