forked from operator-framework/operator-lifecycle-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
219 lines (169 loc) · 7.13 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
##########################
# OLM - Build and Test #
##########################
# Undefine GOFLAGS environment variable.
ifdef GOFLAGS
$(warning Undefining GOFLAGS set in CI)
undefine GOFLAGS
endif
SHELL := /bin/bash
PKG := github.com/operator-framework/operator-lifecycle-manager
MOD_FLAGS := $(shell (go version | grep -q -E "1\.1[1-9]") && echo -mod=vendor)
CMDS := $(shell go list $(MOD_FLAGS) ./cmd/...)
TCMDS := $(shell go list $(MOD_FLAGS) ./test/e2e/...)
MOCKGEN := ./scripts/update_mockgen.sh
CODEGEN := ./scripts/update_codegen.sh
IMAGE_REPO := quay.io/operator-framework/olm
IMAGE_TAG ?= "dev"
SPECIFIC_UNIT_TEST := $(if $(TEST),-run $(TEST),)
LOCAL_NAMESPACE := "olm"
export GO111MODULE=on
CONTROLLER_GEN := go run $(MOD_FLAGS) ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v2/
# ART builds are performed in dist-git, with content (but not commits) copied
# from the source repo. Thus at build time if your code is inspecting the local
# git repo it is getting unrelated commits and tags from the dist-git repo,
# not the source repo.
# For ART image builds, SOURCE_GIT_COMMIT, SOURCE_GIT_TAG, SOURCE_DATE_EPOCH
# variables are inserted in Dockerfile to enable recovering the original git
# metadata at build time.
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))
.PHONY: build test run clean vendor schema-check \
vendor-update coverage coverage-html e2e .FORCE
all: test build
test: clean cover.out
unit:
go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -v -race -count=1 ./pkg/...
schema-check:
cover.out: schema-check
go test $(MOD_FLAGS) -v -race -coverprofile=cover.out -covermode=atomic \
-coverpkg ./pkg/controller/... ./pkg/...
coverage: cover.out
go tool cover -func=cover.out
coverage-html: cover.out
go tool cover -html=cover.out
build: build_cmd=build
build: clean $(CMDS)
test-bare: BUILD_TAGS=-tags=bare
test-bare: clean $(TCMDS)
test-bin: clean $(TCMDS)
# build versions of the binaries with coverage enabled
build-coverage: build_cmd=test -c -covermode=count -coverpkg ./pkg/controller/...
build-coverage: clean $(CMDS)
build-linux: build_cmd=build
build-linux: arch_flags=GOOS=linux GOARCH=386
build-linux: clean $(CMDS)
build-wait: clean bin/wait
bin/wait:
GOOS=linux GOARCH=386 go build $(MOD_FLAGS) -o $@ $(PKG)/test/e2e/wait
build-util-linux: arch_flags=GOOS=linux GOARCH=386
build-util-linux: build-util
build-util: bin/cpb
bin/cpb:
CGO_ENABLED=0 $(arch_flags) go build $(MOD_FLAGS) -ldflags '-extldflags "-static"' -o $@ ./util/cpb
$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=$(GIT_COMMIT) -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
$(CMDS):
$(arch_flags) go $(build_cmd) $(MOD_FLAGS) $(version_flags) -o bin/$(shell basename $@) $@
build: clean $(CMDS)
$(TCMDS):
go test -c $(BUILD_TAGS) $(MOD_FLAGS) -o bin/$(shell basename $@) $@
run-local: build-linux build-wait build-util-linux
rm -rf build
. ./scripts/build_local.sh
mkdir -p build/resources
. ./scripts/package_release.sh 1.0.0 build/resources doc/install/local-values.yaml
. ./scripts/install_local.sh $(LOCAL_NAMESPACE) build/resources
rm -rf build
deploy-local:
mkdir -p build/resources
. ./scripts/package_release.sh 1.0.0 build/resources doc/install/local-values.yaml
. ./scripts/install_local.sh $(LOCAL_NAMESPACE) build/resources
rm -rf build
e2e.namespace:
@printf "e2e-tests-$(shell date +%s)-$$RANDOM" > e2e.namespace
# useful if running e2e directly with `go test -tags=bare`
setup-bare: clean e2e.namespace
. ./scripts/build_bare.sh
. ./scripts/package_release.sh 1.0.0 test/e2e/resources test/e2e/e2e-bare-values.yaml
. ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources
# e2e test exculding the rh-operators directory which tests rh-operators and their metric cardinality.
e2e:
go test -v $(MOD_FLAGS) -failfast -timeout 70m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager -dummyImage=bitnami/nginx:latest
e2e-local: build-linux build-wait build-util-linux
. ./scripts/build_local.sh
. ./scripts/run_e2e_local.sh $(TEST)
e2e-bare: setup-bare
. ./scripts/run_e2e_bare.sh $(TEST)
e2e-local-docker:
. ./scripts/build_local.sh
. ./scripts/run_e2e_docker.sh $(TEST)
e2e-operator-metrics:
go test -v $(MOD_FLAGS) -failfast -timeout 70m ./test/rh-operators/...
vendor:
go mod tidy
go mod vendor
container:
docker build -t $(IMAGE_REPO):$(IMAGE_TAG) .
clean-e2e:
kubectl delete crds --all
kubectl delete apiservices.apiregistration.k8s.io v1.packages.operators.coreos.com || true
kubectl delete -f test/e2e/resources/0000_50_olm_00-namespace.yaml
clean:
@rm -rf cover.out
@rm -rf bin
@rm -rf test/e2e/resources
@rm -rf test/e2e/test-resources
@rm -rf test/e2e/log
@rm -rf e2e.namespace
# Generate manifests for CRDs
manifests: vendor
$(CONTROLLER_GEN) schemapatch:manifests=./deploy/chart/templates paths=./pkg/api/apis/operators/... output:dir=./deploy/chart/templates
$(YQ_INTERNAL) w --inplace deploy/chart/templates/0000_50_olm_03-clusterserviceversion.crd.yaml spec.validation.openAPIV3Schema.properties.spec.properties.install.properties.spec.properties.deployments.items.properties.spec.properties.template.properties.metadata.x-kubernetes-preserve-unknown-fields true
# Generate clients, listers, and informers
codegen:
$(CODEGEN)
# Generate mock types.
mockgen:
$(MOCKGEN)
# Generates everything.
gen-all: codegen mockgen manifests
diff:
git diff --exit-code
verify-codegen: codegen diff
verify-mockgen: mockgen diff
verify-manifests: manifests diff
verify: verify-codegen verify-mockgen verify-manifests
# before running release, bump the version in OLM_VERSION and push to master,
# then tag those builds in quay with the version in OLM_VERSION
release: ver=$(shell cat OLM_VERSION)
release:
docker pull quay.io/operator-framework/olm:$(ver)
$(MAKE) target=upstream ver=$(ver) quickstart=true package
$(MAKE) target=ocp ver=$(ver) package
rm -rf manifests
mkdir manifests
cp -R deploy/ocp/manifests/$(ver)/. manifests
# requires gnu sed if on mac
find ./manifests -type f -exec sed -i "/^#/d" {} \;
find ./manifests -type f -exec sed -i "1{/---/d}" {} \;
verify-release: release diff
package: olmref=$(shell docker inspect --format='{{index .RepoDigests 0}}' quay.io/operator-framework/olm:$(ver))
package:
ifndef target
$(error target is undefined)
endif
ifndef ver
$(error ver is undefined)
endif
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml olm.image.ref $(olmref)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml catalog.image.ref $(olmref)
$(YQ_INTERNAL) w -i deploy/$(target)/values.yaml package.image.ref $(olmref)
./scripts/package_release.sh $(ver) deploy/$(target)/manifests/$(ver) deploy/$(target)/values.yaml
ln -sfFn ./$(ver) deploy/$(target)/manifests/latest
ifeq ($(quickstart), true)
./scripts/package_quickstart.sh deploy/$(target)/manifests/$(ver) deploy/$(target)/quickstart/olm.yaml deploy/$(target)/quickstart/crds.yaml deploy/$(target)/quickstart/install.sh
endif
.PHONY: run-console-local
run-console-local:
@echo Running script to run the OLM console locally:
. ./scripts/run_console_local.sh