Skip to content

Commit f11bcdf

Browse files
Merge pull request #54 from DefangLabs/v1
This PR introduces v1 of the Defang Native Pulumi Provider. Closes #35 #47 Following the [Authoring and publishing Pulumi packages](https://www.pulumi.com/docs/iac/using-pulumi/pulumi-packages/authoring/) guide, this branch was forked from [`pulumi/pulumi-provider-boilerplate`](https://github.com/pulumi/pulumi-provider-boilerplate). The example resources were then replaced with a single defang `Project` resource which takes the following parameters: * a project name * a cloud provider id (`aws`, `gcp`, or `do`). * a list of paths to one or more `compose.yaml` files. **Authentication** * Pulumi must have the necessary credentials to access your cloud provider's APIs. * Pulumi must also be able to authenticate with Defang, so one of the following must be present: * `DEFANG_TOKEN` in the environment * Defang access token in the state file * `ACTIONS_ID_TOKEN_REQUEST_URL` and `ACTIONS_ID_TOKEN_REQUEST_TOKEN` if running in a Github Action.
2 parents 5d96b1f + 622faff commit f11bcdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3411
-30843
lines changed

.devcontainer/devcontainer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Defang Pulumi Provider",
3+
"image": "ubuntu:latest",
4+
"features": {
5+
"ghcr.io/devcontainers/features/nix:1": {
6+
"extraNixConfig": "experimental-features = nix-command flakes"
7+
}
8+
},
9+
"containerEnv": {
10+
"EDITOR": "vim"
11+
},
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"golang.go"
16+
]
17+
}
18+
},
19+
"postAttachCommand": "nix develop --command bash"
20+
}

.github/actions/npm-ci/action.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*'
6+
# - '!*.*.*-**'
7+
permissions:
8+
contents: write # Allows writing releases
9+
packages: write # Allows publishing packages
10+
id-token: write # Required for requesting the JWT before publishing to Pypi and NPM
11+
12+
env:
13+
PROVIDER: "defang"
14+
# THIS GITHUB_TOKEN IS A REQUIREMENT TO BE ABLE TO WRITE TO GH RELEASES
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
# IF YOU NEED TO PUBLISH A NPM PACKAGE THEN ENSURE A NPM_TOKEN SECRET IS SET
17+
# AND PUBLISH_NPM: TRUE. IF YOU WANT TO PUBLISH TO A PRIVATE NPM REGISTRY
18+
# THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
19+
NPM_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }}
20+
PUBLISH_NPM: true
21+
NPM_REGISTRY_URL: https://registry.npmjs.org
22+
# IF YOU NEED TO PUBLISH A NUGET PACKAGE THEN ENSURE AN NUGET_PUBLISH_KEY
23+
# SECRET IS SET AND PUBLISH_NUGET: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
24+
# NPM REGISTRY THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED
25+
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
26+
NUGET_FEED_URL: https://api.nuget.org/v3/index.json
27+
PUBLISH_NUGET: true
28+
# IF YOU NEED TO PUBLISH A PYPI PACKAGE THEN ENSURE AN PYPI_API_TOKEN
29+
# SECRET IS SET AND PUBLISH_PYPI: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE
30+
# PYPI REGISTRY THEN ENSURE THE PYPI_REPOSITORY_URL IS SET. IF YOU ARE USING AN API_TOKEN THEN
31+
# YOU DO NOT NEED TO CHANGE THE PYPI_USERNAME (__token__) , IF YOU ARE USING PASSWORD AUTHENTICATION THEN YOU WILL
32+
# NEED TO CHANGE TO USE THE CORRECT PASSWORD
33+
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }}
34+
PYPI_USERNAME: "__token__"
35+
# PYPI_REPOSITORY_URL: ""
36+
PUBLISH_PYPI: true
37+
jobs:
38+
publish_binary:
39+
name: publish
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout Repo
43+
uses: actions/checkout@v2
44+
- name: Unshallow clone for tags
45+
run: git fetch --prune --unshallow --tags
46+
- name: Install Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version: ${{matrix.goversion}}
50+
- name: Install pulumictl
51+
uses: jaxxstorm/[email protected]
52+
with:
53+
repo: pulumi/pulumictl
54+
- name: Run GoReleaser
55+
uses: goreleaser/goreleaser-action@v6
56+
with:
57+
distribution: goreleaser # either 'goreleaser' (default) or 'goreleaser-pro'
58+
args: -p 3 release
59+
version: v2
60+
strategy:
61+
fail-fast: true
62+
matrix:
63+
goversion:
64+
- 1.22.x
65+
publish_sdk:
66+
name: Publish SDKs
67+
runs-on: ubuntu-latest
68+
needs: publish_binary
69+
environment: publish
70+
steps:
71+
- name: Checkout Repo
72+
uses: actions/checkout@v2
73+
- name: Unshallow clone for tags
74+
run: git fetch --prune --unshallow --tags
75+
- name: Install Go
76+
uses: actions/setup-go@v5
77+
with:
78+
go-version: ${{ matrix.goversion }}
79+
- name: Install pulumictl
80+
uses: jaxxstorm/[email protected]
81+
with:
82+
repo: pulumi/pulumictl
83+
- name: Install Pulumi CLI
84+
uses: pulumi/[email protected]
85+
- if: ${{ matrix.language == 'nodejs'}}
86+
name: Setup Node
87+
uses: actions/setup-node@v1
88+
with:
89+
node-version: ${{matrix.nodeversion}}
90+
registry-url: ${{env.NPM_REGISTRY_URL}}
91+
- if: ${{ matrix.language == 'dotnet'}}
92+
name: Setup DotNet
93+
uses: actions/setup-dotnet@v4
94+
with:
95+
dotnet-version: ${{matrix.dotnetversion}}
96+
- if: ${{ matrix.language == 'python'}}
97+
name: Setup Python
98+
uses: actions/setup-python@v1
99+
with:
100+
python-version: ${{matrix.pythonversion}}
101+
- name: Generate SDK
102+
run: make ${{ matrix.language }}_sdk
103+
- name: Check worktree clean
104+
run: |
105+
git update-index -q --refresh
106+
if ! git diff-files --quiet; then
107+
>&2 echo "error: working tree is not clean, aborting!"
108+
git status
109+
git diff
110+
exit 1
111+
fi
112+
- name: Compress SDK folder
113+
run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} .
114+
- name: Upload artifacts
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: ${{ matrix.language }}-sdk.tar.gz
118+
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
119+
- if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }}
120+
name: Publish package to PyPI
121+
uses: pypa/gh-action-pypi-publish@release/v1
122+
with:
123+
user: ${{ env.PYPI_USERNAME }}
124+
password: ${{ env.PYPI_PASSWORD }}
125+
packages-dir: ${{github.workspace}}/sdk/python/bin/dist
126+
- if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }}
127+
uses: JS-DevTools/npm-publish@v1
128+
with:
129+
access: "public"
130+
token: ${{ env.NPM_TOKEN }}
131+
package: ${{github.workspace}}/sdk/nodejs/bin/package.json
132+
- if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }}
133+
name: publish nuget package
134+
run: |
135+
dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }}
136+
echo "done publishing packages"
137+
strategy:
138+
fail-fast: true
139+
matrix:
140+
dotnetversion:
141+
- 6.0.x
142+
goversion:
143+
- 1.22.x
144+
language:
145+
- nodejs
146+
- python
147+
- dotnet
148+
- go
149+
nodeversion:
150+
- 22.x
151+
pythonversion:
152+
- "3.9"

