generated from pulumi/pulumi-component-provider-go-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
105 lines (78 loc) · 3.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
PACK := lbrlabs-eks
ORG := lbrlabs
PROJECT := github.com/${ORG}/pulumi-${PACK}
NODE_MODULE_NAME := @lbrlabs/${PACK}
TF_NAME := ${PACK}
PROVIDER_PATH := provider
VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version
PLUGIN_PATH := ${HOME}/.pulumi/plugins/
WORKING_DIR := $(shell pwd)
SCHEMA_PATH := ${WORKING_DIR}/schema.yaml
PROVIDER := pulumi-resource-${PACK}
CODEGEN := pulumi-gen-${PACK}
VERSION := $(shell pulumictl get version)
TESTPARALLELISM := 10
WORKING_DIR := $(shell pwd)
.PHONY: development provider build_sdks build_nodejs build_dotnet build_go build_python
development:: install_plugins provider lint_provider build_sdks # 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
generate_schema::
cd provider/cmd/${PROVIDER} && VERSION=${VERSION} SCHEMA=${SCHEMA_PATH} go generate main.go
provider:: install_plugins generate_schema # build the provider binary
cd provider/cmd/${PROVIDER} && go build -o ${WORKING_DIR}/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" .
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 # build the node sdk
cd provider/cmd/${CODEGEN} && go run . nodejs ../../../sdk/nodejs ${SCHEMA_PATH}
cd sdk/nodejs/ && \
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 # build the python sdk
cd provider/cmd/${CODEGEN} && go run . python ../../../sdk/python ${SCHEMA_PATH}
cp ${WORKING_DIR}/README.md 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 = .*/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_go:: install_plugins # build the go sdk
cd provider/cmd/${CODEGEN} && go run . go ../../../sdk/go ${SCHEMA_PATH}
build_dotnet:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet)
build_dotnet:: install_plugins # build the dotnet sdk
cd provider/cmd/${CODEGEN} && go run . dotnet ../../../sdk/dotnet ${SCHEMA_PATH}
cd sdk/dotnet/ && \
echo "${DOTNET_VERSION}" >version.txt && \
dotnet build /p:Version=${DOTNET_VERSION}
build_go:: install_plugins # build the go sdk
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
pulumi plugin install resource kubernetes
pulumi plugin install resource aws
install_dotnet_sdk::
mkdir -p $(WORKING_DIR)/nuget
find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \;
install_python_sdk::
install_go_sdk::
install_nodejs_sdk::
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin
install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk
test::
cd examples && go test -v -tags=all -parallel ${TESTPARALLELISM} -timeout 2h