forked from scott-the-programmer/terraform-provider-minikube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (84 loc) · 2.95 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
.PHONY: init
init:
go mod tidy
.PHONY: configure
configure: build set-local
go generate ./...
.PHONY: schema
schema:
go generate ./minikube/schema_cluster.go
.PHONY: clean
clean:
rm bin/* || true
rm examples/resources/minikube_cluster/terraform.tfstate || true
rm examples/resources/minikube_cluster/terraform.tfstate.backup || true
rm examples/resources/minikube_cluster/.terraform.lock.hcl || true
rm -rf examples/resources/minikube_cluster/.terraform || true
minikube delete -p terraform-provider-minikube --purge
minikube delete -p terraform-provider-minikube-acc --purge
minikube delete -p terraform-provider-minikube-acc-docker --purge
minikube delete -p terraform-provider-minikube-acc-hyperkit --purge
minikube delete -p terraform-provider-minikube-acc-hyperv --purge
.PHONY: nuke
nuke: clean
rm -rf ~/.minikube || true
.PHONY: test
test:
go clean -testcache
go test ./... -coverprofile cover.out.tmp
cat cover.out.tmp | grep -v "mock_" > cover.out
.PHONY: acceptance
acceptance:
go clean -testcache
go test -c -ldflags="-X k8s.io/minikube/pkg/version.storageProvisionerVersion=v5" -o testBinary ./minikube
TF_ACC=true ./testBinary -test.run "TestClusterCreation" -test.v -test.parallel 1 -test.timeout 20m
.PHONY: test-stack-apply
test-stack-apply: set-local
terraform -chdir=examples/resources/minikube_cluster init || true
terraform -chdir=examples/resources/minikube_cluster apply --auto-approve
.PHONY: test-stack-delete
test-stack-delete:
terraform -chdir=examples/resources/minikube_cluster destroy --auto-approve
.PHONY: test-stack
test-stack: test-stack-apply test-stack-delete
STORAGE_PROVISIONER_TAG ?= v5
.PHONY: build
build:
go build -o bin/terraform-provider-minikube -ldflags="-X k8s.io/minikube/pkg/version.storageProvisionerVersion=$(STORAGE_PROVISIONER_TAG)"
ARCH_RAW := $(shell uname -m)
ifeq ($(ARCH_RAW), x86_64)
ARCH := amd64
else ifeq ($(ARCH_RAW), aarch64)
ARCH := arm64
else
ARCH := $(ARCH_RAW)
endif
OS_NAME := $(shell uname -s | tr A-Z a-z)
PLUGIN_NAME := terraform-provider-minikube
VERSION := 99.99.99
DEST_DIR := $$HOME/.terraform.d/plugins/registry.terraform.io/scott-the-programmer/minikube/$(VERSION)
EXT :=
ifeq ($(OS), Windows_NT)
OS_NAME := windows
DEST_DIR := $$APPDATA/terraform.d/plugins/registry.terraform.io/scott-the-programmer/minikube/$(VERSION)
EXT := .exe
endif
.PHONY: set-local
set-local: build
mkdir -p $(DEST_DIR)/$(OS_NAME)_$(ARCH) && \
cp bin/$(PLUGIN_NAME) $(DEST_DIR)/$(OS_NAME)_$(ARCH)/$(PLUGIN_NAME)$(EXT)
.PHONY: reset-local
reset-local:
rm -rf $(DEST_DIR)/$(OS_NAME)_$(ARCH)/$(PLUGIN_NAME)$(EXT)
SED_FLAGS := -i
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
SED_FLAGS += -e
endif
ifeq ($(UNAME_S),Darwin)
SED_FLAGS += ''
endif
.PHONY: set-version
set-version:
$(eval VERSION := $(shell cat minikube/version/version.go | grep Version | tr -d "[:space:]" | sed 's/Version\="//g' | sed 's/"\/\/.*//g'))
sed $(SED_FLAGS) 's/VERSION=".*"/VERSION="$(VERSION)"/g' bootstrap/install-driver.sh