6
6
VERSION ?= 0.5.0
7
7
8
8
# CHANNELS define the bundle channels used in the bundle.
9
- # Add a new line here if you would like to change its default config. (E.g CHANNELS = "preview ,fast,stable")
9
+ # Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate ,fast,stable")
10
10
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
11
- # - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=preview ,fast,stable)
12
- # - use environment variables to overwrite this value (e.g export CHANNELS="preview ,fast,stable")
11
+ # - use the CHANNELS as arg of the bundle target (e.g make bundle CHANNELS=candidate ,fast,stable)
12
+ # - use environment variables to overwrite this value (e.g export CHANNELS="candidate ,fast,stable")
13
13
CHANNELS = "alpha"
14
14
ifneq ($(origin CHANNELS ) , undefined)
15
15
BUNDLE_CHANNELS := --channels=$(CHANNELS )
@@ -43,8 +43,6 @@ IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
43
43
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
44
44
ENVTEST_K8S_VERSION = 1.22
45
45
46
- DOCKERFILE ?= Dockerfile
47
-
48
46
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
49
47
ifeq (,$(shell go env GOBIN) )
50
48
GOBIN =$(shell go env GOPATH) /bin
58
56
SHELL = /usr/bin/env bash -o pipefail
59
57
.SHELLFLAGS = -ec
60
58
59
+ .PHONY : all
61
60
all : build
62
61
63
62
# #@ General
@@ -73,73 +72,95 @@ all: build
73
72
# More info on the awk command:
74
73
# http://linuxcommand.org/lc3_adv_awk.php
75
74
75
+ .PHONY : help
76
76
help : # # Display this help.
77
77
@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 )
78
78
79
79
# #@ Development
80
80
81
+ .PHONY : manifests
81
82
manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
82
83
$(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
83
84
85
+ .PHONY : generate
84
86
generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
85
87
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
86
88
89
+ .PHONY : fmt
87
90
fmt : # # Run go fmt against code.
88
91
go fmt ./...
89
92
93
+ .PHONY : vet
90
94
vet : # # Run go vet against code.
91
95
go vet ./...
92
96
97
+ .PHONY : lint
93
98
lint : # # Run golangci-lint against code.
94
99
docker run --pull always --rm -v $(shell pwd) :/nginx-ingress-operator -w /nginx-ingress-operator -v $(shell go env GOCACHE) :/cache/go -e GOCACHE=/cache/go -e GOLANGCI_LINT_CACHE=/cache/go -v $(shell go env GOPATH) /pkg:/go/pkg golangci/golangci-lint:latest golangci-lint --color always run
95
100
101
+ .PHONY : unit-tests
96
102
unit-test :
97
103
go test ./... -coverprofile cover.out
98
104
105
+ .PHONY : test
99
106
test : manifests generate fmt vet envtest # # Run tests.
100
107
KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) -p path) " go test ./... -coverprofile cover.out
101
108
102
109
# #@ Build
103
110
111
+ .PHONY : build
104
112
build : generate fmt vet # # Build manager binary.
105
113
go build -ldflags " -X main.version=${VERSION} " -o bin/manager main.go
106
114
115
+ .PHONY : run
107
116
run : manifests generate fmt vet # # Run a controller from your host.
108
117
go run -ldflags " -X main.version=${VERSION} " ./main.go $(ARGS )
109
118
119
+ .PHONY : docker-build
110
120
docker-build : test # # Build docker image with the manager.
111
121
docker build -t ${IMG} -f ${DOCKERFILE} . --build-arg VERSION=${VERSION} --target local
112
122
123
+ .PHONY : docker-push
113
124
docker-push : # # Push docker image with the manager.
114
125
docker push ${IMG}
115
126
116
127
# #@ Deployment
117
128
129
+ ifndef ignore-not-found
130
+ ignore-not-found = false
131
+ endif
132
+
133
+ .PHONY : install
118
134
install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
119
135
$(KUSTOMIZE ) build config/crd | kubectl apply -f -
120
136
121
- uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
122
- $(KUSTOMIZE ) build config/crd | kubectl delete -f -
137
+ .PHONY : uninstall
138
+ uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
139
+ $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
123
140
141
+ .PHONY : deploy
124
142
deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
125
143
cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
126
144
$(KUSTOMIZE ) build config/default | kubectl apply -f -
127
145
128
- undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
129
- $( KUSTOMIZE ) build config/default | kubectl delete -f -
130
-
146
+ .PHONY : undeploy
147
+ undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
148
+ $( KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found= $( ignore-not-found ) -f -
131
149
132
150
CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
151
+ .PHONY : controller-gen
133
152
controller-gen : # # Download controller-gen locally if necessary.
134
153
$(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/[email protected] )
135
154
136
155
KUSTOMIZE = $(shell pwd) /bin/kustomize
156
+ .PHONY : kustomize
137
157
kustomize : # # Download kustomize locally if necessary.
138
158
$(call go-get-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/[email protected] )
139
159
140
160
ENVTEST = $(shell pwd) /bin/setup-envtest
161
+ .PHONY : envtest
141
162
envtest : # # Download envtest-setup locally if necessary.
142
- $(call go-get-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@master )
163
+ $(call go-get-tool,$(ENVTEST ) ,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest )
143
164
144
165
# go-get-tool will 'go get' any package $2 and install it to $1.
145
166
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
@@ -158,7 +179,7 @@ endef
158
179
.PHONY : bundle
159
180
bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
160
181
yq eval ' .metadata.annotations.containerImage = "${IMG}"' -i config/manifests/bases/nginx-ingress-operator.clusterserviceversion.yaml
161
- operator-sdk generate kustomize manifests -q
182
+ operator-sdk generate kustomize manifests --interactive=false - q
162
183
cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
163
184
$(KUSTOMIZE ) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
164
185
@printf " %s\n" ' ' ' LABEL com.redhat.openshift.versions="v4.6"' ' LABEL com.redhat.delivery.operator.bundle=true' ' LABEL com.redhat.delivery.backport=true' >> bundle.Dockerfile
@@ -182,7 +203,7 @@ ifeq (,$(shell which opm 2>/dev/null))
182
203
set -e ;\
183
204
mkdir -p $(dir $(OPM)) ;\
184
205
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
185
- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.17.2 /$${OS}-$${ARCH}-opm ;\
206
+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.19.1 /$${OS}-$${ARCH}-opm ;\
186
207
chmod +x $(OPM) ;\
187
208
}
188
209
else
0 commit comments