.github/workflows/sdks.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- docs
5+
- .devcontainer
6+
- examples
7+
8+
jobs:
9+
build_sdks:
10+
name: Build SDKs
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
dotnetversion:
16+
- 6.0.x
17+
goversion:
18+
- 1.21.x
19+
nodeversion:
20+
- 18.x
21+
pythonversion:
22+
- "3.9"
23+
# javaversion:
24+
# - "11"
25+
language:
26+
- nodejs
27+
- python
28+
- dotnet
29+
- go
30+
# - java
31+
32+
steps:
33+
- name: Checkout Repo
34+
uses: actions/checkout@v2
35+
- name: Unshallow clone for tags
36+
run: git fetch --prune --unshallow --tags
37+
38+
- name: Install Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: ${{matrix.goversion}}
42+
43+
- name: Install pulumictl
44+
uses: jaxxstorm/[email protected]
45+
with:
46+
repo: pulumi/pulumictl
47+
48+
- name: Install pulumi
49+
uses: pulumi/actions@v5
50+
51+
- if: ${{ matrix.language == 'nodejs'}}
52+
name: Setup Node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: ${{matrix.nodeversion}}
56+
registry-url: https://registry.npmjs.org
57+
58+
- if: ${{ matrix.language == 'dotnet'}}
59+
name: Setup DotNet
60+
uses: actions/setup-dotnet@v4
61+
with:
62+
dotnet-version: ${{matrix.dotnetversion}}
63+
64+
- if: ${{ matrix.language == 'python'}}
65+
name: Setup Python
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: ${{matrix.pythonversion}}
69+
70+
- if: ${{ matrix.language == 'java'}}
71+
name: Setup Java
72+
uses: actions/setup-java@v4
73+
with:
74+
cache: gradle
75+
distribution: temurin
76+
java-version: ${{matrix.javaversion}}
77+
78+
- name: Build SDK
79+
run: make ${{ matrix.language }}_sdk
80+
81+
- name: Check worktree clean
82+
run: |
83+
git update-index -q --refresh
84+
if ! git diff-files --quiet; then
85+
>&2 echo "error: working tree is not clean, aborting!"
86+
git status
87+
git diff
88+
exit 1
89+
fi
90+
91+
- name: Build Example
92+
run: make ${{ matrix.language }}_example

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- "**"
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Install Go
11+
uses: actions/setup-go@v5
12+
with:
13+
go-version: 1.22.x
14+
- name: Install pulumictl
15+
uses: jaxxstorm/[email protected]
16+
with:
17+
repo: pulumi/pulumictl
18+
- name: Checkout Repo
19+
uses: actions/checkout@v2
20+
- name: Unshallow clone for tags
21+
run: git fetch --prune --unshallow --tags
22+
- run: make provider
23+
- run: make test
24+
- run: make schema && git diff --exit-code -- provider/cmd/pulumi-resource-defang/schema.json
25+
- name: golangci-lint
26+
uses: golangci/golangci-lint-action@v6
27+
with:
28+
version: v1.64
29+
args: --timeout=5m --config=.golangci.yaml provider
30+

0 commit comments

Comments
 (0)