Skip to content

Commit

Permalink
Merge remote-tracking branch 'template/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matchlighter committed Dec 3, 2021
2 parents f3cf973 + f169979 commit 6f7bcab
Show file tree
Hide file tree
Showing 58 changed files with 6,317 additions and 2,057 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
dotnetversion:
- 3.1.301
goversion:
- 1.15.x
- 1.16.x
language:
- nodejs
- python
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: ${{ matrix.goversion }}
# go-version: 1.16.x
# - name: Install pulumictl
# uses: jaxxstorm/action-install-gh-release@d62853bc9e466834c74cefb34fad78535582e21a
# with:
Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goversion }}
go-version: 1.16.x
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@d62853bc9e466834c74cefb34fad78535582e21a
with:
Expand All @@ -175,7 +175,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goversion }}
go-version: 1.16.x
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@d62853bc9e466834c74cefb34fad78535582e21a
with:
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goversion }}
go-version: 1.16.x
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@d62853bc9e466834c74cefb34fad78535582e21a
with:
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.goversion }}
go-version: 1.16.x
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@d62853bc9e466834c74cefb34fad78535582e21a
with:
Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
dotnetversion:
- 3.1.301
goversion:
- 1.15.x
- 1.16.x
language:
- nodejs
- python
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ ci-scripts
**/schema.go
**/version.txt
**/nuget
**/dist
**/dist

.DS_Store
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
linters:
enable-all: false
enable:
- deadcode
- errcheck
Expand All @@ -17,3 +16,9 @@ linters:
- structcheck
- unconvert
- varcheck
enable-all: false
run:
skip-files:
- schema.go
- pulumiManifest.go
timeout: 10m
112 changes: 58 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
PROJECT_NAME := proxmoxve Package
include build/common.mk

PACK := proxmoxve
ORG := matchlighter
PACKDIR := sdk
PROJECT := github.com/${ORG}/pulumi-${PACK}
NODE_MODULE_NAME := @matchlighter/pulumi-${PACK}
TF_NAME := ${PACK}
Expand All @@ -18,103 +16,109 @@ TESTPARALLELISM := 4

WORKING_DIR := $(shell pwd)

OS := $(shell uname)
EMPTY_TO_AVOID_SED := ""

prepare::
@if test -z "${NAME}"; then echo "NAME not set"; exit 1; fi
@if test -z "${REPOSITORY}"; then echo "REPOSITORY not set"; exit 1; fi
@if test ! -d "provider/cmd/pulumi-tfgen-x${EMPTY_TO_AVOID_SED}yz"; then "Project already prepared"; exit 1; fi

mv "provider/cmd/pulumi-tfgen-x${EMPTY_TO_AVOID_SED}yz" provider/cmd/pulumi-tfgen-${NAME}
mv "provider/cmd/pulumi-resource-x${EMPTY_TO_AVOID_SED}yz" provider/cmd/pulumi-resource-${NAME}

if [[ "${OS}" != "Darwin" ]]; then \
sed -i 's,github.com/pulumi/pulumi-xyz,${REPOSITORY},g' provider/go.mod; \
find ./ ! -path './.git/*' -type f -exec sed -i 's/[x]yz/${NAME}/g' {} \; &> /dev/null; \
fi

# In MacOS the -i parameter needs an empty string to execute in place.
if [[ "${OS}" == "Darwin" ]]; then \
sed -i '' 's,github.com/pulumi/pulumi-xyz,${REPOSITORY},g' provider/go.mod; \
find ./ ! -path './.git/*' -type f -exec sed -i '' 's/[x]yz/${NAME}/g' {} \; &> /dev/null; \
fi

.PHONY: development provider build_sdks build_nodejs build_dotnet build_go build_python cleanup

development:: install_plugins provider lint_provider build_sdks install_sdks cleanup # Build the provider & SDKs for a development environment

# Required for the codegen action that runs in pulumi/pulumi and pulumi/pulumi-terraform-bridge
build:: install_plugins provider build_sdks install_sdks
only_build:: build

tfgen:: install_plugins
(cd provider && go build -o $(WORKING_DIR)/bin/${TFGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${TFGEN})
(cd provider && go build -a -o $(WORKING_DIR)/bin/${TFGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${TFGEN})
$(WORKING_DIR)/bin/${TFGEN} schema --out provider/cmd/${PROVIDER}
(cd provider && VERSION=$(VERSION) go generate cmd/${PROVIDER}/main.go)

provider:: tfgen install_plugins # build the provider binary
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})
(cd provider && go build -a -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})

# Build SDKs:
build_sdks:: install_plugins provider build_nodejs build_python build_go build_dotnet
build_sdks:: install_plugins provider build_nodejs build_python build_go build_dotnet # build all the sdks

build_nodejs:: VERSION := $(shell pulumictl get version --language javascript)
build_nodejs:: install_plugins tfgen # build the node sdk
$(WORKING_DIR)/bin/$(TFGEN) nodejs --overlays provider/overlays/nodejs --out sdk/nodejs/

cd sdk/nodejs/ && \
yarn install && \
yarn run tsc && \
cp ../../README.md package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json
yarn install && \
yarn run tsc && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json

build_python:: PYPI_VERSION := $(shell pulumictl get version --language python)
build_python:: install_plugins tfgen # build the python sdk
$(WORKING_DIR)/bin/$(TFGEN) python --overlays provider/overlays/python --out sdk/python/
cd sdk/python/ && \
cp ../../README.md . && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e "s/\$${VERSION}/$(PYPI_VERSION)/g" -e "s/\$${PLUGIN_VERSION}/$(VERSION)/g" ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist

build_go:: install_plugins tfgen # build the go sdk
$(WORKING_DIR)/bin/$(TFGEN) go --overlays provider/overlays/go --out sdk/go/
cp ../../README.md . && \
python3 setup.py clean --all 2>/dev/null && \
rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \
sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION)"/g' ./bin/setup.py && \
rm ./bin/setup.py.bak && \
cd ./bin && python3 setup.py build sdist

build_dotnet:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
build_dotnet:: install_plugins tfgen # build the dotnet sdk
pulumictl get version --language dotnet
$(WORKING_DIR)/bin/$(TFGEN) dotnet --overlays provider/overlays/dotnet --out sdk/dotnet/
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
dotnet build /p:Version=${DOTNET_VERSION}

build_go:: install_plugins tfgen # build the go sdk
$(WORKING_DIR)/bin/$(TFGEN) go --overlays provider/overlays/go --out sdk/go/

# Misc:
lint_provider:: provider # lint the provider code
cd provider && golangci-lint run -c ../.golangci.yml

cleanup:: # cleans up the temporary directory
rm -r $(WORKING_DIR)/bin
rm -f provider/cmd/${PROVIDER}/schema.go

help::
@grep '^[^.#]\+:\s\+.*#' Makefile | \
sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \
expand -t20

clean::
rm -rf sdk/{dotnet,nodejs,go,python}

install_plugins::
[ -x $(shell which pulumi) ] || curl -fsSL https://get.pulumi.com | sh

# Install SDKs:
install_sdks:: install_python_sdk install_nodejs_sdk install_dotnet_sdk
pulumi plugin install resource random 4.3.1

install_dotnet_sdk::
mkdir -p $(WORKING_DIR)/nuget
find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;

install_python_sdk::
cd ${PACKDIR}/python/bin && $(PIP) install --user -e .

install_go_sdk::

install_nodejs_sdk::
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin

# Testing:
test_all::
cd examples && $(GO_TEST) .

test_fast::
cd examples && $(GO_TEST_FAST) .

.PHONY: publish_tgz
publish_tgz:
$(call STEP_MESSAGE)
./scripts/publish_tgz.sh

