forked from noobaa/noobaa-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
169 lines (135 loc) · 4.05 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
# Required build-tools:
# - go
# - git
# - python3
# - minikube
# - operator-sdk
export GO111MODULE=on
export GOPROXY:=https://proxy.golang.org
TIME ?= time -p
VERSION ?= $(shell go run cmd/version/main.go)
IMAGE ?= noobaa/noobaa-operator:$(VERSION)
REPO ?= github.com/noobaa/noobaa-operator
CATALOG_IMAGE ?= noobaa/noobaa-operator-catalog:$(VERSION)
GO_LINUX ?= GOOS=linux GOARCH=amd64
GOHOSTOS ?= $(shell go env GOHOSTOS)
OUTPUT ?= build/_output
BIN ?= $(OUTPUT)/bin
OLM ?= $(OUTPUT)/olm
VENV ?= $(OUTPUT)/venv
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
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
#-----------#
#- 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-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