Compare commits
70 commits
master
...
t0yv0/try-
Author | SHA1 | Date | |
---|---|---|---|
|
233522a565 | ||
|
0ab7306d21 | ||
|
f55aaa82c9 | ||
|
0d45de67dd | ||
|
7ca0ad12ff | ||
|
80db85c1e9 | ||
|
e4530c91f7 | ||
|
4c7b9daee6 | ||
|
8caa968462 | ||
|
9e9cffc68d | ||
|
6bd2aab636 | ||
|
db93628984 | ||
|
06a4b5b044 | ||
|
b6b78cc3b2 | ||
|
229be2b0a0 | ||
|
3490e2ff82 | ||
|
5e629b4f85 | ||
|
93a8286d91 | ||
|
2570b87dc3 | ||
|
257ed26a33 | ||
|
1830f71c82 | ||
|
c4676cfd33 | ||
|
f957cd5033 | ||
|
70fc032fb6 | ||
|
232cba84a6 | ||
|
47e97143ff | ||
|
938d09dce8 | ||
|
4572dfdc44 | ||
|
8e2f80d514 | ||
|
735ecd5e3a | ||
|
b4ff6dd2b4 | ||
|
aa9391f40c | ||
|
2f37ad26a4 | ||
|
ee488200c7 | ||
|
3beadb25b7 | ||
|
d841c5790f | ||
|
f729ecac78 | ||
|
e9ce7e34ed | ||
|
bccbc7875e | ||
|
ca46eb7dbb | ||
|
9a24223d90 | ||
|
11be4a1105 | ||
|
7ddf6e0742 | ||
|
75852d96f3 | ||
|
61fc97f251 | ||
|
ab7d3cdf0d | ||
|
5929ffb67a | ||
|
2292a95965 | ||
|
52e747c030 | ||
|
743b851c8e | ||
|
2829f9008c | ||
|
d8a4debf65 | ||
|
13e78100cd | ||
|
4ec78986c8 | ||
|
22d54ac1ad | ||
|
94dab380e5 | ||
|
ece2325694 | ||
|
898fe20af5 | ||
|
f4873b9560 | ||
|
487cbf87b2 | ||
|
33608ef2f5 | ||
|
12289325c5 | ||
|
c76075005b | ||
|
9a48902e1c | ||
|
10b9606ed7 | ||
|
17b49ed6fd | ||
|
e8c6f643a8 | ||
|
293b73be51 | ||
|
28db49b0cb | ||
|
59568580c1 |
214
.github/workflows/build.yml
vendored
Normal file
214
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,214 @@
|
|||
name: Builds CLI and SDK binaries.
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
go-version:
|
||||
description: 'Version of the Go toolchain for the build'
|
||||
default: '1.17.x'
|
||||
required: false
|
||||
type: string
|
||||
python-version:
|
||||
description: 'Version of the Python toolchain for the build'
|
||||
default: '3.9.x'
|
||||
required: false
|
||||
type: string
|
||||
node-version:
|
||||
description: 'Version of the Node toolchain for the build'
|
||||
default: '14.x'
|
||||
required: false
|
||||
type: string
|
||||
dotnet-version:
|
||||
description: 'Version of the .NET toolchain for the build'
|
||||
default: '3.1.x'
|
||||
required: false
|
||||
type: string
|
||||
goreleaser-flags:
|
||||
description: 'Command-line flags to pass to goreleaser'
|
||||
default: '-p 3 -f .goreleaser.build.yml --snapshot --skip-validate'
|
||||
required: false
|
||||
type: string
|
||||
secrets: {}
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
build_pulumi_go_binaries:
|
||||
name: Build Pulumi Go binaries
|
||||
|
||||
# Due to the use of CGO in `pulumi` this cross-compilation step
|
||||
# cannot proceed on `ubuntu-latest`, which would have been
|
||||
# preferable.
|
||||
# runs-on: macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
git fetch --quiet --prune --unshallow --tags
|
||||
- name: Install pulumictl
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Set up Go ${{ inputs.go-version }}
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ inputs.go-version }}
|
||||
- name: Compute current version to inform GoReleaser
|
||||
run: |
|
||||
echo "GORELEASER_CURRENT_TAG=v$(pulumictl get version --language generic -o)" >> $GITHUB_ENV
|
||||
- name: Run GoReleaser to build Go Pulumi binaries
|
||||
uses: goreleaser/goreleaser-action@v2
|
||||
with:
|
||||
version: latest
|
||||
args: ${{ inputs.goreleaser-flags }}
|
||||
- name: Upload pulumi-darwin-arm64.tar.gz
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-darwin-arm64.tar.gz
|
||||
path: goreleaser/pulumi*-darwin-arm64.tar.gz
|
||||
- name: Upload pulumi-darwin-x64.tar.gz
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-darwin-x64.tar.gz
|
||||
path: goreleaser/pulumi*-darwin-x64.tar.gz
|
||||
- name: Upload pulumi-linux-arm64.tar.gz
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-linux-arm64.tar.gz
|
||||
path: goreleaser/pulumi*-linux-arm64.tar.gz
|
||||
- name: Upload pulumi-linux-x64.tar.gz
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-linux-x64.tar.gz
|
||||
path: goreleaser/pulumi*-linux-x64.tar.gz
|
||||
- name: Upload pulumi-windows-x64.zip
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-windows-x64.zip
|
||||
path: goreleaser/pulumi*-windows-x64.zip
|
||||
|
||||
build_python_sdk:
|
||||
name: Build Pulumi Python SDK wheel
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
git fetch --quiet --prune --unshallow --tags
|
||||
- name: Install pulumictl
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Set up Python ${{ inputs.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
- name: Compute current version to inform wheel build
|
||||
run: |
|
||||
echo "PYPY_VERSION=$(pulumictl get version --language python)" >> $GITHUB_ENV
|
||||
- name: Build Pulumi Python SDK wheel
|
||||
run: |
|
||||
# TODO unify with sdk/python/Makefile once that does not use pipenv
|
||||
cp README.md sdk/python/lib
|
||||
cd sdk/python/lib
|
||||
sed -i.bak "s/\${VERSION}/$PYPY_VERSION/g" setup.py
|
||||
rm setup.py.bak
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
python -m pip install wheel
|
||||
python setup.py build bdist_wheel --python-tag py3
|
||||
- name: Upload pulumi.whl
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi.whl
|
||||
path: sdk/python/lib/dist/*.whl
|
||||
|
||||
build_node_sdk:
|
||||
name: Build Pulumi Node SDK tarball
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
git fetch --quiet --prune --unshallow --tags
|
||||
- name: Install pulumictl
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Set up Node ${{ inputs.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
- name: Install yarn
|
||||
run: |
|
||||
npm install -g yarn
|
||||
- name: Make no-op Go command to avoid Go builds
|
||||
run: |
|
||||
cd sdk/nodejs
|
||||
mkdir -p bin
|
||||
ln -s $(which echo) bin/go
|
||||
- name: Ensure installed dependencies
|
||||
run: |
|
||||
cd sdk/nodejs
|
||||
PATH=./bin:$PATH make ensure
|
||||
- name: Build the Node SDK package
|
||||
run: |
|
||||
cd sdk/nodejs
|
||||
PATH=./bin:$PATH make build_package
|
||||
- name: Pack the Node SDK
|
||||
run: |
|
||||
cd sdk/nodejs/bin
|
||||
npm pack
|
||||
- name: Upload pulumi-node-sdk.tgz
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-node-sdk.tgz
|
||||
path: sdk/nodejs/bin/*.tgz
|
||||
|
||||
build_dotnet_sdk:
|
||||
name: Build Pulumi .NET SDK NuGet packages
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
git fetch --quiet --prune --unshallow --tags
|
||||
- name: Install pulumictl
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Set up DotNet ${{ inputs.dotnet-version }}
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: ${{ inputs.dotnet-version }}
|
||||
- name: Compute current version to inform the NuGet package build
|
||||
run: |
|
||||
echo "DOTNET_VERSION=$(pulumictl get version --language dotnet)" >> $GITHUB_ENV
|
||||
- name: Build the .NET SDK package
|
||||
run: |
|
||||
cd sdk/dotnet
|
||||
dotnet build --configuration Release dotnet.sln /p:Version=$DOTNET_VERSION
|
||||
- name: Pack the .NET SDK package
|
||||
run: |
|
||||
cd sdk/dotnet
|
||||
dotnet pack --configuration Release --output nupkgs dotnet.sln /p:Version=$DOTNET_VERSION
|
||||
- name: Upload the NuGet packages
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pulumi-nuget-packages
|
||||
path: sdk/dotnet/nupkgs/*.nupkg
|
367
.github/workflows/run-build-and-acceptance-tests.yml
vendored
367
.github/workflows/run-build-and-acceptance-tests.yml
vendored
|
@ -6,6 +6,10 @@ on:
|
|||
- 'CHANGELOG.md'
|
||||
- 'CHANGELOG_PENDING.md'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
env:
|
||||
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_PROD_ACCESS_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
@ -33,6 +37,7 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
comment-notification:
|
||||
# We only care about adding the result to the PR if it's a repository_dispatch event
|
||||
if: github.event_name == 'repository_dispatch'
|
||||
|
@ -51,6 +56,7 @@ jobs:
|
|||
Please view the results of the PR Build + Acceptance Tests Run [Here][1]
|
||||
|
||||
[1]: ${{ steps.vars.outputs.run-url }}
|
||||
|
||||
go-lint:
|
||||
container: golangci/golangci-lint:latest
|
||||
name: Lint ${{ matrix.directory }}
|
||||
|
@ -66,6 +72,7 @@ jobs:
|
|||
- name: Lint ${{ matrix.directory }}
|
||||
run: |
|
||||
cd ${{ matrix.directory }} && golangci-lint run -c ../.golangci.yml
|
||||
|
||||
sdk-lint:
|
||||
name: Lint SDKs
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -124,11 +131,18 @@ jobs:
|
|||
- name: Lint .NET
|
||||
run: |
|
||||
cd sdk/dotnet && make lint
|
||||
build_and_test:
|
||||
name: Build & Test
|
||||
|
||||
build:
|
||||
name: Build
|
||||
uses: pulumi/pulumi/.github/workflows/build.yml@8e2f80d5147fbf30d06370f87c02c5d361198a55
|
||||
|
||||
test:
|
||||
name: Test
|
||||
needs: build
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ ubuntu-latest, macos-latest ]
|
||||
# platform: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
platform: [ windows-latest ]
|
||||
go-version: [ 1.17.x ]
|
||||
python-version: [ 3.9.x ]
|
||||
dotnet-version: [ 3.1.x ]
|
||||
|
@ -156,27 +170,87 @@ jobs:
|
|||
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Set PULUMI_TEST_SUBSET env var
|
||||
run: |
|
||||
echo "PULUMI_TEST_SUBSET=${{ matrix.test-subset }}" >> $GITHUB_ENV
|
||||
- name: Set up Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v1
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Uninstall pre-installed Pulumi (windows)
|
||||
if: ${{ matrix.platform == 'windows-latest' }}
|
||||
run: |
|
||||
chocolatey uninstall pulumi
|
||||
- name: Download Pulumi Go Binaries (linux-x64)
|
||||
if: ${{ matrix.platform == 'ubuntu-latest' }}
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: pulumi-linux-x64.tar.gz
|
||||
path: artifacts/go
|
||||
- name: Download Pulumi Go Binaries (darwin-x64)
|
||||
if: ${{ matrix.platform == 'macos-latest' }}
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: pulumi-darwin-x64.tar.gz
|
||||
path: artifacts/go
|
||||
- name: Download Pulumi Go Binaries (windows-x64)
|
||||
if: ${{ matrix.platform == 'windows-latest' }}
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: pulumi-windows-x64.zip
|
||||
path: artifacts/go
|
||||
- name: Install Pulumi Go Binaries (non-windows)
|
||||
if: ${{ matrix.platform != 'windows-latest' }}
|
||||
run: |
|
||||
mkdir -p bin
|
||||
tar -xf artifacts/go/*.tar.gz -C bin
|
||||
- name: Install Pulumi Go Binaries (windows)
|
||||
if: ${{ matrix.platform == 'windows-latest' }}
|
||||
run: |
|
||||
mkdir -p $PWD/bin
|
||||
unzip -d $PWD/bin artifacts/go/*.zip
|
||||
mv $PWD/bin/pulumi/bin/* $PWD/bin
|
||||
rm -rf $PWD/bin/pulumi
|
||||
echo "Checking contents of $PWD/bin"
|
||||
find $PWD/bin
|
||||
- name: Add ./bin to PATH
|
||||
run: |
|
||||
LOCAL_PATH=$(./scripts/normpath "${{ github.workspace }}/bin")
|
||||
echo "Adding LOCAL_PATH=$LOCAL_PATH to PATH"
|
||||
echo $LOCAL_PATH >> $GITHUB_PATH
|
||||
- name: Verify Pulumi Version
|
||||
run: |
|
||||
which pulumi || echo "no pulumi"
|
||||
pulumi version || echo "no pulumi"
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Diagnose System Path and sub-process Pulumi version
|
||||
run: |
|
||||
python scripts/path.py
|
||||
- name: Set up Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Set PULUMI_TEST_SUBSET env var
|
||||
run: |
|
||||
echo "PULUMI_TEST_SUBSET=${{ matrix.test-subset }}" >> $GITHUB_ENV
|
||||
- name: Install Make
|
||||
if: ${{ matrix.platform == 'windows-latest' }}
|
||||
run: |
|
||||
choco install make
|
||||
- name: Diagnose System Path
|
||||
run: |
|
||||
python scripts/path.py
|
||||
- name: Set up DotNet ${{ matrix.dotnet-version }}
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: ${{ matrix.dotnet-version }}
|
||||
- run: mkdir -p ${{ runner.temp }}/opt/pulumi/nuget
|
||||
- run: dotnet nuget add source ${{ runner.temp }}/opt/pulumi/nuget
|
||||
- name: Set up Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Install yarn
|
||||
run: |
|
||||
npm install -g yarn
|
||||
- name: Install pipenv
|
||||
run: |
|
||||
python -m pip install --upgrade pipenv pip requests wheel urllib3 chardet
|
||||
|
@ -184,13 +258,6 @@ jobs:
|
|||
run: |
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
- name: Update path
|
||||
run: |
|
||||
echo "${{ runner.temp }}/opt/pulumi/bin" >> $GITHUB_PATH
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
git fetch --quiet --prune --unshallow --tags
|
||||
|
@ -201,40 +268,70 @@ jobs:
|
|||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Install gotestsum
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: gotestyourself/gotestsum
|
||||
- name: Install gotestsum from source
|
||||
run: |
|
||||
go install gotest.tools/gotestsum@latest
|
||||
env:
|
||||
GOBIN: ${{ github.workspace }}/bin
|
||||
# Binary installer for gotestsum does not work because the
|
||||
# project distributes tarballs for Windows instead of zips
|
||||
# expected by the action.
|
||||
#
|
||||
# - name: Install gotestsum
|
||||
# uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
# with:
|
||||
# repo: gotestyourself/gotestsum
|
||||
# tag: v1.7.0
|
||||
- name: Install goteststats
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: t0yv0/goteststats
|
||||
tag: v0.0.7
|
||||
- name: Ensure
|
||||
- name: Download Pulumi .NET NuGet packages
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: pulumi-nuget-packages
|
||||
# path set to match PULUMI_LOCAL_NUGET
|
||||
path: ${{ github.workspace }}/nuget
|
||||
- name: Add NuGet packages as a local NuGet source
|
||||
run: |
|
||||
echo "PULUMI_LOCAL_NUGET=$PULUMI_LOCAL_NUGET"
|
||||
SOURCE=$(./scripts/normpath $PULUMI_LOCAL_NUGET)
|
||||
echo "SOURCE=$SOURCE"
|
||||
dotnet nuget add source $SOURCE
|
||||
env:
|
||||
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
|
||||
- name: Inspect downloaded artifacts
|
||||
run: |
|
||||
find artifacts
|
||||
echo "PULUMI_LOCAL_NUGET=$PULUMI_LOCAL_NUGET"
|
||||
ls $PULUMI_LOCAL_NUGET
|
||||
env:
|
||||
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
|
||||
- name: Ensure dependencies for the Node SDK
|
||||
run: |
|
||||
cd sdk/nodejs
|
||||
make ensure
|
||||
- name: Dist
|
||||
- name: Build the Node SDK
|
||||
run: |
|
||||
make dist
|
||||
env:
|
||||
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
|
||||
PULUMI_LOCAL_NUGET: ${{ runner.temp }}/opt/pulumi/nuget
|
||||
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
|
||||
- name: Install
|
||||
cd sdk/nodejs
|
||||
make build_package
|
||||
cd bin
|
||||
yarn link
|
||||
- name: Ensure dependencies for the Python SDK
|
||||
run: |
|
||||
make install_all
|
||||
# Install Pulumi Python SDK globally (on CI only) to workaround a
|
||||
# problem a sub-process in a test failing to find it.
|
||||
python -m pip install -e sdk/python/env/src
|
||||
env:
|
||||
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
|
||||
PULUMI_LOCAL_NUGET: ${{ runner.temp }}/opt/pulumi/nuget
|
||||
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
|
||||
cd sdk/python
|
||||
make ensure
|
||||
- name: Install Python SDK
|
||||
run: |
|
||||
cd sdk/python
|
||||
make build_package
|
||||
- name: Test
|
||||
run: make TEST_ALL_DEPS= test_all
|
||||
env:
|
||||
PULUMI_HOME: ${{ github.workspace }}/home
|
||||
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
|
||||
PULUMI_LOCAL_NUGET: ${{ runner.temp }}/opt/pulumi/nuget
|
||||
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
|
||||
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
|
||||
- name: Summarize Test Time by Package
|
||||
run: |
|
||||
|
@ -245,95 +342,101 @@ jobs:
|
|||
run: |
|
||||
goteststats -statistic test-time test-results/*.json | head -n 100
|
||||
|
||||
|
||||
windows-build:
|
||||
name: Windows Build + Test
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.17.x]
|
||||
node-version: [14.x]
|
||||
python-version: [3.9.x]
|
||||
dotnet: [3.1.x]
|
||||
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
GOPATH: ${{ github.workspace }}
|
||||
PULUMI_LOCAL_NUGET: "D:\\Pulumi\\nuget"
|
||||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
||||
steps:
|
||||
- name: Install DotNet ${{ matrix.dotnet }}
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: ${{ matrix.dotnet }}
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Set up Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install Python Deps
|
||||
run: |
|
||||
pip3 install pyenv-win
|
||||
pip3 install pipenv
|
||||
- name: Create Local Nuget
|
||||
run: mkdir -p "${{ env.PULUMI_LOCAL_NUGET }}"
|
||||
shell: bash
|
||||
- run: dotnet nuget add source ${{ env.PULUMI_LOCAL_NUGET }}
|
||||
- name: Set Build Env Vars
|
||||
shell: bash
|
||||
run: |
|
||||
echo "D:\\Pulumi\\bin" >> $GITHUB_PATH
|
||||
- name: Install AWS CLI Tools
|
||||
uses: chrislennon/action-aws-cli@v1.1
|
||||
- name: Install pulumictl
|
||||
uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
with:
|
||||
repo: pulumi/pulumictl
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: ./src/github.com/${{ github.repository }}
|
||||
ref: ${{ env.PR_COMMIT_SHA }}
|
||||
- name: Fetch Tags
|
||||
run: |
|
||||
cd ./src/github.com/${{ github.repository }} && git fetch --quiet --prune --unshallow --tags
|
||||
- name: Clean
|
||||
run: dotnet nuget locals all --clear
|
||||
- name: Create Local Nuget
|
||||
run: mkdir -p "D:\\Pulumi\\nuget"
|
||||
shell: bash
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
cd src\github.com\${{ github.repository }}
|
||||
pushd .
|
||||
cd sdk
|
||||
go mod download
|
||||
popd
|
||||
pushd .
|
||||
cd pkg
|
||||
go mod download
|
||||
popd
|
||||
pushd .
|
||||
cd tests
|
||||
go mod download
|
||||
popd
|
||||
- name: Build Pulumi
|
||||
run: |
|
||||
cd src\github.com\${{ github.repository }}
|
||||
dotnet msbuild /t:Build /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" /p:PythonVersion="${{ matrix.python-version }}"
|
||||
- run: |
|
||||
which pulumi
|
||||
pulumi version
|
||||
shell: bash
|
||||
- name: Run Pulumi Tests
|
||||
env:
|
||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
run: |
|
||||
cd src\github.com\${{ github.repository }}
|
||||
dotnet msbuild /t:Tests /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" /p:PythonVersion="${{ matrix.python-version }}"
|
||||
# windows-build:
|
||||
# name: Windows Build + Test
|
||||
# strategy:
|
||||
# matrix:
|
||||
# go-version: [1.17.x]
|
||||
# node-version: [14.x]
|
||||
# python-version: [3.9.x]
|
||||
# dotnet: [3.1.x]
|
||||
# if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
|
||||
# runs-on: windows-latest
|
||||
# env:
|
||||
# GOPATH: ${{ github.workspace }}
|
||||
# PULUMI_LOCAL_NUGET: "D:\\Pulumi\\nuget"
|
||||
# ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
||||
# steps:
|
||||
# - name: Checkout Repo
|
||||
# uses: actions/checkout@v2
|
||||
# with:
|
||||
# ref: ${{ env.PR_COMMIT_SHA }}
|
||||
# - name: Test Make
|
||||
# run: |
|
||||
# make -n ensure
|
||||
# # - name: Install DotNet ${{ matrix.dotnet }}
|
||||
# # uses: actions/setup-dotnet@v1
|
||||
# # with:
|
||||
# # dotnet-version: ${{ matrix.dotnet }}
|
||||
# # - name: Use Node.js ${{ matrix.node-version }}
|
||||
# # uses: actions/setup-node@v1
|
||||
# # with:
|
||||
# # node-version: ${{ matrix.node-version }}
|
||||
# # - name: Set up Go ${{ matrix.go-version }}
|
||||
# # uses: actions/setup-go@v1
|
||||
# # with:
|
||||
# # go-version: ${{ matrix.go-version }}
|
||||
# # - name: Set up Python ${{ matrix.python-version }}
|
||||
# # uses: actions/setup-python@v2
|
||||
# # with:
|
||||
# # python-version: ${{ matrix.python-version }}
|
||||
# # - name: Install Python Deps
|
||||
# # run: |
|
||||
# # pip3 install pyenv-win
|
||||
# # pip3 install pipenv
|
||||
# # - name: Create Local Nuget
|
||||
# # run: mkdir -p "${{ env.PULUMI_LOCAL_NUGET }}"
|
||||
# # shell: bash
|
||||
# # - run: dotnet nuget add source ${{ env.PULUMI_LOCAL_NUGET }}
|
||||
# # - name: Set Build Env Vars
|
||||
# # shell: bash
|
||||
# # run: |
|
||||
# # echo "D:\\Pulumi\\bin" >> $GITHUB_PATH
|
||||
# # - name: Install AWS CLI Tools
|
||||
# # uses: chrislennon/action-aws-cli@v1.1
|
||||
# # - name: Install pulumictl
|
||||
# # uses: jaxxstorm/action-install-gh-release@v1.2.0
|
||||
# # with:
|
||||
# # repo: pulumi/pulumictl
|
||||
# # - name: Check out code into the Go module directory
|
||||
# # uses: actions/checkout@v2
|
||||
# # with:
|
||||
# # path: ./src/github.com/${{ github.repository }}
|
||||
# # ref: ${{ env.PR_COMMIT_SHA }}
|
||||
# # - name: Fetch Tags
|
||||
# # run: |
|
||||
# # cd ./src/github.com/${{ github.repository }} && git fetch --quiet --prune --unshallow --tags
|
||||
# # - name: Clean
|
||||
# # run: dotnet nuget locals all --clear
|
||||
# # - name: Create Local Nuget
|
||||
# # run: mkdir -p "D:\\Pulumi\\nuget"
|
||||
# # shell: bash
|
||||
# # - name: Get dependencies
|
||||
# # run: |
|
||||
# # cd src\github.com\${{ github.repository }}
|
||||
# # pushd .
|
||||
# # cd sdk
|
||||
# # go mod download
|
||||
# # popd
|
||||
# # pushd .
|
||||
# # cd pkg
|
||||
# # go mod download
|
||||
# # popd
|
||||
# # pushd .
|
||||
# # cd tests
|
||||
# # go mod download
|
||||
# # popd
|
||||
# # - name: Build Pulumi
|
||||
# # run: |
|
||||
# # cd src\github.com\${{ github.repository }}
|
||||
# # dotnet msbuild /t:Build /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" /p:PythonVersion="${{ matrix.python-version }}"
|
||||
# # - run: |
|
||||
# # which pulumi
|
||||
# # pulumi version
|
||||
# # shell: bash
|
||||
# # - name: Run Pulumi Tests
|
||||
# # env:
|
||||
# # PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
# # run: |
|
||||
# # cd src\github.com\${{ github.repository }}
|
||||
# # dotnet msbuild /t:Tests /v:Detailed build.proj /p:PulumiRoot="D:\\Pulumi" /p:PythonVersion="${{ matrix.python-version }}"
|
||||
|
|
169
.goreleaser.build.yml
Normal file
169
.goreleaser.build.yml
Normal file
|
@ -0,0 +1,169 @@
|
|||
dist: goreleaser
|
||||
project_name: pulumi
|
||||
before:
|
||||
hooks:
|
||||
- ./scripts/prep-for-goreleaser.sh
|
||||
release:
|
||||
disable: true
|
||||
changelog:
|
||||
skip: true
|
||||
builds:
|
||||
# Windows builds
|
||||
- id: pulumi-windows
|
||||
binary: pulumi
|
||||
dir: pkg
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- windows
|
||||
ldflags:
|
||||
- -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
main: ./cmd/pulumi
|
||||
- id: pulumi-language-nodejs-windows
|
||||
binary: pulumi-language-nodejs
|
||||
dir: sdk
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- windows
|
||||
ldflags:
|
||||
- -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
main: ./nodejs/cmd/pulumi-language-nodejs
|
||||
- id: pulumi-language-python-windows
|
||||
binary: pulumi-language-python
|
||||
dir: sdk
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- windows
|
||||
ldflags:
|
||||
- -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
main: ./python/cmd/pulumi-language-python
|
||||
- id: pulumi-language-dotnet-windows
|
||||
binary: pulumi-language-dotnet
|
||||
dir: sdk
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- windows
|
||||
ldflags:
|
||||
- -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
main: ./dotnet/cmd/pulumi-language-dotnet
|
||||
- id: pulumi-language-go-windows
|
||||
binary: pulumi-language-go
|
||||
dir: sdk
|
||||
goarch:
|
||||
- amd64
|
||||
goos:
|
||||
- windows
|
||||
ldflags:
|
||||
- -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
main: ./go/pulumi-language-go
|
||||
|
||||
|
||||
|
||||
# UNIX builds
|
||||
# - id: pulumi-unix
|
||||
# binary: pulumi
|
||||
# dir: pkg
|
||||
# goarch:
|
||||
# - amd64
|
||||
# - arm64
|
||||
# goos:
|
||||
# - linux
|
||||
# - darwin
|
||||
# ldflags:
|
||||
# - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
# main: ./cmd/pulumi
|
||||
# - id: pulumi-language-nodejs-unix
|
||||
# binary: pulumi-language-nodejs
|
||||
# dir: sdk
|
||||
# goarch:
|
||||
# - amd64
|
||||
# - arm64
|
||||
# goos:
|
||||
# - linux
|
||||
# - darwin
|
||||
# ldflags:
|
||||
# - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
# main: ./nodejs/cmd/pulumi-language-nodejs
|
||||
# - id: pulumi-language-python-unix
|
||||
# binary: pulumi-language-python
|
||||
# dir: sdk
|
||||
# goarch:
|
||||
# - amd64
|
||||
# - arm64
|
||||
# goos:
|
||||
# - linux
|
||||
# - darwin
|
||||
# ldflags:
|
||||
# - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
# main: ./python/cmd/pulumi-language-python
|
||||
# - id: pulumi-language-dotnet-unix
|
||||
# binary: pulumi-language-dotnet
|
||||
# dir: sdk
|
||||
# goarch:
|
||||
# - amd64
|
||||
# - arm64
|
||||
# goos:
|
||||
# - linux
|
||||
# - darwin
|
||||
# ldflags:
|
||||
# - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
# main: ./dotnet/cmd/pulumi-language-dotnet
|
||||
# - id: pulumi-language-go-unix
|
||||
# binary: pulumi-language-go
|
||||
# dir: sdk
|
||||
# goarch:
|
||||
# - amd64
|
||||
# - arm64
|
||||
# goos:
|
||||
# - linux
|
||||
# - darwin
|
||||
# ldflags:
|
||||
# - -X github.com/pulumi/pulumi/pkg/v3/version.Version={{.Tag}}
|
||||
# main: ./go/pulumi-language-go
|
||||
|
||||
|
||||
archives:
|
||||
# - id: pulumi-unix
|
||||
# wrap_in_directory: pulumi
|
||||
# builds:
|
||||
# - pulumi-language-dotnet-unix
|
||||
# - pulumi-language-go-unix
|
||||
# - pulumi-language-python-unix
|
||||
# - pulumi-language-nodejs-unix
|
||||
# - pulumi-unix
|
||||
# replacements:
|
||||
# amd64: x64
|
||||
# files:
|
||||
# - pulumi-resource-pulumi-nodejs
|
||||
# - pulumi-resource-pulumi-python
|
||||
# - pulumi-analyzer-policy
|
||||
# - pulumi-analyzer-policy-python
|
||||
# - pulumi-language-python-exec
|
||||
# name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
|
||||
- id: pulumi-windows
|
||||
wrap_in_directory: pulumi/bin
|
||||
builds:
|
||||
- pulumi-language-dotnet-windows
|
||||
- pulumi-language-go-windows
|
||||
- pulumi-language-python-windows
|
||||
- pulumi-language-nodejs-windows
|
||||
- pulumi-windows
|
||||
replacements:
|
||||
amd64: x64
|
||||
format: zip
|
||||
files:
|
||||
- pulumi-resource-pulumi-nodejs.cmd
|
||||
- pulumi-resource-pulumi-python.cmd
|
||||
- pulumi-python3-shim.cmd
|
||||
- pulumi-python-shim.cmd
|
||||
- pulumi-analyzer-policy.cmd
|
||||
- pulumi-analyzer-policy-python.cmd
|
||||
- pulumi-language-python-exec
|
||||
name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
|
||||
snapshot:
|
||||
name_template: "{{ .Version }}-SNAPSHOT"
|
||||
checksum:
|
||||
name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt"
|
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -1,43 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
## 3.18.1 (2021-11-22)
|
||||
|
||||
### Improvements
|
||||
|
||||
- [cli] - When running `pulumi new https://github.com/name/repo`, check
|
||||
for branch `main` if branch `master` doesn't exist.
|
||||
[#8463](https://github.com/pulumi/pulumi/pull/8463)
|
||||
|
||||
- [codegen/python] - Program generator now uses `fn_output` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8433](https://github.com/pulumi/pulumi/pull/8433)
|
||||
|
||||
- [codegen/go] - Program generator now uses fnOutput forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8431](https://github.com/pulumi/pulumi/pull/8431)
|
||||
|
||||
- [codegen/dotnet] - Program generator now uses `Invoke` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8432](https://github.com/pulumi/pulumi/pull/8432)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [cli/nodejs] - Allow specifying the tsconfig file used in Pulumi.yaml.
|
||||
[#8452](https://github.com/pulumi/pulumi/pull/8452)
|
||||
|
||||
- [codegen/nodejs] - Respect default values in Pulumi object types.
|
||||
[#8400](https://github.com/pulumi/pulumi/pull/8400)
|
||||
|
||||
- [sdk/python] - Correctly handle version checking python virtual environments.
|
||||
[#8465](https://github.com/pulumi/pulumi/pull/8465)
|
||||
|
||||
- [cli] - Catch expected errors in stacks with filestate backends.
|
||||
[#8455](https://github.com/pulumi/pulumi/pull/8455)
|
||||
|
||||
- [sdk/dotnet] - Do not attempt to serialize unknown values.
|
||||
[#8475](https://github.com/pulumi/pulumi/pull/8475)
|
||||
|
||||
## 3.18.0 (2021-11-17)
|
||||
|
||||
### Improvements
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
### Improvements
|
||||
|
||||
- [codegen/go] - Remove `ResourcePtr` types from generated SDKs. Besides being
|
||||
unnecessary--`Resource` types already accommodate `nil` to indicate the lack of
|
||||
a value--the implementation of `Ptr` types for resources was incorrect, making
|
||||
these types virtually unusable in practice.
|
||||
[#8449](https://github.com/pulumi/pulumi/pull/8449)
|
||||
- [cli] - When running `pulumi new https://github.com/name/repo`, check
|
||||
for branch `main` if branch `master` doesn't exist.
|
||||
[#8463](https://github.com/pulumi/pulumi/pull/8463)
|
||||
|
||||
- [codegen/python] - Program generator now uses `fn_output` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8433](https://github.com/pulumi/pulumi/pull/8433)
|
||||
|
||||
- [codegen/go] - Program generator now uses fnOutput forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8431](https://github.com/pulumi/pulumi/pull/8431)
|
||||
|
||||
- [codegen/dotnet] - Program generator now uses `Invoke` forms where
|
||||
appropriate, simplifying auto-generated examples.
|
||||
[#8432](https://github.com/pulumi/pulumi/pull/8432)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [codegen/go] - Respect default values in Pulumi object types.
|
||||
[#8411](https://github.com/pulumi/pulumi/pull/8400)
|
||||
- [codegen/typescript] - Respect default values in Pulumi object types.
|
||||
[#8400](https://github.com/pulumi/pulumi/pull/8400)
|
||||
|
||||
- [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)
|
||||
|
|
|
@ -22,7 +22,7 @@ To hack on Pulumi, you'll need to get a development environment set up. You'll w
|
|||
You can easily get all required dependencies with brew and npm
|
||||
|
||||
```bash
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl coreutils
|
||||
brew install node pipenv python@3 typescript yarn go@1.17 golangci/tap/golangci-lint pulumi/tap/pulumictl
|
||||
curl https://raw.githubusercontent.com/Homebrew/homebrew-cask/0272f0d33f/Casks/dotnet-sdk.rb > dotnet-sdk.rb # v3.1.0
|
||||
brew install --HEAD -s dotnet-sdk.rb
|
||||
rm dotnet-sdk.rb
|
||||
|
@ -53,10 +53,9 @@ ulimit -n 5000
|
|||
|
||||
Across our projects, we try to use a regular set of make targets. The ones you'll care most about are:
|
||||
|
||||
1. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make dist`, which just builds and installs the Pulumi CLI
|
||||
0. `make ensure`, which restores/installs any build dependencies
|
||||
1. `make`, which builds Pulumi and runs a quick set of tests
|
||||
1. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
2. `make all` which builds Pulumi and runs the quick tests and a larger set of tests.
|
||||
|
||||
We make heavy use of integration level testing where we invoke `pulumi` to create and then delete cloud resources. This requires you to have a Pulumi account (so [sign up for free](https://pulumi.com) today if you haven't already) and login with `pulumi login`.
|
||||
|
||||
|
|
4
Makefile
4
Makefile
|
@ -89,3 +89,7 @@ test_build:: $(TEST_ALL_DEPS)
|
|||
test_all:: test_build
|
||||
cd pkg && $(GO_TEST) ${PROJECT_PKGS}
|
||||
cd tests && $(GO_TEST) -p=1 ${TESTS_PKGS}
|
||||
|
||||
|
||||
check_python_version::
|
||||
python --version
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -101,18 +101,17 @@ ifeq ($(PULUMI_ROOT),)
|
|||
PULUMI_ROOT:=$(shell realpath "$$HOME/.pulumi")
|
||||
endif
|
||||
|
||||
# Use Python 3 explicitly vs expecting that `python` will resolve to a python 3
|
||||
# runtime.
|
||||
PYTHON ?= python3
|
||||
PIP ?= pip3
|
||||
# Expecting that `python`, `pip` will resolve to a python 3 runtime.
|
||||
PYTHON ?= python
|
||||
PIP ?= pip
|
||||
|
||||
PULUMI_BIN := $(PULUMI_ROOT)/bin
|
||||
PULUMI_NODE_MODULES := $(PULUMI_ROOT)/node_modules
|
||||
PULUMI_NUGET := $(PULUMI_ROOT)/nuget
|
||||
|
||||
RUN_TESTSUITE = python3 ${PROJECT_ROOT}/scripts/run-testsuite.py
|
||||
GO_TEST_FAST = PATH="$(PULUMI_BIN):$(PATH)" python3 ${PROJECT_ROOT}/scripts/go-test.py -short -count=1 -cover -tags=all -timeout 1h -parallel ${TESTPARALLELISM}
|
||||
GO_TEST = PATH="$(PULUMI_BIN):$(PATH)" python3 $(PROJECT_ROOT)/scripts/go-test.py -count=1 -cover -timeout 1h -tags=all -parallel ${TESTPARALLELISM}
|
||||
TESTSUITE_SKIPPED = python ${PROJECT_ROOT}/scripts/skipped.py
|
||||
GO_TEST_FAST = python ${PROJECT_ROOT}/scripts/go-test.py -short -count=1 -cover -tags=all -timeout 1h -parallel ${TESTPARALLELISM}
|
||||
GO_TEST = python $(PROJECT_ROOT)/scripts/go-test.py -count=1 -cover -timeout 1h -tags=all -parallel ${TESTPARALLELISM}
|
||||
GOPROXY = 'https://proxy.golang.org'
|
||||
|
||||
.PHONY: default all ensure only_build only_test build lint install test_all core
|
||||
|
|
|
@ -114,9 +114,6 @@ type pkgContext struct {
|
|||
|
||||
// Determines if we should emit type registration code
|
||||
disableInputTypeRegistrations bool
|
||||
|
||||
// Determines if we should emit object defaults code
|
||||
disableObjectDefaults bool
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) detailsForType(t schema.Type) *typeDetails {
|
||||
|
@ -272,7 +269,6 @@ func rawResourceName(r *schema.Resource) string {
|
|||
return tokenToName(r.Token)
|
||||
}
|
||||
|
||||
// If `nil` is a valid value of type `t`.
|
||||
func isNilType(t schema.Type) bool {
|
||||
switch t := t.(type) {
|
||||
case *schema.OptionalType, *schema.ArrayType, *schema.MapType, *schema.ResourceType, *schema.InputType:
|
||||
|
@ -299,6 +295,23 @@ func isNilType(t schema.Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// The default value for a Pulumi primitive type.
|
||||
func primitiveNilValue(t schema.Type) string {
|
||||
contract.Assert(schema.IsPrimitiveType(t))
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
return "false"
|
||||
case schema.IntType:
|
||||
return "0"
|
||||
case schema.NumberType:
|
||||
return "0.0"
|
||||
case schema.StringType:
|
||||
return "\"\""
|
||||
default:
|
||||
return "nil"
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
|
||||
switch t := codegen.SimplifyInputUnion(t).(type) {
|
||||
case *schema.OptionalType:
|
||||
|
@ -500,12 +513,7 @@ func (pkg *pkgContext) typeStringImpl(t schema.Type, argsType bool) string {
|
|||
}
|
||||
|
||||
func (pkg *pkgContext) typeString(t schema.Type) string {
|
||||
s := pkg.typeStringImpl(t, false)
|
||||
if s == "pulumi." {
|
||||
return "pulumi.Any"
|
||||
}
|
||||
return s
|
||||
|
||||
return pkg.typeStringImpl(t, false)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) isExternalReference(t schema.Type) bool {
|
||||
|
@ -625,9 +633,6 @@ func (pkg *pkgContext) outputType(t schema.Type) string {
|
|||
}
|
||||
// TODO(pdg): union types
|
||||
return "pulumi.AnyOutput"
|
||||
case *schema.InputType:
|
||||
// We can't make output types for input types. We instead strip the input and try again.
|
||||
return pkg.outputType(t.ElementType)
|
||||
default:
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
|
@ -779,14 +784,16 @@ type genInputImplementationArgs struct {
|
|||
elementType string
|
||||
ptrMethods bool
|
||||
toOutputMethods bool
|
||||
resourceType bool
|
||||
}
|
||||
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods bool) {
|
||||
func genInputImplementation(w io.Writer, name, receiverType, elementType string, ptrMethods, resourceType bool) {
|
||||
genInputImplementationWithArgs(w, genInputImplementationArgs{
|
||||
name: name,
|
||||
receiverType: receiverType,
|
||||
elementType: elementType,
|
||||
ptrMethods: ptrMethods,
|
||||
resourceType: resourceType,
|
||||
toOutputMethods: true,
|
||||
})
|
||||
}
|
||||
|
@ -795,9 +802,14 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
name := genArgs.name
|
||||
receiverType := genArgs.receiverType
|
||||
elementType := genArgs.elementType
|
||||
resourceType := genArgs.resourceType
|
||||
|
||||
fmt.Fprintf(w, "func (%s) ElementType() reflect.Type {\n", receiverType)
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
if genArgs.toOutputMethods {
|
||||
|
@ -825,11 +837,15 @@ func genInputImplementationWithArgs(w io.Writer, genArgs genInputImplementationA
|
|||
}
|
||||
}
|
||||
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
||||
func genOutputType(w io.Writer, baseName, elementType string, ptrMethods, resourceType bool) {
|
||||
fmt.Fprintf(w, "type %sOutput struct { *pulumi.OutputState }\n\n", baseName)
|
||||
|
||||
fmt.Fprintf(w, "func (%sOutput) ElementType() reflect.Type {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
if resourceType {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil))\n", elementType)
|
||||
} else {
|
||||
fmt.Fprintf(w, "\treturn reflect.TypeOf((*%s)(nil)).Elem()\n", elementType)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[1]sOutput {\n", baseName, Title(baseName))
|
||||
|
@ -853,8 +869,8 @@ func genOutputType(w io.Writer, baseName, elementType string, ptrMethods bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false)
|
||||
func genArrayOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Array", "[]"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", elementType)
|
||||
|
@ -863,8 +879,8 @@ func genArrayOutput(w io.Writer, baseName, elementType string) {
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genMapOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false)
|
||||
func genMapOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Map", "map[string]"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s{\n", elementType)
|
||||
|
@ -873,8 +889,8 @@ func genMapOutput(w io.Writer, baseName, elementType string) {
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false)
|
||||
func genPtrOutput(w io.Writer, baseName, elementType string, resourceType bool) {
|
||||
genOutputType(w, baseName+"Ptr", "*"+elementType, false, resourceType)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) Elem() %[1]sOutput {\n", baseName)
|
||||
fmt.Fprintf(w, "\treturn o.ApplyT(func(v *%[1]s) %[1]s {\n", baseName)
|
||||
|
@ -940,7 +956,7 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -949,24 +965,24 @@ func (pkg *pkgContext) genEnum(w io.Writer, enumType *schema.EnumType) error {
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]s\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the array output
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name)
|
||||
genArrayOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
// Generate the map output.
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name)
|
||||
genMapOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, elementGoType, asFuncName string) {
|
||||
genOutputType(w, name, name, true)
|
||||
genOutputType(w, name, name, true, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sOutput() %[3]sOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -989,7 +1005,7 @@ func (pkg *pkgContext) genEnumOutputTypes(w io.Writer, name, elementArgsType, el
|
|||
fmt.Fprintf(w, "}).(%sPtrOutput)\n", elementArgsType)
|
||||
fmt.Fprint(w, "}\n\n")
|
||||
|
||||
genPtrOutput(w, name, name)
|
||||
genPtrOutput(w, name, name, false)
|
||||
|
||||
fmt.Fprintf(w, "func (o %[1]sPtrOutput) To%[2]sPtrOutput() %[3]sPtrOutput {\n", name, asFuncName, elementArgsType)
|
||||
fmt.Fprintf(w, "return o.To%sPtrOutputWithContext(context.Background())\n", asFuncName)
|
||||
|
@ -1091,27 +1107,6 @@ func (pkg *pkgContext) genEnumInputFuncs(w io.Writer, typeName string, enum *sch
|
|||
fmt.Fprintln(w)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) assignProperty(w io.Writer, p *schema.Property, object, value string, indirectAssign bool) {
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = ""
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
if t != "" {
|
||||
value = fmt.Sprintf("%s(%s)", t, value)
|
||||
}
|
||||
fmt.Fprintf(w, "\targs.%s = %s\n", Title(p.Name), value)
|
||||
} else if indirectAssign {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s := %s\n", tmpName, value)
|
||||
fmt.Fprintf(w, "%s.%s = &%s\n", object, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%s.%s = %s\n", object, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessage string,
|
||||
properties []*schema.Property) {
|
||||
|
||||
|
@ -1124,66 +1119,6 @@ func (pkg *pkgContext) genPlainType(w io.Writer, name, comment, deprecationMessa
|
|||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genPlainObjectDefaultFunc(w io.Writer, name string,
|
||||
properties []*schema.Property) error {
|
||||
defaults := []*schema.Property{}
|
||||
for _, p := range properties {
|
||||
if p.DefaultValue != nil || codegen.IsProvideDefaultsFuncRequired(p.Type) {
|
||||
defaults = append(defaults, p)
|
||||
}
|
||||
}
|
||||
|
||||
// There are no defaults, so we don't need to generate a defaults function.
|
||||
if len(defaults) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
printComment(w, fmt.Sprintf("%s sets the appropriate defaults for %s", ProvideDefaultsMethodName, name), false)
|
||||
fmt.Fprintf(w, "func (val *%[1]s) %[2]s() *%[1]s {\n", name, ProvideDefaultsMethodName)
|
||||
fmt.Fprint(w, "if val == nil {\n return nil\n}\n")
|
||||
fmt.Fprint(w, "tmp := *val\n")
|
||||
for _, p := range defaults {
|
||||
if p.DefaultValue != nil {
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "if isZero(tmp.%s) {\n", Title(p.Name))
|
||||
pkg.assignProperty(w, p, "tmp", dv, !p.IsRequired())
|
||||
fmt.Fprintf(w, "}\n")
|
||||
} else if funcName := pkg.provideDefaultsFuncName(p.Type); funcName != "" {
|
||||
var member string
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
f := fmt.Sprintf("func(v %[1]s) %[1]s { return v.%[2]s*() }", name, funcName)
|
||||
member = fmt.Sprintf("tmp.%[1]s.ApplyT(%[2]s)\n", Title(p.Name), f)
|
||||
} else {
|
||||
member = fmt.Sprintf("tmp.%[1]s.%[2]s()\n", Title(p.Name), funcName)
|
||||
}
|
||||
sigil := ""
|
||||
if p.IsRequired() {
|
||||
sigil = "*"
|
||||
}
|
||||
pkg.assignProperty(w, p, "tmp", sigil+member, false)
|
||||
} else {
|
||||
panic(fmt.Sprintf("Property %s[%s] should not be in the default list", p.Name, p.Type.String()))
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "return &tmp\n}\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// The name of the method used to instantiate defaults.
|
||||
const ProvideDefaultsMethodName = "Defaults"
|
||||
|
||||
func (pkg *pkgContext) provideDefaultsFuncName(typ schema.Type) string {
|
||||
if !codegen.IsProvideDefaultsFuncRequired(typ) {
|
||||
return ""
|
||||
}
|
||||
return ProvideDefaultsMethodName
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details *typeDetails) {
|
||||
contract.Assert(t.IsInputShape())
|
||||
|
||||
|
@ -1194,7 +1129,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
pkg.genInputArgsStruct(w, name+"Args", t)
|
||||
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement)
|
||||
genInputImplementation(w, name, name+"Args", name, details.ptrElement, false)
|
||||
|
||||
// Generate the pointer input.
|
||||
if details.ptrElement {
|
||||
|
@ -1208,7 +1143,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
fmt.Fprintf(w, "\treturn (*%s)(v)\n", ptrTypeName)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the array input.
|
||||
|
@ -1217,7 +1152,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]"+name, false, false)
|
||||
}
|
||||
|
||||
// Generate the map input.
|
||||
|
@ -1226,7 +1161,7 @@ func (pkg *pkgContext) genInputTypes(w io.Writer, t *schema.ObjectType, details
|
|||
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]"+name, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1265,6 +1200,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
name, /* baseName */
|
||||
name, /* elementType */
|
||||
details.ptrElement, /* ptrMethods */
|
||||
false, /* resourceType */
|
||||
)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
|
@ -1283,7 +1219,7 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.ptrElement {
|
||||
genPtrOutput(w, name, name)
|
||||
genPtrOutput(w, name, name, false)
|
||||
|
||||
for _, p := range t.Properties {
|
||||
printCommentWithDeprecationMessage(w, p.Comment, p.DeprecationMessage, false)
|
||||
|
@ -1316,11 +1252,11 @@ func (pkg *pkgContext) genOutputTypes(w io.Writer, genArgs genOutputTypesArgs) {
|
|||
}
|
||||
|
||||
if details.arrayElement {
|
||||
genArrayOutput(w, name, name)
|
||||
genArrayOutput(w, name, name, false)
|
||||
}
|
||||
|
||||
if details.mapElement {
|
||||
genMapOutput(w, name, name)
|
||||
genMapOutput(w, name, name, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1374,11 +1310,6 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
|
|||
return "", err
|
||||
}
|
||||
val = v
|
||||
switch t.(type) {
|
||||
case *schema.EnumType:
|
||||
typeName := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(t)), "Input")
|
||||
val = fmt.Sprintf("%s(%s)", typeName, val)
|
||||
}
|
||||
}
|
||||
|
||||
if len(dv.Environment) > 0 {
|
||||
|
@ -1462,8 +1393,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\t}\n\n")
|
||||
|
||||
// Produce the inputs.
|
||||
|
||||
// Check all required inputs are present
|
||||
for _, p := range r.InputProperties {
|
||||
if p.IsRequired() && isNilType(p.Type) && p.DefaultValue == nil {
|
||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||
|
@ -1472,8 +1401,26 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
}
|
||||
}
|
||||
|
||||
assign := func(p *schema.Property, value string) {
|
||||
pkg.assignProperty(w, p, "args", value, isNilType(p.Type))
|
||||
assign := func(p *schema.Property, value string, indentation int) {
|
||||
ind := strings.Repeat("\t", indentation)
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = strings.TrimSuffix(t, "Ptr")
|
||||
}
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, value)
|
||||
} else if isNilType(p.Type) {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s%s := %s\n", ind, tmpName, value)
|
||||
fmt.Fprintf(w, "%sargs.%s = &%s\n", ind, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%sargs.%s = %s\n", ind, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range r.InputProperties {
|
||||
|
@ -1482,51 +1429,19 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assign(p, v)
|
||||
assign(p, v, 1)
|
||||
} else if p.DefaultValue != nil {
|
||||
dv, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pkg.needsUtils = true
|
||||
fmt.Fprintf(w, "\tif isZero(args.%s) {\n", Title(p.Name))
|
||||
assign(p, dv)
|
||||
defaultComp := "nil"
|
||||
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
|
||||
defaultComp = primitiveNilValue(p.Type)
|
||||
}
|
||||
fmt.Fprintf(w, "\tif args.%s == %s {\n", Title(p.Name), defaultComp)
|
||||
assign(p, v, 2)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
} else if name := pkg.provideDefaultsFuncName(p.Type); name != "" && !pkg.disableObjectDefaults {
|
||||
var value string
|
||||
var needsNilCheck bool
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
innerFuncType := strings.TrimSuffix(pkg.typeString(codegen.UnwrapType(p.Type)), "Args")
|
||||
applyName := fmt.Sprintf("%sApplier", camel(p.Name))
|
||||
fmt.Fprintf(w, "%[3]s := func(v %[1]s) *%[1]s { return v.%[2]s() }\n", innerFuncType, name, applyName)
|
||||
|
||||
outputValue := pkg.convertToOutput(fmt.Sprintf("args.%s", Title(p.Name)), p.Type)
|
||||
outputType := pkg.typeString(p.Type)
|
||||
if strings.HasSuffix(outputType, "Input") {
|
||||
outputType = strings.TrimSuffix(outputType, "Input") + "Output"
|
||||
}
|
||||
|
||||
// Because applies return pointers, we need to convert to PtrOutput and then call .Elem().
|
||||
var tail string
|
||||
if !strings.HasSuffix(outputType, "PtrOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
tail = ".Elem()"
|
||||
}
|
||||
needsNilCheck = !p.IsRequired()
|
||||
value = fmt.Sprintf("%s.ApplyT(%s).(%s)%s", outputValue, applyName, outputType, tail)
|
||||
} else {
|
||||
value = fmt.Sprintf("args.%[1]s.%[2]s()", Title(p.Name), name)
|
||||
}
|
||||
v := func() {
|
||||
fmt.Fprintf(w, "args.%[1]s = %s\n", Title(p.Name), value)
|
||||
}
|
||||
if needsNilCheck {
|
||||
fmt.Fprintf(w, "if args.%s != nil {\n", Title(p.Name))
|
||||
v()
|
||||
fmt.Fprint(w, "}\n")
|
||||
} else {
|
||||
v()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1793,26 +1708,42 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
fmt.Fprintf(w, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
|
||||
genInputImplementation(w, name, "*"+name, "*"+name, false)
|
||||
genInputImplementation(w, name, "*"+name, name, generateResourceContainerTypes, true)
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false)
|
||||
if generateResourceContainerTypes {
|
||||
// Emit the resource pointer input type.
|
||||
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.Input\n\n")
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
ptrTypeName := camel(name) + "PtrType"
|
||||
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
|
||||
genInputImplementation(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
|
||||
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false)
|
||||
if !r.IsProvider {
|
||||
// Generate the resource array input.
|
||||
pkg.genInputInterface(w, name+"Array")
|
||||
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Array", name+"Array", "[]*"+name, false, false)
|
||||
|
||||
// Generate the resource map input.
|
||||
pkg.genInputInterface(w, name+"Map")
|
||||
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
|
||||
genInputImplementation(w, name+"Map", name+"Map", "map[string]*"+name, false, false)
|
||||
}
|
||||
}
|
||||
|
||||
// Emit the resource output type.
|
||||
genOutputType(w, name, "*"+name, false)
|
||||
genOutputType(w, name, name, generateResourceContainerTypes, true)
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
genArrayOutput(w, name, "*"+name)
|
||||
genMapOutput(w, name, "*"+name)
|
||||
if generateResourceContainerTypes {
|
||||
genPtrOutput(w, name, name, true)
|
||||
|
||||
if !r.IsProvider {
|
||||
genArrayOutput(w, name, name, true)
|
||||
genMapOutput(w, name, name, true)
|
||||
}
|
||||
}
|
||||
|
||||
pkg.genResourceRegistrations(w, r, generateResourceContainerTypes)
|
||||
|
@ -1820,30 +1751,6 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
return nil
|
||||
}
|
||||
|
||||
// Takes an expression and type, and returns a string that converts that expression to an Output type.
|
||||
//
|
||||
// Examples:
|
||||
// ("bar", Foo of ObjectType) => "bar.ToFooOutput()"
|
||||
// ("id", FooOutput) => "id"
|
||||
// ("ptr", FooInput of ObjectType) => "ptr.ToFooPtrOutput().Elem()"
|
||||
func (pkg *pkgContext) convertToOutput(expr string, typ schema.Type) string {
|
||||
elemConversion := ""
|
||||
switch typ.(type) {
|
||||
case *schema.OptionalType:
|
||||
elemConversion = ".Elem()"
|
||||
}
|
||||
outputType := pkg.outputType(typ)
|
||||
// Remove any element before the last .
|
||||
outputType = outputType[strings.LastIndex(outputType, ".")+1:]
|
||||
if strings.HasSuffix(outputType, "ArgsOutput") {
|
||||
outputType = strings.TrimSuffix(outputType, "ArgsOutput") + "Output"
|
||||
}
|
||||
if elemConversion != "" {
|
||||
outputType = strings.TrimSuffix(outputType, "Output") + "PtrOutput"
|
||||
}
|
||||
return fmt.Sprintf("%s.To%s()%s", expr, outputType, elemConversion)
|
||||
}
|
||||
|
||||
func NeedsGoOutputVersion(f *schema.Function) bool {
|
||||
fPkg := f.Package
|
||||
|
||||
|
@ -1861,7 +1768,7 @@ func NeedsGoOutputVersion(f *schema.Function) bool {
|
|||
return f.NeedsOutputVersion()
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
||||
func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) string {
|
||||
importsAndAliases := map[string]string{}
|
||||
pkg.getImports(f, importsAndAliases)
|
||||
buffer := &bytes.Buffer{}
|
||||
|
@ -1872,14 +1779,12 @@ func (pkg *pkgContext) genFunctionCodeFile(f *schema.Function) (string, error) {
|
|||
}
|
||||
|
||||
pkg.genHeader(buffer, imports, importsAndAliases)
|
||||
if err := pkg.genFunction(buffer, f); err != nil {
|
||||
return "", err
|
||||
}
|
||||
pkg.genFunction(buffer, f)
|
||||
pkg.genFunctionOutputVersion(buffer, f)
|
||||
return buffer.String(), nil
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
||||
func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) {
|
||||
name := pkg.functionName(f)
|
||||
printCommentWithDeprecationMessage(w, f.Comment, f.DeprecationMessage, false)
|
||||
|
||||
|
@ -1900,8 +1805,6 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
|||
var inputsVar string
|
||||
if f.Inputs == nil {
|
||||
inputsVar = "nil"
|
||||
} else if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
inputsVar = "args.Defaults()"
|
||||
} else {
|
||||
inputsVar = "args"
|
||||
}
|
||||
|
@ -1925,38 +1828,19 @@ func (pkg *pkgContext) genFunction(w io.Writer, f *schema.Function) error {
|
|||
fmt.Fprintf(w, "\t}\n")
|
||||
|
||||
// Return the result.
|
||||
var retValue string
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
retValue = "rv.Defaults()"
|
||||
} else {
|
||||
retValue = "&rv"
|
||||
}
|
||||
fmt.Fprintf(w, "\treturn %s, nil\n", retValue)
|
||||
fmt.Fprintf(w, "\treturn &rv, nil\n")
|
||||
}
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// If there are argument and/or return types, emit them.
|
||||
if f.Inputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
fnInputsName := pkg.functionArgsTypeName(f)
|
||||
pkg.genPlainType(w, fnInputsName, f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Inputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnInputsName, f.Inputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
pkg.genPlainType(w, pkg.functionArgsTypeName(f), f.Inputs.Comment, "", f.Inputs.Properties)
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
fmt.Fprintf(w, "\n")
|
||||
fnOutputsName := pkg.functionResultTypeName(f)
|
||||
pkg.genPlainType(w, fnOutputsName, f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
if codegen.IsProvideDefaultsFuncRequired(f.Outputs) && !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, fnOutputsName, f.Outputs.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
pkg.genPlainType(w, pkg.functionResultTypeName(f), f.Outputs.Comment, "", f.Outputs.Properties)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) functionName(f *schema.Function) string {
|
||||
|
@ -2135,24 +2019,16 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
|
|||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) error {
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
|
||||
contract.Assert(!obj.IsInputShape())
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
return nil
|
||||
}
|
||||
|
||||
plainName := pkg.tokenToType(obj.Token)
|
||||
pkg.genPlainType(w, plainName, obj.Comment, "", obj.Properties)
|
||||
if !pkg.disableObjectDefaults {
|
||||
if err := pkg.genPlainObjectDefaultFunc(w, plainName, obj.Properties); err != nil {
|
||||
return err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
pkg.genPlainType(w, pkg.tokenToType(obj.Token), obj.Comment, "", obj.Properties)
|
||||
pkg.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
|
||||
pkg.genOutputTypes(w, genOutputTypesArgs{t: obj})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) addSuffixesToName(typ schema.Type, name string) []string {
|
||||
|
@ -2224,16 +2100,16 @@ func (pkg *pkgContext) genNestedCollectionTypes(w io.Writer, types map[string]ma
|
|||
names = append(names, name)
|
||||
if strings.HasSuffix(name, "Array") {
|
||||
fmt.Fprintf(w, "type %s []%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName)
|
||||
genArrayOutput(w, strings.TrimSuffix(name, "Array"), elementTypeName, false)
|
||||
}
|
||||
|
||||
if strings.HasSuffix(name, "Map") {
|
||||
fmt.Fprintf(w, "type %s map[string]%sInput\n\n", name, elementTypeName)
|
||||
genInputImplementation(w, name, name, elementTypeName, false)
|
||||
genInputImplementation(w, name, name, elementTypeName, false, false)
|
||||
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName)
|
||||
genMapOutput(w, strings.TrimSuffix(name, "Map"), elementTypeName, false)
|
||||
}
|
||||
pkg.genInputInterface(w, name)
|
||||
}
|
||||
|
@ -2360,13 +2236,18 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
name)
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
if generateResourceContainerTypes {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sPtrInput)(nil)).Elem(), &%[1]s{})\n",
|
||||
name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sArrayInput)(nil)).Elem(), %[1]sArray{})\n",
|
||||
name)
|
||||
fmt.Fprintf(w,
|
||||
"\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sMapInput)(nil)).Elem(), %[1]sMap{})\n",
|
||||
name)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Register all output types
|
||||
|
@ -2381,9 +2262,12 @@ func (pkg *pkgContext) genResourceRegistrations(w io.Writer, r *schema.Resource,
|
|||
}
|
||||
}
|
||||
|
||||
if generateResourceContainerTypes && !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
if generateResourceContainerTypes {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
|
||||
if !r.IsProvider {
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(w, "}\n\n")
|
||||
}
|
||||
|
@ -2786,7 +2670,6 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
packages: packages,
|
||||
liftSingleValueMethodReturns: goInfo.LiftSingleValueMethodReturns,
|
||||
disableInputTypeRegistrations: goInfo.DisableInputTypeRegistrations,
|
||||
disableObjectDefaults: goInfo.DisableObjectDefaults,
|
||||
}
|
||||
packages[mod] = pack
|
||||
}
|
||||
|
@ -3110,10 +2993,8 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
pkg.functions = append(pkg.functions, f)
|
||||
|
||||
name := tokenToName(f.Token)
|
||||
|
||||
if pkg.names.Has(name) ||
|
||||
pkg.names.Has(name+"Args") ||
|
||||
pkg.names.Has(name+"Result") {
|
||||
originalName := name
|
||||
if pkg.names.Has(name) {
|
||||
switch {
|
||||
case strings.HasPrefix(name, "New"):
|
||||
name = "Create" + name[3:]
|
||||
|
@ -3126,9 +3007,15 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
|
||||
if f.Inputs != nil {
|
||||
pkg.names.Add(name + "Args")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Args"] = name + "Args"
|
||||
}
|
||||
}
|
||||
if f.Outputs != nil {
|
||||
pkg.names.Add(name + "Result")
|
||||
if originalName != name {
|
||||
pkg.renamed[originalName+"Result"] = name + "Result"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3317,10 +3204,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
}
|
||||
|
||||
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
||||
code, err := pkg.genFunctionCodeFile(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
code := pkg.genFunctionCodeFile(f)
|
||||
setFile(fileName, code)
|
||||
}
|
||||
|
||||
|
@ -3360,9 +3244,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
|
||||
|
||||
for _, t := range pkg.types {
|
||||
if err := pkg.genType(buffer, t); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkg.genType(buffer, t)
|
||||
delete(knownTypes, t)
|
||||
}
|
||||
|
||||
|
@ -3498,12 +3380,4 @@ func PkgVersion() (semver.Version, error) {
|
|||
}
|
||||
return semver.Version{}, fmt.Errorf("failed to determine the package version from %%s", pkgPath)
|
||||
}
|
||||
|
||||
// isZero is a null safe check for if a value is it's types zero value.
|
||||
func isZero(v interface{}) bool {
|
||||
if v == nil {
|
||||
return true
|
||||
}
|
||||
return reflect.ValueOf(v).IsZero()
|
||||
}
|
||||
`
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -3,6 +3,7 @@ package syntax
|
|||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -212,6 +213,10 @@ func (v *validator) Exit(n hclsyntax.Node) hcl.Diagnostics {
|
|||
}
|
||||
|
||||
func TestComments(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Skipped on Windows: TODO newline handling")
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadFile("./testdata/comments_all.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read test data: %v", err)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -164,6 +165,11 @@ func TestProgramCodegen(
|
|||
testcase ProgramCodegenOptions,
|
||||
|
||||
) {
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("TestProgramCodegen is skipped on Windows")
|
||||
}
|
||||
|
||||
ensureValidSchemaVersions(t)
|
||||
for _, tt := range programTests {
|
||||
t.Run(tt.Description, func(t *testing.T) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -192,22 +193,11 @@ var sdkTests = []sdkTest{
|
|||
SkipCompileCheck: codegen.NewStringSet(nodejs),
|
||||
},
|
||||
{
|
||||
Directory: "plain-object-defaults",
|
||||
Description: "Ensure that object defaults are generated (repro #8132)",
|
||||
Directory: "env-helper",
|
||||
Description: "Ensure that eviromental helpers are generated (repro #8132)",
|
||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet),
|
||||
},
|
||||
{
|
||||
Directory: "plain-object-disable-defaults",
|
||||
Description: "Ensure that we can still compile safely when defaults are disabled",
|
||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet),
|
||||
},
|
||||
{
|
||||
Directory: "regress-8403",
|
||||
Description: "Regress pulumi/pulumi#8403",
|
||||
SkipCompileCheck: codegen.NewStringSet(dotnet, python, nodejs),
|
||||
},
|
||||
}
|
||||
|
||||
var genSDKOnly bool
|
||||
|
@ -288,6 +278,11 @@ type SDKCodegenOptions struct {
|
|||
// `go/tests/go_test.go` before performing compilation and unit test
|
||||
// checks over the project generated in `go`.
|
||||
func TestSDKCodegen(t *testing.T, opts *SDKCodegenOptions) { // revive:disable-line
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("TestSDKCodegen is skipped on Windows")
|
||||
}
|
||||
|
||||
testDir := filepath.Join("..", "internal", "test", "testdata")
|
||||
|
||||
// Motivation for flagging: concerns about memory utilizaion
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
@ -93,7 +93,7 @@ type FooInput interface {
|
|||
}
|
||||
|
||||
func (*Foo) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
||||
return reflect.TypeOf((*Foo)(nil))
|
||||
}
|
||||
|
||||
func (i *Foo) ToFooOutput() FooOutput {
|
||||
|
@ -107,7 +107,7 @@ func (i *Foo) ToFooOutputWithContext(ctx context.Context) FooOutput {
|
|||
type FooOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (FooOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Foo)(nil)).Elem()
|
||||
return reflect.TypeOf((*Foo)(nil))
|
||||
}
|
||||
|
||||
func (o FooOutput) ToFooOutput() FooOutput {
|
|
@ -7,8 +7,8 @@ import (
|
|||
"context"
|
||||
"reflect"
|
||||
|
||||
"env-helper/example/mod1"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-disable-defaults/example/mod1"
|
||||
)
|
||||
|
||||
// A test for namespaces (mod 2)
|
|
@ -7,8 +7,8 @@ import (
|
|||
"context"
|
||||
"reflect"
|
||||
|
||||
"env-helper/example/mod1"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-disable-defaults/example/mod1"
|
||||
)
|
||||
|
||||
type ModuleTest struct {
|
||||
|
@ -76,7 +76,7 @@ type ModuleTestInput interface {
|
|||
}
|
||||
|
||||
func (*ModuleTest) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
||||
return reflect.TypeOf((*ModuleTest)(nil))
|
||||
}
|
||||
|
||||
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
|
||||
|
@ -90,7 +90,7 @@ func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTe
|
|||
type ModuleTestOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleTestOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
||||
return reflect.TypeOf((*ModuleTest)(nil))
|
||||
}
|
||||
|
||||
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {
|
|
@ -53,7 +53,7 @@ type ProviderInput interface {
|
|||
}
|
||||
|
||||
func (*Provider) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (i *Provider) ToProviderOutput() ProviderOutput {
|
||||
|
@ -67,7 +67,7 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
|
|||
type ProviderOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ProviderOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**Provider)(nil)).Elem()
|
||||
return reflect.TypeOf((*Provider)(nil))
|
||||
}
|
||||
|
||||
func (o ProviderOutput) ToProviderOutput() ProviderOutput {
|
|
@ -7,9 +7,9 @@ import (
|
|||
"context"
|
||||
"reflect"
|
||||
|
||||
"env-helper/example/mod1"
|
||||
"env-helper/example/mod2"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
"plain-object-disable-defaults/example/mod1"
|
||||
"plain-object-disable-defaults/example/mod2"
|
||||
)
|
||||
|
||||
// BETA FEATURE - Options to configure the Helm Release resource.
|
|
@ -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()
|
||||
}
|
|
@ -219,8 +219,7 @@
|
|||
}
|
||||
},
|
||||
"go": {
|
||||
"importBasePath": "plain-object-disable-defaults/example",
|
||||
"disableObjectDefaults": true
|
||||
"importBasePath": "env-helper/example"
|
||||
},
|
||||
"nodejs": {
|
||||
"dependencies": {
|
|
@ -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{})
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue