-
Notifications
You must be signed in to change notification settings - Fork 184
/
Makefile
187 lines (151 loc) · 5.67 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
LOCALBIN=$(shell pwd)/bin
KUSTOMIZE_VERSION=v4.5.7
KUSTOMIZE=$(LOCALBIN)/kustomize
CONTROLLER_GEN_VERSION=v0.16.1
CONTROLLER_GEN=$(LOCALBIN)/controller-gen
.PHONY: \
build \
gen-protobuf \
clean \
ocs-operator \
operator-bundle \
verify-operator-bundle \
gen-latest-csv \
gen-latest-deploy-yaml \
gen-latest-prometheus-rules-yamls \
verify-latest-deploy-yaml \
verify-latest-csv \
cluster-deploy \
cluster-clean \
functest \
shellcheck-test \
golangci-lint \
update-generated \
ocs-operator-ci \
unit-test \
deps-update
deps-update:
@echo "Running deps-update"
go mod tidy && go mod vendor
@echo "Running deps-update on api submodule"
cd api && go mod tidy && go mod vendor
@echo "Running deps-update on metrics submodule"
cd metrics && go mod tidy && go mod vendor
@echo "Running deps-update on provider/api submodule"
cd services/provider/api && go mod tidy && go mod vendor
operator-sdk:
@echo "Ensuring operator-sdk"
hack/ensure-operator-sdk.sh
build: deps-update generate gen-protobuf
ocs-operator: build
@echo "Building the ocs-operator image"
hack/build-operator.sh
ocs-metrics-exporter: build
@echo "Building the ocs-metrics-exporter image"
hack/build-metrics-exporter.sh
gen-protobuf:
@echo "Generating protobuf files for gRPC services"
hack/gen-protobuf.sh
gen-latest-csv: operator-sdk manifests kustomize
@echo "Generating latest development CSV version using predefined ENV VARs."
hack/generate-latest-csv.sh
gen-release-csv: operator-sdk manifests kustomize
@echo "Generating unified CSV from sourced component-level operators"
hack/generate-unified-csv.sh
gen-latest-deploy-yaml:
@echo "Generating latest deployment yaml file"
hack/gen-deployment-yaml.sh
verify-latest-deploy-yaml: gen-latest-deploy-yaml
@echo "Verifying deployment yaml changes"
hack/verify-latest-deploy-yaml.sh
verify-latest-csv: gen-latest-csv
@echo "Verifying latest CSV"
hack/verify-latest-csv.sh
verify-operator-bundle: operator-sdk
@echo "Verifying operator bundle"
hack/verify-operator-bundle.sh
operator-bundle: gen-latest-csv
@echo "Building ocs operator bundle"
hack/build-operator-bundle.sh
operator-catalog:
@echo "Building ocs catalog image in file based catalog format"
hack/build-operator-catalog.sh
clean:
@echo "cleaning previous outputs"
hack/clean.sh
cluster-deploy: cluster-clean
@echo "Deploying ocs to cluster"
hack/cluster-deploy.sh
cluster-clean:
@echo "Removing ocs install from cluster"
hack/cluster-clean.sh
build-functest:
@echo "Building functional tests"
hack/build-functest.sh
functest: build-functest
@echo "Running ocs developer functional test suite"
hack/functest.sh $(ARGS)
shellcheck-test:
@echo "Testing for shellcheck"
hack/shellcheck-test.sh
golangci-lint:
@echo "Running golangci-lint run"
hack/golangci_lint.sh
lint: ## Run golangci-lint inside a container
source hack/common.sh; source hack/docker-common.sh; \
$${IMAGE_BUILD_CMD} run --rm -v $${PROJECT_DIR}:/app:Z -w /app $${GO_LINT_IMG} golangci-lint run ./...
# ignoring the functest dir since it requires an active cluster
# use 'make functest' to run just the functional tests
unit-test:
@echo "Executing unit tests"
hack/unit-test.sh
ocs-operator-ci: shellcheck-test golangci-lint unit-test verify-deps verify-generated verify-latest-csv verify-operator-bundle verify-latest-deploy-yaml
# Generate code
generate: controller-gen
@echo Updating generated code
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
@echo Updating generated manifests
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true paths=./api/... webhook paths="./..." output:crd:artifacts:config=config/crd/bases
verify-deps: deps-update
@echo "Verifying dependency files"
hack/verify-dependencies.sh
update-generated: generate manifests
verify-generated: update-generated
@echo "Verifying generated code and manifests"
hack/verify-generated.sh
# ARGS is used to pass flags
# `make run ARGS="--zap-devel"` is parsed as
# `go run ./main.go --zap-devel`
run: manifests generate
go fmt ./...
go vet ./...
go run ./main.go $(ARGS)
# find or download controller-gen if necessary
controller-gen:
ifeq ($(wildcard ${CONTROLLER_GEN}),)
@echo "Installing controller-gen@${CONTROLLER_GEN_VERSION} at ${CONTROLLER_GEN}"
@GOBIN=$(LOCALBIN) go install -mod=readonly sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
else ifneq ($(shell ${CONTROLLER_GEN} --version | awk '{print $$2}'), $(CONTROLLER_GEN_VERSION))
@echo "Installing newer controller-gen@${CONTROLLER_GEN_VERSION} at ${CONTROLLER_GEN}"
@GOBIN=$(LOCALBIN) go install -mod=readonly sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
else
@echo "Using existing controller-gen@${CONTROLLER_GEN_VERSION} at ${CONTROLLER_GEN}"
endif
# find or download kustomize if necessary
kustomize:
ifeq ($(wildcard ${KUSTOMIZE}),)
@echo "Installing kustomize@${KUSTOMIZE_VERSION} at ${KUSTOMIZE}"
@curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
else ifneq ($(shell ${KUSTOMIZE} version | awk -F'[ /]' '/Version/{print $$2}'), $(KUSTOMIZE_VERSION))
@echo "Installing newer kustomize@${KUSTOMIZE_VERSION} at ${KUSTOMIZE}"
@rm -f ${KUSTOMIZE}
@curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
else
@echo "Using existing kustomize@${KUSTOMIZE_VERSION} at ${KUSTOMIZE}"
endif
export KUSTOMIZE
install: operator-sdk
@echo "Installing operators"
hack/install-ocs-operator.sh