forked from noobaa/noobaa-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
225 lines (181 loc) · 5.77 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Required build-tools:
# - go
# - git
# - python3
# - minikube
# - operator-sdk
export GO111MODULE=on
export GOPROXY:=https://proxy.golang.org
TIME ?= time -p
ARCH ?= $(shell uname -m)
VERSION ?= $(shell go run cmd/version/main.go)
IMAGE ?= noobaa/noobaa-operator:$(VERSION)
DEV_IMAGE ?= noobaa/noobaa-operator-dev:$(VERSION)
REPO ?= github.com/noobaa/noobaa-operator
CATALOG_IMAGE ?= noobaa/noobaa-operator-catalog:$(VERSION)
BUNDLE_IMAGE ?= noobaa/noobaa-operator-bundle:$(VERSION)
GO_LINUX ?= GOOS=linux GOARCH=amd64
GOHOSTOS ?= $(shell go env GOHOSTOS)
OUTPUT ?= build/_output
BIN ?= $(OUTPUT)/bin
OLM ?= $(OUTPUT)/olm
MANIFESTS ?= $(OUTPUT)/manifests
VENV ?= $(OUTPUT)/venv
# OPERATOR_SDK_VERSION is for build perpuse only, the dependencies themself are
# updated to a new version as stated in the go.mod file
export OPERATOR_SDK_VERSION ?= v0.17.2
export OPERATOR_SDK ?= build/_tools/operator-sdk-$(OPERATOR_SDK_VERSION)
KUBECONFIG ?= build/empty-kubeconfig
#------------#
#- Building -#
#------------#
all: build
@echo "✅ all"
.PHONY: all
build: cli image gen-olm
@echo "✅ build"
.PHONY: build
cli: $(OPERATOR_SDK) gen
$(OPERATOR_SDK) run --kubeconfig="$(KUBECONFIG)" --local --operator-flags "version"
@echo "✅ cli"
.PHONY: cli
image: $(OPERATOR_SDK) gen
$(OPERATOR_SDK) build $(IMAGE)
@echo "✅ image"
.PHONY: image
dev-image: $(OPERATOR_SDK) gen
$(OPERATOR_SDK) build --go-build-args "-gcflags all=-N -gcflags all=-l" $(IMAGE)
docker build -f build/DockerfileDev --build-arg base_image=$(IMAGE) -t $(DEV_IMAGE) .
@echo "✅ dev image"
.PHONY: dev-image
vendor:
go mod tidy
go mod vendor
@echo "✅ vendor"
.PHONY: vendor
run: $(OPERATOR_SDK) gen
$(OPERATOR_SDK) run --local --operator-flags "operator run"
.PHONY: run
clean:
rm -rf $(OUTPUT)
rm -rf vendor/
@echo "✅ clean"
.PHONY: clean
release-docker:
docker push $(IMAGE)
docker push $(CATALOG_IMAGE)
@echo "✅ docker push"
.PHONY: release-docker
release-cli:
mkdir -p build-releases
cp build/_output/bin/noobaa-operator build-releases/noobaa-linux-v$(VERSION)
@echo "✅ build-releases/noobaa-linux-v$(VERSION)"
cp build/_output/bin/noobaa-operator-local build-releases/noobaa-mac-v$(VERSION)
@echo "✅ build-releases/noobaa-mac-v$(VERSION)"
.PHONY: release-cli
release: release-docker release-cli
.PHONY: release
$(OPERATOR_SDK):
bash build/install-operator-sdk.sh
@echo "✅ $(OPERATOR_SDK)"
#------------#
#- Generate -#
#------------#
gen: vendor pkg/bundle/deploy.go
@echo "✅ gen"
.PHONY: gen
pkg/bundle/deploy.go: pkg/bundler/bundler.go version/version.go $(shell find deploy/ -type f)
mkdir -p pkg/bundle
go run pkg/bundler/bundler.go deploy/ pkg/bundle/deploy.go
gen-api: $(OPERATOR_SDK) gen
$(TIME) $(OPERATOR_SDK) generate k8s
$(TIME) $(OPERATOR_SDK) generate crds --crd-version v1
@echo "✅ gen-api"
.PHONY: gen-api
gen-api-fail-if-dirty: gen-api
git diff --exit-code || ( \
echo "Build failed: gen-api is not up to date."; \
echo "Run 'make gen-api' and update your PR."; \
exit 1; \
)
.PHONY: gen-api-fail-if-dirty
gen-olm: $(OPERATOR_SDK) gen
rm -rf $(OLM)
$(OPERATOR_SDK) run --kubeconfig="$(KUBECONFIG)" --local --operator-flags "olm catalog -n my-noobaa-operator --dir $(OLM)"
python3 -m venv $(VENV) && \
. $(VENV)/bin/activate && \
pip3 install --upgrade pip && \
pip3 install operator-courier==2.1.11 && \
operator-courier --verbose verify --ui_validate_io $(OLM)
docker build -t $(CATALOG_IMAGE) -f build/catalog-source.Dockerfile .
@echo "✅ gen-olm"
.PHONY: gen-olm
gen-odf-package: cli
rm -rf $(MANIFESTS)
MANIFESTS="$(MANIFESTS)" CSV_NAME="$(csv-name)" SKIP_RANGE="$(skip-range)" REPLACES="$(replaces)" CORE_IMAGE="$(core-image)" DB_IMAGE="$(db-image)" OPERATOR_IMAGE="$(operator-image)" build/gen-odf-package.sh
@echo "✅ gen-odf-package"
.PHONY: gen-odf-package
bundle-image: gen-odf-package
docker build -t $(BUNDLE_IMAGE) -f build/bundle/Dockerfile .
#-----------#
#- Testing -#
#-----------#
test: lint test-go
@echo "✅ test"
.PHONY: test
golangci-lint: gen
golangci-lint run --disable-all -E varcheck,structcheck,typecheck,errcheck,gosimple,unused,deadcode,ineffassign,staticcheck --timeout=10m
@echo "✅ golangci-lint"
.PHONY: golangci-lint
lint: gen
GO111MODULE=off go get -u -a golang.org/x/lint/golint
GO111MODULE=off go run golang.org/x/lint/golint \
-set_exit_status=1 \
$$(go list ./... | cut -d'/' -f5- | sed 's/^\(.*\)$$/\.\/\1\//' | grep -v ./pkg/apis/noobaa/v1alpha1/ | grep -v ./pkg/bundle/)
@echo
GO111MODULE=off go run golang.org/x/lint/golint \
-set_exit_status=1 \
$$(echo ./pkg/apis/noobaa/v1alpha1/* | tr ' ' '\n' | grep -v '/zz_generated')
@echo "✅ lint"
.PHONY: lint
test-go: gen cli
$(TIME) go test ./pkg/... ./cmd/... ./version/...
@echo "✅ test-go"
.PHONY: test-go
test-cli-flow:
$(TIME) ./test/cli/test_cli_flow.sh
@echo "✅ test-cli-flow"
.PHONY: test-cli-flow
test-core-config-map-flow:
$(TIME) ./test/cli/test_cli_flow.sh --check_core_config_map
@echo "✅ test-core-config-map-flow"
.PHONY: test-core-config-map-flow
# test-olm runs tests for the OLM package
test-olm: $(OPERATOR_SDK) gen-olm
$(TIME) ./test/test-olm.sh $(CATALOG_IMAGE)
@echo "✅ test-olm"
.PHONY: test-olm
test-hac: vendor
ginkgo -v pkg/controller/ha
@echo "✅ test-hac"
.PHONY: test-hac
test-kms-dev: vendor
ginkgo -v pkg/util/kms/test/dev
@echo "✅ test-kms-dev"
.PHONY: test-kms-dev
test-kms-tls-sa: vendor
ginkgo -v pkg/util/kms/test/tls-sa
@echo "✅ test-kms-tls-sa"
.PHONY: test-kms-tls-sa
test-kms-tls-token: vendor
ginkgo -v pkg/util/kms/test/tls-token
@echo "✅ test-kms-tls-token"
.PHONY: test-kms-tls-token
test-kms-ibm-kp: vendor
ginkgo -v pkg/util/kms/test/ibm-kp
@echo "✅ test-kms-ibm-kp"
.PHONY: test-kms-ibm-kp
test-admission: vendor
ginkgo -v pkg/admission/test/integ
@echo "✅ test-admission"
.PHONY: test-admission