forked from minio/operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (97 loc) · 4.41 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
PWD := $(shell pwd)
ifeq '${CI}' 'true'
VERSION ?= dev
else
VERSION ?= $(shell git describe --tags)
VERSIONV ?= $(shell git describe --tags | sed 's,v,,g')
endif
TAG ?= "minio/operator:$(VERSION)"
LDFLAGS ?= "-s -w -X main.Version=$(VERSION)"
GOPATH := $(shell go env GOPATH)
GOARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
HELM_HOME=helm/operator
HELM_TEMPLATES=$(HELM_HOME)/templates
KUSTOMIZE_HOME=resources
KUSTOMIZE_CRDS=$(KUSTOMIZE_HOME)/base/crds/
PLUGIN_HOME=kubectl-minio
all: build
getdeps:
@echo "Checking dependencies"
@mkdir -p ${GOPATH}/bin
@echo "Installing golangci-lint" && \
go install github.com/golangci/golangci-lint/cmd/[email protected] && \
echo "Installing govulncheck" && \
go install golang.org/x/vuln/cmd/govulncheck@latest
verify: getdeps govet lint
binary:
@CGO_ENABLED=0 GOOS=linux go build -trimpath --ldflags $(LDFLAGS) -o minio-operator ./cmd/operator
operator: assets binary
docker: operator
@docker build --no-cache -t $(TAG) .
build: regen-crd verify plugin operator docker
install: all
lint: getdeps
@echo "Running $@ check"
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml
govet:
@go vet ./...
gotest:
@go test -race ./...
vulncheck:
@${GOPATH}/bin/govulncheck ./...
clean:
@echo "Cleaning up all the generated files"
@find . -name '*.test' | xargs rm -fv
@find . -name '*~' | xargs rm -fv
@find . -name '*.zip' | xargs rm -fv
@rm -rf dist/
regen-crd:
@go install sigs.k8s.io/controller-tools/cmd/[email protected]
@${GOPATH}/bin/controller-gen crd:maxDescLen=0,generateEmbeddedObjectMeta=true paths="./..." output:crd:artifacts:config=$(KUSTOMIZE_CRDS)
@sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/minio.min.io_tenants.yaml > $(HELM_TEMPLATES)/minio.min.io_tenants.yaml
@sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/sts.min.io_policybindings.yaml > $(HELM_TEMPLATES)/sts.min.io_policybindings.yaml
regen-crd-docs:
@which crd-ref-docs 1>/dev/null || (echo "Installing crd-ref-docs" && GO111MODULE=on go install -v github.com/elastic/crd-ref-docs@latest)
@${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/minio.min.io/v2 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/tenant_crd.adoc --templates-dir=docs/templates/asciidoctor/
@${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/sts.min.io/v1alpha1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/policybinding_crd.adoc --templates-dir=docs/templates/asciidoctor/
plugin: regen-crd
@echo "Building 'kubectl-minio' binary"
@(cd $(PLUGIN_HOME); \
go vet ./... && \
go test -race ./... && \
GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean && \
GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ../.golangci.yml)
generate-code:
@./k8s/update-codegen.sh
generate-openshift-manifests:
@./olm.sh
release: assets generate-openshift-manifests
@./release.sh
apply-gofmt:
@echo "Applying gofmt to all generated an existing files"
@GO111MODULE=on gofmt -w .
clean-swagger:
@echo "cleaning"
@rm -rf models
@rm -rf api/operations
swagger-operator:
@echo "Generating swagger server code from yaml"
@swagger generate server -A operator --main-package=operator --server-package=api --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
@echo "Generating typescript api"
@npx swagger-typescript-api -p ./swagger.yml -o ./web-app/src/api -n operatorApi.ts
@(cd web-app && npm install -g prettier && prettier -w .)
swagger-gen: clean-swagger swagger-operator apply-gofmt
@echo "Done Generating swagger server code from yaml"
assets:
@(if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use && npm install -g yarn ; fi &&\
cd web-app; yarn install; make build-static; yarn prettier --write . --loglevel warn; cd ..)
test-unit-test-operator:
@echo "execute unit test and get coverage for api"
@(cd api && mkdir coverage && GO111MODULE=on go test -test.v -coverprofile=coverage/coverage-unit-test-operatorapi.out)
test-operator-integration:
@(echo "Start cd operator-integration && go test:")
@(pwd)
@(cd operator-integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./operator-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/operator-api.out)
test-operator:
@(env bash $(PWD)/web-app/tests/scripts/operator.sh)