Skip to content

Commit

Permalink
Merge pull request #20 from spacelift-io/future
Browse files Browse the repository at this point in the history
V3 Provider, Bringing future into main
  • Loading branch information
Yantrio authored Oct 11, 2022
2 parents bcc6510 + 9ede549 commit 827b92c
Show file tree
Hide file tree
Showing 603 changed files with 43,493 additions and 37,986 deletions.
68 changes: 68 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
ARG UBUNTU_VERSION=latest
FROM --platform=linux/amd64 ubuntu:${UBUNTU_VERSION}

# Update apt-get and install various needed utilities
RUN apt-get update && \
apt-get install -y curl && \
apt-get install -y wget && \
apt-get install -y xz-utils && \
apt-get install -y make && \
apt-get install -y gcc && \
apt-get install -y git

# Install bridged provider prerequisites
# See README.md

# Install go
ARG GO_VERSION=1.18.3
RUN rm -rf /usr/local/go && \
wget -O ${GO_VERSION}.tar.gz https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -C /usr/local -xzf ${GO_VERSION}.tar.gz && \
rm ${GO_VERSION}.tar.gz

ENV GOPATH=/root/go
ENV PATH=$PATH:/usr/local/go/bin

# Install go linter
RUN mkdir -p $GOPATH/bin && \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.46.2

ENV PATH=$PATH:$GOPATH/bin

# Install pulumictl
ARG PULUMICTL_VERSION=v0.0.32
RUN rm -rf /usr/local/bin/pulumictl && \
wget -O pulumictl.${PULUMICTL_VERSION}.tar.gz https://github.com/pulumi/pulumictl/releases/download/${PULUMICTL_VERSION}/pulumictl-${PULUMICTL_VERSION}-linux-amd64.tar.gz && \
tar -C /usr/local/bin -xzf pulumictl.${PULUMICTL_VERSION}.tar.gz

# Install nodejs
ARG NODEJS_VERSION=v16.16.0
ARG NODEJS_PKG=node-${NODEJS_VERSION}-linux-x64
ARG NODEJS_TARBALL=${NODEJS_PKG}.tar.xz
RUN rm -rf /usr/local/node && \
wget -O ${NODEJS_TARBALL} https://nodejs.org/dist/${NODEJS_VERSION}/${NODEJS_TARBALL} && \
tar -C /usr/local -xf ${NODEJS_TARBALL} && \
mv /usr/local/${NODEJS_PKG} /usr/local/node

ENV PATH=$PATH:/usr/local/node/bin

# Install yarn
RUN npm install --global yarn

# Install python and related items
RUN apt-get install -y python3 && \
apt-get install -y python3-setuptools

# Install .NET
RUN wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
rm packages-microsoft-prod.deb

RUN apt-get update && \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-6.0

# Install Pulumi
RUN curl -fsSL https://get.pulumi.com | sh
ENV PATH=$PATH:/root/.pulumi/bin
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.3/containers/hugo
{
"name": "TFProvider",
"build": {
"dockerfile": "Dockerfile"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/build-provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build-provider:
name: Build provider
runs-on: ubuntu-latest
container: golang:1.16-alpine
container: golang:1.19-alpine
steps:
- name: Install build dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/library-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
go-version: 1.19.x
- name: Install pulumictl
uses: jaxxstorm/[email protected]
with:
Expand Down Expand Up @@ -55,6 +55,8 @@ jobs:
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- name: Publish npm package.
run: cd sdk/nodejs/bin && npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build dotnet package
run: make build_dotnet
- name: Package dotnet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preprod-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
preprod-provider-deployment:
name: Build and upload provider
runs-on: ubuntu-latest
container: golang:1.16-alpine
container: golang:1.19-alpine
permissions:
id-token: write
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prod-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
prod-provider-deployment:
name: Build and upload provider
runs-on: ubuntu-latest
container: golang:1.16-alpine
container: golang:1.19-alpine
permissions:
id-token: write
contents: read
Expand Down
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.idea
.code
**/vendor/
.pulumi
**/bin/
**/obj/
Pulumi.*.yaml
**/node_modules/
.DS_Store

**/command-output/

.idea/
*.iml

yarn.lock
**/pulumiManifest.go

ci-scripts
provider/**/schema-embed.json
**/version.txt
**/nuget
**/dist
65 changes: 20 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PROJECT_NAME := pulumi-spacelift Package
PROJECT_NAME := spacelift Package

SHELL := /bin/bash
PACK := spacelift
ORG := spacelift-io
PROJECT := github.com/${ORG}/pulumi-${PACK}
Expand All @@ -10,11 +11,7 @@ VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version

TFGEN := pulumi-tfgen-${PACK}
PROVIDER := pulumi-resource-${PACK}
VERSION_WITH_V := "$(shell git describe --tags --abbrev=0)"
VERSION := "$(shell git describe --tags --abbrev=0 | sed 's/^v//g')"
PROVIDER_OS := ${PROVIDER_OS}

SHELL := /bin/bash
VERSION := $(shell pulumictl get version)

TESTPARALLELISM := 4

Expand All @@ -32,16 +29,13 @@ prepare::
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; \
sed -i 's,github.com/pulumi/pulumi-spacelift,${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; \

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

Expand All @@ -54,63 +48,43 @@ build:: install_plugins provider build_sdks install_sdks
only_build:: build

tfgen:: install_plugins
(cd provider && go build -a -o $(WORKING_DIR)/bin/${TFGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${TFGEN})
(cd provider && go build -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 && CGO_ENABLED=0 GOOS=$(PROVIDER_OS) go build -a -tags netgo -o $(WORKING_DIR)/bin/ -ldflags "-s -w -extldflags '-static' -X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER})

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 -R scripts/ bin && \
cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION_WITH_V)/g" ./bin/package.json
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/
if [[ "${OS}" == "Darwin" ]]; then \
sed -i '' -r "s/check_call\(\['pulumi', 'plugin', 'install', 'resource', 'spacelift', '[^']+']\)/check_call(['pulumi', 'plugin', 'install', '--server', 'https:\/\/downloads.spacelift.io\/pulumi-plugins', 'resource', 'spacelift', '0.0.0'])/g" sdk/python/setup.py; \
fi
if [[ "${OS}" != "Darwin" ]]; then \
sed -i -r "s/check_call\(\['pulumi', 'plugin', 'install', 'resource', 'spacelift', '[^']+']\)/check_call(['pulumi', 'plugin', 'install', '--server', 'https:\/\/downloads.spacelift.io\/pulumi-plugins', 'resource', 'spacelift', '0.0.0'])/g" sdk/python/setup.py; \
fi
if [[ "${OS}" == "Darwin" ]]; then \
sed -i '' -r "s/import pulumi$$/import pulumi as pulumilib/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/pulumi.CustomResource/pulumilib.CustomResource/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/pulumi.ResourceOptions/pulumilib.ResourceOptions/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/pulumi.Input/pulumilib.Input/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/pulumi.Output/pulumilib.Output/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/@pulumi.getter/@pulumilib.getter/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i '' -r "s/pulumi.get/pulumilib.get/g" sdk/python/pulumi_spacelift/stack.py; \
fi
if [[ "${OS}" != "Darwin" ]]; then \
sed -i -r "s/import pulumi$$/import pulumi as pulumilib/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/pulumi.CustomResource/pulumilib.CustomResource/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/pulumi.ResourceOptions/pulumilib.ResourceOptions/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/pulumi.Input/pulumilib.Input/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/pulumi.Output/pulumilib.Output/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/@pulumi.getter/@pulumilib.getter/g" sdk/python/pulumi_spacelift/stack.py && \
sed -i -r "s/pulumi.get/pulumilib.get/g" sdk/python/pulumi_spacelift/stack.py; \
fi
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}/$(VERSION)/g" -e "s/\$${PLUGIN_VERSION}/0.0.0/g" ./bin/setup.py && \
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 "$(VERSION)" >version.txt && \
cp ../../Pulumi.Spacelift.csproj.template ./Pulumi.Spacelift.csproj && \
dotnet build --configuration Release /p:Version=$(VERSION)
echo "${DOTNET_VERSION}" >version.txt && \
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/
Expand All @@ -124,15 +98,15 @@ cleanup:: # cleans up the temporary directory

help::
@grep '^[^.#]\+:\s\+.*#' Makefile | \
sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \
expand -t20
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
pulumi plugin install resource random 2.2.0
pulumi plugin install resource random 4.3.1

install_dotnet_sdk::
mkdir -p $(WORKING_DIR)/nuget
Expand All @@ -149,3 +123,4 @@ install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk

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

4 changes: 4 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.pulumi/
**/bin/
node_modules/

3 changes: 3 additions & 0 deletions examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/spacelift-io/pulumi-spacelift/examples

go 1.16
Loading

0 comments on commit 827b92c

Please sign in to comment.