-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
74 changed files
with
3,411 additions
and
30,843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "Defang Pulumi Provider", | ||
"image": "ubuntu:latest", | ||
"features": { | ||
"ghcr.io/devcontainers/features/nix:1": { | ||
"extraNixConfig": "experimental-features = nix-command flakes" | ||
} | ||
}, | ||
"containerEnv": { | ||
"EDITOR": "vim" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"golang.go" | ||
] | ||
} | ||
}, | ||
"postAttachCommand": "nix develop --command bash" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
# - '!*.*.*-**' | ||
permissions: | ||
contents: write # Allows writing releases | ||
packages: write # Allows publishing packages | ||
id-token: write # Required for requesting the JWT before publishing to Pypi and NPM | ||
|
||
env: | ||
PROVIDER: "defang" | ||
# THIS GITHUB_TOKEN IS A REQUIREMENT TO BE ABLE TO WRITE TO GH RELEASES | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# IF YOU NEED TO PUBLISH A NPM PACKAGE THEN ENSURE A NPM_TOKEN SECRET IS SET | ||
# AND PUBLISH_NPM: TRUE. IF YOU WANT TO PUBLISH TO A PRIVATE NPM REGISTRY | ||
# THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED | ||
NPM_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }} | ||
PUBLISH_NPM: true | ||
NPM_REGISTRY_URL: https://registry.npmjs.org | ||
# IF YOU NEED TO PUBLISH A NUGET PACKAGE THEN ENSURE AN NUGET_PUBLISH_KEY | ||
# SECRET IS SET AND PUBLISH_NUGET: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE | ||
# NPM REGISTRY THEN ENSURE THE NPM_REGISTRY_URL IS CHANGED | ||
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} | ||
NUGET_FEED_URL: https://api.nuget.org/v3/index.json | ||
PUBLISH_NUGET: true | ||
# IF YOU NEED TO PUBLISH A PYPI PACKAGE THEN ENSURE AN PYPI_API_TOKEN | ||
# SECRET IS SET AND PUBLISH_PYPI: TRUE. IF YOU WANT TO PUBLISH TO AN ALTERNATIVE | ||
# PYPI REGISTRY THEN ENSURE THE PYPI_REPOSITORY_URL IS SET. IF YOU ARE USING AN API_TOKEN THEN | ||
# YOU DO NOT NEED TO CHANGE THE PYPI_USERNAME (__token__) , IF YOU ARE USING PASSWORD AUTHENTICATION THEN YOU WILL | ||
# NEED TO CHANGE TO USE THE CORRECT PASSWORD | ||
PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
PYPI_USERNAME: "__token__" | ||
# PYPI_REPOSITORY_URL: "" | ||
PUBLISH_PYPI: true | ||
jobs: | ||
publish_binary: | ||
name: publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
- name: Unshallow clone for tags | ||
run: git fetch --prune --unshallow --tags | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{matrix.goversion}} | ||
- name: Install pulumictl | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: pulumi/pulumictl | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser # either 'goreleaser' (default) or 'goreleaser-pro' | ||
args: -p 3 release | ||
version: v2 | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
goversion: | ||
- 1.22.x | ||
publish_sdk: | ||
name: Publish SDKs | ||
runs-on: ubuntu-latest | ||
needs: publish_binary | ||
environment: publish | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
- name: Unshallow clone for tags | ||
run: git fetch --prune --unshallow --tags | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.goversion }} | ||
- name: Install pulumictl | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: pulumi/pulumictl | ||
- name: Install Pulumi CLI | ||
uses: pulumi/[email protected] | ||
- if: ${{ matrix.language == 'nodejs'}} | ||
name: Setup Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{matrix.nodeversion}} | ||
registry-url: ${{env.NPM_REGISTRY_URL}} | ||
- if: ${{ matrix.language == 'dotnet'}} | ||
name: Setup DotNet | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{matrix.dotnetversion}} | ||
- if: ${{ matrix.language == 'python'}} | ||
name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{matrix.pythonversion}} | ||
- name: Generate SDK | ||
run: make ${{ matrix.language }}_sdk | ||
- name: Check worktree clean | ||
run: | | ||
git update-index -q --refresh | ||
if ! git diff-files --quiet; then | ||
>&2 echo "error: working tree is not clean, aborting!" | ||
git status | ||
git diff | ||
exit 1 | ||
fi | ||
- name: Compress SDK folder | ||
run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} . | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.language }}-sdk.tar.gz | ||
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz | ||
- if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }} | ||
name: Publish package to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: ${{ env.PYPI_USERNAME }} | ||
password: ${{ env.PYPI_PASSWORD }} | ||
packages-dir: ${{github.workspace}}/sdk/python/bin/dist | ||
- if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }} | ||
uses: JS-DevTools/npm-publish@v1 | ||
with: | ||
access: "public" | ||
token: ${{ env.NPM_TOKEN }} | ||
package: ${{github.workspace}}/sdk/nodejs/bin/package.json | ||
- if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }} | ||
name: publish nuget package | ||
run: | | ||
dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }} | ||
echo "done publishing packages" | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
dotnetversion: | ||
- 6.0.x | ||
goversion: | ||
- 1.22.x | ||
language: | ||
- nodejs | ||
- python | ||
- dotnet | ||
- go | ||
nodeversion: | ||
- 22.x | ||
pythonversion: | ||
- "3.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
on: | ||
pull_request: | ||
paths-ignore: | ||
- docs | ||
- .devcontainer | ||
- examples | ||
|
||
jobs: | ||
build_sdks: | ||
name: Build SDKs | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dotnetversion: | ||
- 6.0.x | ||
goversion: | ||
- 1.21.x | ||
nodeversion: | ||
- 18.x | ||
pythonversion: | ||
- "3.9" | ||
# javaversion: | ||
# - "11" | ||
language: | ||
- nodejs | ||
- python | ||
- dotnet | ||
- go | ||
# - java | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
- name: Unshallow clone for tags | ||
run: git fetch --prune --unshallow --tags | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{matrix.goversion}} | ||
|
||
- name: Install pulumictl | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: pulumi/pulumictl | ||
|
||
- name: Install pulumi | ||
uses: pulumi/actions@v5 | ||
|
||
- if: ${{ matrix.language == 'nodejs'}} | ||
name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{matrix.nodeversion}} | ||
registry-url: https://registry.npmjs.org | ||
|
||
- if: ${{ matrix.language == 'dotnet'}} | ||
name: Setup DotNet | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{matrix.dotnetversion}} | ||
|
||
- if: ${{ matrix.language == 'python'}} | ||
name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{matrix.pythonversion}} | ||
|
||
- if: ${{ matrix.language == 'java'}} | ||
name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
cache: gradle | ||
distribution: temurin | ||
java-version: ${{matrix.javaversion}} | ||
|
||
- name: Build SDK | ||
run: make ${{ matrix.language }}_sdk | ||
|
||
- name: Check worktree clean | ||
run: | | ||
git update-index -q --refresh | ||
if ! git diff-files --quiet; then | ||
>&2 echo "error: working tree is not clean, aborting!" | ||
git status | ||
git diff | ||
exit 1 | ||
fi | ||
- name: Build Example | ||
run: make ${{ matrix.language }}_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: test | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- name: Install pulumictl | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: pulumi/pulumictl | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
- name: Unshallow clone for tags | ||
run: git fetch --prune --unshallow --tags | ||
- run: make provider | ||
- run: make test | ||
- run: make schema && git diff --exit-code -- provider/cmd/pulumi-resource-defang/schema.json | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.64 | ||
args: --timeout=5m --config=.golangci.yaml provider | ||
|
Oops, something went wrong.