-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
145 lines (103 loc) · 4.02 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
export GOPROXY=https://proxy.golang.org
CONTROLLER_GEN_VERSION="v0.14.0"
CSV_PATH=bundle/manifests/ibm-storage-odf-operator.clusterserviceversion.yaml
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
LINT_VERSION="1.40.0"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: build
##@ General
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-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
ensure-yq:
@echo "Ensuring yq CLI tool installed..."
hack/ensure-yq.sh
ensure-opm:
@echo "Ensuring opm CLI tool installed..."
hack/ensure-opm.sh
ensure-operator-sdk:
@echo "Ensuring operator-sdk CLI tool installed..."
hack/ensure-operator-sdk.sh
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) --version
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
fmt: ## Run go fmt against code
go fmt ./...
vet: ## Run go vet against code
go vet ./...
test: manifests generate fmt vet ## Run tests
hack/envtest.sh
add-copyright:
hack/add-copyright.sh
check-copyright:
hack/check-copyright.sh
.PHONY: deps
deps:
@if ! which golangci-lint >/dev/null || [[ "$$(golangci-lint --version)" != *${LINT_VERSION}* ]]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v${LINT_VERSION}; \
fi
.PHONY: lint
lint: deps
golangci-lint run -E gosec --timeout=6m # Run `make lint-fix` may help to fix lint issues.
.PHONY: lint-fix
lint-fix: deps
golangci-lint run --fix
##@ Build
build: generate fmt vet ## Build manager binary
go build -o bin/manager main.go
run: manifests generate fmt vet ## Run a controller from your host
go run ./main.go
docker-build: ## Build docker image with the manager
hack/build-operator-image.sh
.PHONY: bundle ## Generate bundle manifests and metadata, then validate generated files.
bundle: ensure-operator-sdk manifests kustomize ensure-yq
hack/bundle-manifests.sh
bundle-build: bundle ## Build the bundle image
hack/build-operator-bundle.sh
build-catalog:
hack/build-operator-catalog.sh
build-must-gather:
hack/build-must-gather.sh
##@ Deployment
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config
hack/install-crds.sh
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config
hack/uninstall-crds.sh
deploy-catalog:
hack/deploy-catalog-source.sh
undeploy-catalog:
hack/delete-catalog-source.sh
deploy: manifests kustomize csicryaml ## Deploy controller to the K8s cluster specified in ~/.kube/config
hack/deploy-operator.sh
undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config
hack/undeploy-operator.sh
.PHONY: clean
clean:
hack/clean.sh
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION})
kustomize: ## Download kustomize locally if necessary
hack/ensure-kustomize.sh
csicryaml:
hack/ensure-blockcsi-cryaml.sh
# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef