This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
112 lines (90 loc) · 3.11 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
106
107
108
109
110
111
112
OPERATOR_IMAGE ?= docker.io/servicemeshinterface/smi-adapter-istio
OPERATOR_SDK_RELEASE_VERSION ?= v0.9.0
OPERATOR_IMAGE_TAG ?= latest
#go options
GO ?= go
GOFLAGS :=
TESTS := .
TESTFLAGS :=
KIND_VERSION=v0.5.1
HOST_OS := $(shell uname -s)
ifeq ($(HOST_OS), Darwin)
OS_ARCH = darwin-amd64
else
ifeq ($(HOST_OS), Linux)
OS_ARCH = linux-amd64
else
$(error Unsupported Host OS)
endif
endif
# Required for globs to work correctly
SHELL=/usr/bin/env bash
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
HAS_DEP := $(shell command -v dep;)
HAS_OPERATOR_SDK := $(shell command -v operator-sdk)
HAS_KIND := $(shell command -v kind)
KIND_KUBECONFIG = $(shell kind get kubeconfig-path --name=local-kind)
.PHONY: ci-build
ci-build:
ifndef HAS_OPERATOR_SDK
# install linux release binary
curl -JL https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_RELEASE_VERSION}/operator-sdk-${OPERATOR_SDK_RELEASE_VERSION}-x86_64-linux-gnu > operator-sdk
sudo chmod a+x operator-sdk
sudo mv operator-sdk /usr/local/bin
endif
operator-sdk build $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG)
docker tag $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG) $(OPERATOR_IMAGE):$(GIT_COMMIT)
ci-push:
docker push $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG)
docker push $(OPERATOR_IMAGE):$(GIT_COMMIT)
.PHONY: build check-env
build: check-env
operator-sdk build $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG)
docker tag $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG) $(OPERATOR_IMAGE):$(GIT_COMMIT)
push:
docker push $(OPERATOR_IMAGE):$(OPERATOR_IMAGE_TAG)
docker push $(OPERATOR_IMAGE):$(GIT_COMMIT)
check-env:
ifndef OPERATOR_IMAGE
$(error Environment variable OPERATOR_IMAGE is undefined)
endif
GOFORMAT_FILES := $(shell find . -name '*.go' | grep -v '\./vendor/')
.PHONY: format-go-code
## Formats any go file that differs from gofmt's style
format-go-code:
@gofmt -s -l -w ${GOFORMAT_FILES}
.PHONY: test
test: test-unit
.PHONY: test-unit
test-unit:
@echo
@echo "==> Running unit tests <=="
$(GO) test $(GOFLAGS) -run $(TESTS) ./cmd/... ./pkg/... $(TESTFLAGS) -v
test-e2e:
KUBECONFIG=$(KIND_KUBECONFIG) \
operator-sdk test local ./test/e2e --namespaced-manifest deploy/operator-and-rbac.yaml --namespace istio-system
.PHONY: bootstrap
bootstrap:
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
endif
dep ensure
create-kindcluster:
ifndef HAS_KIND
@echo "installing kind"
@curl -fsSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$(KIND_VERSION)/kind-$(OS_ARCH)"
@chmod +x kind
@mv kind /usr/local/bin/kind
endif
kind create cluster --name local-kind --image kindest/node:v1.15.3
install-istio:
curl -fsSL https://git.io/getLatestIstio | ISTIO_VERSION=1.1.6 sh -
ls istio-1.1.6/install/kubernetes/helm/istio-init/files/crd*yaml | \
xargs -I{} kubectl apply -f {} --kubeconfig=$(KIND_KUBECONFIG)
kubectl apply -f istio-1.1.6/install/kubernetes/istio-demo-auth.yaml \
--kubeconfig=$(KIND_KUBECONFIG)
install-smi-crds:
kubectl apply -f https://raw.githubusercontent.com/servicemeshinterface/smi-adapter-istio/master/deploy/crds/crds.yaml \
--kubeconfig=$(KIND_KUBECONFIG)
clean-kind:
kind delete cluster --name local-kind