-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
78 lines (66 loc) · 2.55 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
SHELL := /bin/bash
export API_TAGS ?= ExternalClusterAPI,PoliciesAPI,NodeConfigurationAPI,NodeTemplatesAPI,AuthTokenAPI,ScheduledRebalancingAPI,InventoryAPI,UsersAPI,OperationsAPI,EvictorAPI,SSOAPI,CommitmentsAPI,WorkloadOptimizationAPI
export SWAGGER_LOCATION ?= https://api.cast.ai/v1/spec/openapi.json
default: build
.PHONY: init-examples
init-examples:
@echo "==> Creating symlinks for example/ projects to terraform-provider-castai binary"; \
TF_PROVIDER_FILENAME=terraform-provider-castai; \
GOOS=`go env GOOS`; \
GOARCH=`go env GOARCH`; \
git fetch --tags > /dev/null; \
NEXT_MINOR=`git tag --list 'v*'|sort|tail -n 1| awk -F. -v OFS=. '{$$NF += 1 ; print}'`; \
echo "using next possible minor version without 'v' prefix: $${NEXT_MINOR:1}"; \
for examples in examples/eks examples/gke examples/aks ; do \
for tfproject in $$examples/* ; do \
TF_PROJECT_PLUGIN_PATH="$${tfproject}/terraform.d/plugins/registry.terraform.io/castai/castai/$${NEXT_MINOR:1}/$${GOOS}_$${GOARCH}"; \
echo "creating $${TF_PROVIDER_FILENAME} symlink to $${TF_PROJECT_PLUGIN_PATH}/$${TF_PROVIDER_FILENAME}"; \
mkdir -p "${PWD}/$${TF_PROJECT_PLUGIN_PATH}"; \
ln -sf "${PWD}/terraform-provider-castai" "$${TF_PROJECT_PLUGIN_PATH}"; \
done \
done
.PHONY: format-tf
format-tf:
terraform fmt -recursive -list=false
.PHONY: generate-sdk
generate-sdk:
echo "==> Generating castai sdk client"
go generate castai/sdk/generate.go
# The following command also rewrites existing documentation
.PHONY: generate-docs
generate-docs:
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.14.1
tfplugindocs generate --rendered-provider-name "CAST AI" --ignore-deprecated
.PHONY: generate-all
generate-all: generate-sdk generate-docs
.PHONY: build
build: init-examples
build: generate-sdk
build: generate-docs
build:
@echo "==> Building terraform-provider-castai"
go build
.PHONY: lint
lint:
@echo "==> Running lint"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
.PHONY: test
test:
@echo "==> Running tests"
go test $$(go list ./... | grep -v vendor/ | grep -v e2e) -timeout=1m -parallel=4
.PHONY: testacc
testacc:
@echo "==> Running acceptance tests"
TF_ACC=1 go test ./castai/... '-run=^TestAcc' -v -timeout 40m
.PHONY: validate-terraform-examples
validate-terraform-examples:
for examples in examples/eks examples/gke examples/aks ; do \
for tfproject in $$examples/* ; do \
echo "==> Validating terraform example $$tfproject"; \
cd $$tfproject; \
terraform init; \
terraform validate; \
cd -; \
done \
done