Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit ded716b

Browse files
authored
Update Operator SDK to v1.16.0 (#198)
1 parent a084661 commit ded716b

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

Makefile

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
VERSION ?= 0.5.0
77

88
# 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")
1010
# 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")
1313
CHANNELS = "alpha"
1414
ifneq ($(origin CHANNELS), undefined)
1515
BUNDLE_CHANNELS := --channels=$(CHANNELS)
@@ -43,8 +43,6 @@ IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
4343
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
4444
ENVTEST_K8S_VERSION = 1.22
4545

46-
DOCKERFILE ?= Dockerfile
47-
4846
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
4947
ifeq (,$(shell go env GOBIN))
5048
GOBIN=$(shell go env GOPATH)/bin
@@ -58,6 +56,7 @@ endif
5856
SHELL = /usr/bin/env bash -o pipefail
5957
.SHELLFLAGS = -ec
6058

59+
.PHONY: all
6160
all: build
6261

6362
##@ General
@@ -73,73 +72,95 @@ all: build
7372
# More info on the awk command:
7473
# http://linuxcommand.org/lc3_adv_awk.php
7574

75+
.PHONY: help
7676
help: ## Display this help.
7777
@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)
7878

7979
##@ Development
8080

81+
.PHONY: manifests
8182
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
8283
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
8384

85+
.PHONY: generate
8486
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
8587
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
8688

89+
.PHONY: fmt
8790
fmt: ## Run go fmt against code.
8891
go fmt ./...
8992

93+
.PHONY: vet
9094
vet: ## Run go vet against code.
9195
go vet ./...
9296

97+
.PHONY: lint
9398
lint: ## Run golangci-lint against code.
9499
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
95100

101+
.PHONY: unit-tests
96102
unit-test:
97103
go test ./... -coverprofile cover.out
98104

105+
.PHONY: test
99106
test: manifests generate fmt vet envtest ## Run tests.
100107
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
101108

102109
##@ Build
103110

111+
.PHONY: build
104112
build: generate fmt vet ## Build manager binary.
105113
go build -ldflags "-X main.version=${VERSION}" -o bin/manager main.go
106114

115+
.PHONY: run
107116
run: manifests generate fmt vet ## Run a controller from your host.
108117
go run -ldflags "-X main.version=${VERSION}" ./main.go $(ARGS)
109118

119+
.PHONY: docker-build
110120
docker-build: test ## Build docker image with the manager.
111121
docker build -t ${IMG} -f ${DOCKERFILE} . --build-arg VERSION=${VERSION} --target local
112122

123+
.PHONY: docker-push
113124
docker-push: ## Push docker image with the manager.
114125
docker push ${IMG}
115126

116127
##@ Deployment
117128

129+
ifndef ignore-not-found
130+
ignore-not-found = false
131+
endif
132+
133+
.PHONY: install
118134
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
119135
$(KUSTOMIZE) build config/crd | kubectl apply -f -
120136

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 -
123140

141+
.PHONY: deploy
124142
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
125143
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
126144
$(KUSTOMIZE) build config/default | kubectl apply -f -
127145

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 -
131149

132150
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
151+
.PHONY: controller-gen
133152
controller-gen: ## Download controller-gen locally if necessary.
134153
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])
135154

136155
KUSTOMIZE = $(shell pwd)/bin/kustomize
156+
.PHONY: kustomize
137157
kustomize: ## Download kustomize locally if necessary.
138158
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])
139159

140160
ENVTEST = $(shell pwd)/bin/setup-envtest
161+
.PHONY: envtest
141162
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)
143164

144165
# go-get-tool will 'go get' any package $2 and install it to $1.
145166
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
@@ -158,7 +179,7 @@ endef
158179
.PHONY: bundle
159180
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
160181
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
162183
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
163184
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
164185
@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))
182203
set -e ;\
183204
mkdir -p $(dir $(OPM)) ;\
184205
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 ;\
186207
chmod +x $(OPM) ;\
187208
}
188209
else

bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=nginx-ingress-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
99
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
10-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.15.0
10+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.16.0
1111
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1212
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
1313

bundle/manifests/nginx-ingress-operator.clusterserviceversion.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ metadata:
3030
createdAt: placeholder
3131
description: The NGINX Ingress Operator is a Kubernetes/OpenShift component which
3232
deploys and manages one or more NGINX/NGINX Plus Ingress Controllers
33-
operators.operatorframework.io/builder: operator-sdk-v1.15.0
33+
operators.operatorframework.io/builder: operator-sdk-v1.16.0
3434
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
3535
repository: https://github.com/nginxinc/nginx-ingress-operator
3636
support: NGINX Inc.
@@ -354,6 +354,8 @@ spec:
354354
strategy: {}
355355
template:
356356
metadata:
357+
annotations:
358+
kubectl.kubernetes.io/default-container: manager
357359
labels:
358360
control-plane: controller-manager
359361
spec:

bundle/metadata/annotations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ annotations:
66
operators.operatorframework.io.bundle.package.v1: nginx-ingress-operator
77
operators.operatorframework.io.bundle.channels.v1: alpha
88
operators.operatorframework.io.bundle.channel.default.v1: alpha
9-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.15.0
9+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.16.0
1010
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1111
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3
1212

config/manager/manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ spec:
1919
replicas: 1
2020
template:
2121
metadata:
22+
annotations:
23+
kubectl.kubernetes.io/default-container: manager
2224
labels:
2325
control-plane: controller-manager
2426
spec:

0 commit comments

Comments
 (0)