.PHONY: publish_packages
publish_packages:
$(call STEP_MESSAGE)
$$(go env GOPATH)/src/github.com/pulumi/scripts/ci/publish-tfgen-package .
# $$(go env GOPATH)/src/github.com/pulumi/scripts/ci/build-package-docs.sh ${PACK}

.PHONY: check_clean_worktree
check_clean_worktree:
$$(go env GOPATH)/src/github.com/pulumi/scripts/ci/check-worktree-is-clean.sh

# The travis_* targets are entrypoints for CI.
.PHONY: travis_cron travis_push travis_pull_request travis_api
travis_cron: all
travis_push: only_build check_clean_worktree publish_tgz only_test publish_packages
travis_pull_request: all check_clean_worktree
travis_api: all
install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk

test::
cd examples && go test -v -tags=all -parallel ${TESTPARALLELISM} -timeout 2h

56 changes: 56 additions & 0 deletions README-PROVIDER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Foo Resource Provider

The Foo Resource Provider lets you manage [Foo](http://example.com) resources.

## Installing

This package is available for several languages/platforms:

### Node.js (JavaScript/TypeScript)

To use from JavaScript or TypeScript in Node.js, install using either `npm`:

```bash
npm install @pulumi/foo
```

or `yarn`:

```bash
yarn add @pulumi/foo
```

### Python

To use from Python, install using `pip`:

```bash
pip install pulumi_foo
```

### Go

To use from Go, use `go get` to grab the latest version of the library:

```bash
go get github.com/pulumi/pulumi-foo/sdk/go/...
```

### .NET

To use from .NET, install using `dotnet add package`:

```bash
dotnet add package Pulumi.Foo
```

## Configuration

The following configuration points are available for the `foo` provider:

- `foo:apiKey` (environment: `FOO_API_KEY`) - the API key for `foo`
- `foo:region` (environment: `FOO_REGION`) - the region in which to deploy resources

## Reference

For detailed reference documentation, please visit [the Pulumi registry](https://www.pulumi.com/registry/packages/foo/api-docs/).
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Work in Progress Pulumi Provider for use with Proxmox VE

## Installing
1. Follow the steps above to verify the program runs successfully.

This package is available in many languages in the standard packaging formats.
## Add End-to-end Testing

### Installing the Plugin
1. Download the appropriate archive file from the Releases page:
Expand All @@ -14,30 +14,30 @@ This package is available in many languages in the standard packaging formats.

### Node.js (Java/TypeScript)

To use from JavaScript or TypeScript in Node.js, install using either `npm`:
1. Add code to `examples_nodejs_test.go` to call the example you created, e.g.:

$ npm install @matchlighter/pulumi-proxmoxve

or `yarn`:
1. Add a similar function for each example that you want to run in an integration test. For examples written in other languages, create similar files for `examples_${LANGUAGE}_test.go`.

$ yarn add @matchlighter/pulumi-proxmoxve

### Python
_*(Not published. I don't have a present need for this. If you do please open an issue.)*_

To use from Python, install using `pip`:
You can also run each test file separately via test tags:

$ pip install pulumi_proxmoxve

### .NET
_*(Not published. I don't have a present need for this. If you do please open an issue with some instructions for how to publish a .NET package)*_

### Go
## Configuring CI with GitHub Actions

To use from Go, use `go get` to grab the latest version of the library
In this section, we'll add the necessary configuration to work with GitHub Actions for Pulumi's standard CI/CD workflows for providers.

$ go get github.com/matchlighter/pulumi-proxmoxve/sdk/go/...

## Configuration
1. Ensure that any required secrets are present as repository-level [secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) in GitHub. These will be used by the integration tests during the CI/CD process.

Provider configuration is as documented on https://github.com/Telmate/terraform-provider-proxmox
Loading

0 comments on commit 6f7bcab

Please sign in to comment.