forked from wave-k8s/wave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.tools
94 lines (82 loc) · 3.93 KB
/
Makefile.tools
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
.PHONY: prepare-env-%
prepare-env-%: gopath dep ginkgo-cli golangci-lint kustomize
PATH=$$GOPATH/bin:/usr/local/kubebuilder-$*/bin:/usr/local/opt/kubebuilder-$*/bin:$$PATH make kubebuilder-tools-$*
PATH=$$GOPATH/bin:/usr/local/kubebuilder-$*/bin:/usr/local/opt/kubebuilder-$*/bin:$$PATH ./configure
.PHONY: gopath
gopath:
@ if [ ! -d $$GOPATH ]; then \
mkdir -p $$GOPATH; \
fi
@ if [ ! -d $$GOPATH/bin ]; then \
mkdir -p $$GOPATH/bin; \
fi
.PHONY: dep
dep:
@ if [ ! $$(which dep) ]; then \
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
fi
.PHONY: ginkgo-cli
ginkgo-cli:
@ if [ ! $$(which ginkgo) ]; then \
go get -u github.com/onsi/ginkgo/ginkgo; \
fi
.PHONY: golangci-lint
golangci-lint:
@ if [ ! $$(which golangci-lint) ]; then \
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $$(go env GOPATH)/bin v1.15.0; \
fi
.PHONY: kustomize
kustomize:
@ if [ ! $$(which kustomize) ]; then \
go get -u sigs.k8s.io/kustomize; \
fi
.PHONY: kubebuilder-tools-1.14
kubebuilder-tools-1.14:
@ ver=$$(kubebuilder version | awk '{where = match($$0, /KubeBuilderVersion:"[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta)\.[0-9+])?"/); if (where != 0) print substr($$0, RSTART+20, RLENGTH)}' | sed s/\",.\*// ); \
if [ "$$ver" != "2.0.0-beta.0" ]; then \
kubebuilder_version=2.0.0-beta.0 kubernetes_version=1.14 make install-kubebuilder-tools; \
fi
.PHONY: kubebuilder-tools-1.13
kubebuilder-tools-1.13:
@ ver=$$(kubebuilder version | awk '{where = match($$0, /KubeBuilderVersion:"[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta)\.[0-9+])?"/); if (where != 0) print substr($$0, RSTART+20, RLENGTH)}' | sed s/\",.\*// ); \
if [ "$$ver" != "1.0.8" ]; then \
kubebuilder_version=1.0.8 kubernetes_version=1.13 make install-kubebuilder-tools; \
fi
.PHONY: kubebuilder-tools-1.12
kubebuilder-tools-1.12:
@ ver=$$(kubebuilder version | awk '{where = match($$0, /KubeBuilderVersion:"[[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta)\.[0-9+])?"/); if (where != 0) print substr($$0, RSTART+20, RLENGTH)}' | sed s/\",.\*// ); \
if [ "$$ver" != "1.0.7" ]; then \
kubebuilder_version=1.0.7 kubernetes_version=1.12 make install-kubebuilder-tools; \
fi
.PHONY: kubebuilder-tools-1.11
kubebuilder-tools-1.11:
@ ver=$$(kubebuilder version | awk '{where = match($$0, /KubeBuilderVersion:"[0-9]\.[0-9]+\.[0-9]+(-(alpha|beta)\.[0-9+])?"/); if (where != 0) print substr($$0, RSTART+20, RLENGTH)}' | sed s/\",.\*// ); \
if [ "$$ver" != "1.0.5" ]; then \
kubebuilder_version=1.0.5 kubernetes_version=1.11 make install-kubebuilder-tools; \
fi
# latest stable version
kubebuilder_version ?= 2.0.0-beta.0
kubernetes_version ?= 1.14
os := $(shell uname | awk '{print tolower($$0)}')
# Version string should be approx v1.x.x_linux_amd64
kubebuilder_version_string=$(kubebuilder_version)_$(os)_amd64
.PHONY: install-kubebuilder-tools
install-kubebuilder-tools:
# download the release
curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v$(kubebuilder_version)/kubebuilder_$(kubebuilder_version_string).tar.gz"
tar -zxvf kubebuilder_$(kubebuilder_version_string).tar.gz
rm kubebuilder_$(kubebuilder_version_string).tar.gz
export TEST_ASSET_DIR=/usr/local/opt/kubebuilder-${kubernetes_version}/bin; \
export TEST_ASSET_KUBECTL=$$TEST_ASSET_DIR/kubectl \
TEST_ASSET_KUBE_APISERVER=$$TEST_ASSET_DIR/kube-apiserver \
TEST_ASSET_ETCD=$$TEST_ASSET_DIR/etcd \
TEST_ASSET_KUBEBUILDER=$$TEST_ASSET_DIR/kubebuilder; \
\
mkdir -p $$TEST_ASSET_DIR; \
mv kubebuilder_$(kubebuilder_version_string)/bin/etcd $$TEST_ASSET_ETCD; \
mv kubebuilder_$(kubebuilder_version_string)/bin/kube-apiserver $$TEST_ASSET_KUBE_APISERVER; \
mv kubebuilder_$(kubebuilder_version_string)/bin/kubectl $$TEST_ASSET_KUBECTL; \
mv kubebuilder_$(kubebuilder_version_string)/bin/kubebuilder $$TEST_ASSET_KUBEBUILDER; \
rm -rf kubebuilder_$(kubebuilder_version_string); \
\
chmod +x $$TEST_ASSET_ETCD $$TEST_ASSET_KUBE_APISERVER $$TEST_ASSET_KUBECTL $$TEST_ASSET_KUBEBUILDER