forked from operator-framework/operator-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
282 lines (201 loc) · 9.09 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# kernel-style V=1 build verbosity
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
endif
ifeq ($(BUILD_VERBOSE),1)
Q =
else
Q = @
endif
VERSION = $(shell git describe --dirty --tags --always)
GIT_COMMIT = $(shell git rev-parse HEAD)
K8S_VERSION = v1.18.2
REPO = github.com/operator-framework/operator-sdk
BUILD_PATH = $(REPO)/cmd/operator-sdk
PKGS = $(shell go list ./... | grep -v /vendor/)
TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/')
SOURCES = $(shell find . -name '*.go' -not -path "*/vendor/*")
# GO_BUILD_ARGS should be set when running 'go build' or 'go install'.
GO_BUILD_ARGS = \
-gcflags "all=-trimpath=$(shell go env GOPATH)" \
-asmflags "all=-trimpath=$(shell go env GOPATH)" \
-ldflags " \
-X '$(REPO)/version.GitVersion=$(VERSION)' \
-X '$(REPO)/version.GitCommit=$(GIT_COMMIT)' \
-X '$(REPO)/version.KubernetesVersion=$(K8S_VERSION)' \
" \
ANSIBLE_BASE_IMAGE = quay.io/operator-framework/ansible-operator
HELM_BASE_IMAGE = quay.io/operator-framework/helm-operator
SCORECARD_PROXY_BASE_IMAGE = quay.io/operator-framework/scorecard-proxy
SCORECARD_TEST_BASE_IMAGE = quay.io/operator-framework/scorecard-test
ANSIBLE_IMAGE ?= $(ANSIBLE_BASE_IMAGE)
HELM_IMAGE ?= $(HELM_BASE_IMAGE)
SCORECARD_PROXY_IMAGE ?= $(SCORECARD_PROXY_BASE_IMAGE)
SCORECARD_TEST_IMAGE ?= $(SCORECARD_TEST_BASE_IMAGE)
ANSIBLE_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
HELM_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
SCORECARD_PROXY_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
SCORECARD_TEST_ARCHES:="amd64" "ppc64le" "s390x" "arm64"
export CGO_ENABLED:=0
.DEFAULT_GOAL:=help
.PHONY: help
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##############################
# Development #
##############################
##@ Development
.PHONY: all install
all: format test build/operator-sdk ## Test and Build the Operator SDK
install: ## Install the operator-sdk binary
$(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(BUILD_PATH)
# Code management.
.PHONY: format tidy clean cli-doc lint
format: ## Format the source code
$(Q)go fmt $(PKGS)
tidy: ## Update dependencies
$(Q)go mod tidy -v
clean: ## Clean up the build artifacts
$(Q)rm -rf build
lint-dev: ## Run golangci-lint with all checks enabled (development purpose only)
./hack/tests/check-lint.sh dev
lint-fix: ## Run golangci-lint automatically fix (development purpose only)
./hack/tests/check-lint.sh fix
lint: ## Run golangci-lint with all checks enabled in the ci
./hack/tests/check-lint.sh ci
setup-k8s:
hack/ci/setup-k8s.sh ${K8S_VERSION}
##############################
# Generate Artifacts #
##############################
##@ Generate
.PHONY: generate gen-cli-doc gen-test-framework gen-changelog
generate: gen-cli-doc gen-test-framework ## Run all non-release generate targets
gen-cli-doc: ## Generate CLI documentation
./hack/generate/cli-doc/gen-cli-doc.sh
gen-test-framework: build/operator-sdk ## Run generate commands to update test/test-framework
./hack/generate/test-framework/gen-test-framework.sh
gen-changelog: ## Generate CHANGELOG.md and migration guide updates
./hack/generate/changelog/gen-changelog.sh
##############################
# Release #
##############################
##@ Release
# Build/install/release the SDK.
.PHONY: release_builds release
release_builds := \
build/operator-sdk-$(VERSION)-aarch64-linux-gnu \
build/operator-sdk-$(VERSION)-x86_64-linux-gnu \
build/operator-sdk-$(VERSION)-x86_64-apple-darwin \
build/operator-sdk-$(VERSION)-ppc64le-linux-gnu \
build/operator-sdk-$(VERSION)-s390x-linux-gnu
release: clean $(release_builds) $(release_builds:=.asc) ## Release the Operator SDK
build/operator-sdk-%-aarch64-linux-gnu: GOARGS = GOOS=linux GOARCH=arm64
build/operator-sdk-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64
build/operator-sdk-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64
build/operator-sdk-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le
build/operator-sdk-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
build/operator-sdk-%-linux-gnu: GOARGS = GOOS=linux
build/%: $(SOURCES) ## Build the operator-sdk binary
$(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(BUILD_PATH)
build/%.asc: ## Create release signatures for operator-sdk release binaries
$(Q){ \
default_key=$$(gpgconf --list-options gpg | awk -F: '$$1 == "default-key" { gsub(/"/,""); print toupper($$10)}'); \
git_key=$$(git config --get user.signingkey | awk '{ print toupper($$0) }'); \
if [ "$${default_key}" = "$${git_key}" ]; then \
gpg --output $@ --detach-sig build/$*; \
gpg --verify $@ build/$*; \
else \
echo "git and/or gpg are not configured to have default signing key $${default_key}"; \
exit 1; \
fi; \
}
# Image scaffold/build/push.
.PHONY: image image-build image-push
image: image-build image-push ## Build and push all images
image-build: image-build-ansible image-build-helm image-build-scorecard-proxy image-build-scorecard-test ## Build all images
image-push: image-push-ansible image-push-helm image-push-scorecard-proxy image-push-scorecard-test ## Push all images
# Ansible operator image scaffold/build/push.
.PHONY: image-scaffold-ansible image-build-ansible image-push-ansible image-push-ansible-multiarch
image-scaffold-ansible:
go run ./hack/image/ansible/scaffold-ansible-image.go
image-build-ansible: build/operator-sdk-dev-linux-gnu
./hack/image/build-ansible-image.sh $(ANSIBLE_BASE_IMAGE):dev
image-push-ansible:
./hack/image/push-image-tags.sh $(ANSIBLE_BASE_IMAGE):dev $(ANSIBLE_IMAGE)-$(shell go env GOARCH)
image-push-ansible-multiarch:
./hack/image/push-manifest-list.sh $(ANSIBLE_IMAGE) ${ANSIBLE_ARCHES}
# Helm operator image scaffold/build/push.
.PHONY: image-scaffold-helm image-build-helm image-push-helm image-push-helm-multiarch
image-scaffold-helm:
go run ./hack/image/helm/scaffold-helm-image.go
image-build-helm: build/operator-sdk-dev-linux-gnu
./hack/image/build-helm-image.sh $(HELM_BASE_IMAGE):dev
image-push-helm:
./hack/image/push-image-tags.sh $(HELM_BASE_IMAGE):dev $(HELM_IMAGE)-$(shell go env GOARCH)
image-push-helm-multiarch:
./hack/image/push-manifest-list.sh $(HELM_IMAGE) ${HELM_ARCHES}
# Scorecard proxy image scaffold/build/push.
.PHONY: image-build-scorecard-proxy image-push-scorecard-proxy image-push-scorecard-proxy-multiarch
image-build-scorecard-proxy:
./hack/image/build-scorecard-proxy-image.sh $(SCORECARD_PROXY_BASE_IMAGE):dev
image-push-scorecard-proxy:
./hack/image/push-image-tags.sh $(SCORECARD_PROXY_BASE_IMAGE):dev $(SCORECARD_PROXY_IMAGE)-$(shell go env GOARCH)
image-push-scorecard-proxy-multiarch:
./hack/image/push-manifest-list.sh $(SCORECARD_PROXY_IMAGE) ${SCORECARD_PROXY_ARCHES}
# Scorecard test image scaffold/build/push.
.PHONY: image-build-scorecard-test image-push-scorecard-test image-push-scorecard-test-multiarch
image-build-scorecard-test:
./hack/image/build-scorecard-test-image.sh $(SCORECARD_TEST_BASE_IMAGE):dev
image-push-scorecard-test:
./hack/image/push-image-tags.sh $(SCORECARD_TEST_BASE_IMAGE):dev $(SCORECARD_TEST_IMAGE)-$(shell go env GOARCH)
image-push-scorecard-test-multiarch:
./hack/image/push-manifest-list.sh $(SCORECARD_TEST_IMAGE) ${SCORECARD_TEST_ARCHES}
##############################
# Tests #
##############################
##@ Tests
# Static tests.
.PHONY: test test-sanity test-unit
test: test-unit ## Run the tests
test-sanity: tidy build/operator-sdk lint
./hack/tests/sanity-check.sh
test-unit: ## Run the unit tests
$(Q)go test -coverprofile=coverage.out -covermode=count -count=1 -short $(TEST_PKGS)
test-links:
./hack/check-links.sh
# CI tests.
.PHONY: test-ci
test-ci: test-sanity test-unit install test-subcommand test-e2e ## Run the CI test suite
# Subcommand tests.
.PHONY: test-subcommand test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install
test-subcommand: test-subcommand-local test-subcommand-scorecard test-subcommand-olm-install
./hack/tests/subcommand-bundle.sh
./hack/tests/subcommand-generate-csv.sh
test-subcommand-local:
./hack/tests/subcommand.sh
test-subcommand-scorecard:
./hack/tests/subcommand-scorecard.sh
test-subcommand-olm-install:
./hack/tests/subcommand-olm-install.sh
# E2E tests.
.PHONY: test-e2e test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm
test-e2e: test-e2e-go test-e2e-go-new test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests
test-e2e-go:
./hack/tests/e2e-go.sh $(ARGS)
test-e2e-go-new:
K8S_VERSION=$(K8S_VERSION) ./hack/tests/e2e-go-new.sh
test-e2e-ansible: image-build-ansible
./hack/tests/e2e-ansible.sh
test-e2e-ansible-molecule: image-build-ansible
./hack/tests/e2e-ansible-molecule.sh
test-e2e-helm: image-build-helm
./hack/tests/e2e-helm.sh
# Integration tests.
.PHONY: test-integration
test-integration: ## Run integration tests
./hack/tests/integration.sh