Skip to content

Commit e4bad1c

Browse files
authored
update tool dependency for code and manifest (#169)
1 parent 6d3ef88 commit e4bad1c

File tree

9 files changed

+130
-28
lines changed

9 files changed

+130
-28
lines changed

Makefile

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ KUBECTL ?= $(shell which kubectl)
1919
OPERATOR_SDK ?= $(shell which operator-sdk)
2020
CONTROLLER_GEN ?= $(shell which controller-gen)
2121
KUSTOMIZE ?= $(shell which kustomize)
22+
YQ_VERSION=3.4.0
23+
KUSTOMIZE_VERSION=v3.8.7
24+
OPERATOR_SDK_VERSION=v1.20.0
25+
26+
GOPATH=$(HOME)/go/bin/
2227

2328
# Specify whether this repo is build locally or not, default values is '1';
2429
# If set to 1, then you need to also set 'DOCKER_USERNAME' and 'DOCKER_PASSWORD'
@@ -72,8 +77,8 @@ OPERATOR_IMAGE_NAME ?= ibm-namespace-scope-operator
7277
OPERATOR_VERSION ?= 1.14.0
7378

7479
# Options for 'bundle-build'
75-
CHANNELS ?= beta
76-
DEFAULT_CHANNEL ?= beta
80+
CHANNELS ?= v3
81+
DEFAULT_CHANNEL ?= v3
7782
ifneq ($(origin CHANNELS), undefined)
7883
BUNDLE_CHANNELS := --channels=$(CHANNELS)
7984
endif
@@ -126,32 +131,79 @@ undeploy: ## Undeploy controller in the configured Kubernetes cluster in ~/.kube
126131
cd config/manager && $(KUSTOMIZE) edit set image ibm-namespace-scope-operator=$(QUAY_REGISTRY)/$(OPERATOR_IMAGE_NAME):$(OPERATOR_VERSION)
127132
$(KUSTOMIZE) build config/default | kubectl delete -f -
128133

129-
##@ Generate code and manifests
134+
kustomize: ## Install kustomize
135+
ifeq (, $(shell which kustomize 2>/dev/null))
136+
@{ \
137+
set -e ;\
138+
mkdir -p bin ;\
139+
echo "Downloading kustomize ...";\
140+
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/$(KUSTOMIZE_VERSION)/kustomize_$(KUSTOMIZE_VERSION)_$(LOCAL_OS)_$(LOCAL_ARCH).tar.gz | tar xzf - -C bin/ ;\
141+
}
142+
KUSTOMIZE=$(realpath ./bin/kustomize)
143+
else
144+
KUSTOMIZE=$(shell which kustomize)
145+
endif
146+
147+
operator-sdk:
148+
ifneq ($(shell operator-sdk version | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '"' | xargs | cut -d '.' -f1), v1)
149+
@{ \
150+
if [ "$(shell ./bin/operator-sdk version | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '"' | xargs)" != $(OPERATOR_SDK_VERSION) ]; then \
151+
set -e ; \
152+
mkdir -p bin ;\
153+
echo "Downloading operator-sdk..." ;\
154+
curl -sSLo ./bin/operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(LOCAL_OS)_$(LOCAL_ARCH)" ;\
155+
chmod +x ./bin/operator-sdk ;\
156+
fi ;\
157+
}
158+
OPERATOR_SDK=$(realpath ./bin/operator-sdk)
159+
else
160+
OPERATOR_SDK=$(shell which operator-sdk)
161+
endif
162+
163+
yq: ## Install yq, a yaml processor
164+
ifneq ($(shell yq -V | cut -d ' ' -f 3 | cut -d '.' -f 1 ), 4)
165+
@{ \
166+
if [ v$(shell ./bin/yq --version | cut -d ' ' -f3) != $(YQ_VERSION) ]; then\
167+
set -e ;\
168+
mkdir -p bin ;\
169+
echo "Downloading yq ...";\
170+
curl -sSLO https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$(LOCAL_OS)_$(LOCAL_ARCH);\
171+
mv yq_$(LOCAL_OS)_$(LOCAL_ARCH) ./bin/yq ;\
172+
chmod +x ./bin/yq ;\
173+
fi;\
174+
}
175+
YQ=$(realpath ./bin/yq)
176+
else
177+
YQ=$(shell which yq)
178+
endif
179+
180+
clis: yq kustomize operator-sdk controller-gen
130181

131-
manifests: ## Generate manifests e.g. CRD, RBAC etc.
182+
##@ Generate code and manifests
183+
manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc.
132184
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=ibm-namespace-scope-operator webhook paths="./..." output:crd:artifacts:config=config/crd/bases
133185

134-
generate: ## Generate code e.g. API etc.
186+
generate: controller-gen ## Generate code e.g. API etc.
135187
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
136188

137-
generate-csv-manifests: ## Generate CSV manifests
189+
generate-csv-manifests: operator-sdk ## Generate CSV manifests
138190
$(OPERATOR_SDK) generate kustomize manifests
139191

140-
bundle: generate manifests ## Generate bundle and restricted bundle manifests
192+
bundle: clis generate manifests ## Generate bundle and restricted bundle manifests
141193
# Generate restricted bundle manifests
142-
@yq w -i PROJECT 'projectName' ibm-namespace-scope-operator-restricted
143-
@yq w -i config/rbac/role.yaml 'kind' Role
144-
@yq w -i config/rbac/role_binding.yaml 'kind' RoleBinding
145-
@yq w -i config/rbac/role_binding.yaml 'roleRef.kind' Role
194+
@$(YQ) w -i PROJECT 'projectName' ibm-namespace-scope-operator-restricted
195+
@$(YQ) w -i config/rbac/role.yaml 'kind' Role
196+
@$(YQ) w -i config/rbac/role_binding.yaml 'kind' RoleBinding
197+
@$(YQ) w -i config/rbac/role_binding.yaml 'roleRef.kind' Role
146198
- $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle \
147199
-q --version $(OPERATOR_VERSION) $(BUNDLE_METADATA_OPTS) \
148200
--output-dir bundle-restricted
149201
@rm -f ./bundle-restricted/manifests/ibm-namespace-scope-operator.clusterserviceversion.yaml
150202
- $(OPERATOR_SDK) bundle validate ./bundle-restricted
151-
@yq w -i PROJECT 'projectName' ibm-namespace-scope-operator
152-
@yq w -i config/rbac/role.yaml 'kind' ClusterRole
153-
@yq w -i config/rbac/role_binding.yaml 'kind' ClusterRoleBinding
154-
@yq w -i config/rbac/role_binding.yaml 'roleRef.kind' ClusterRole
203+
@$(YQ) w -i PROJECT 'projectName' ibm-namespace-scope-operator
204+
@$(YQ) w -i config/rbac/role.yaml 'kind' ClusterRole
205+
@$(YQ) w -i config/rbac/role_binding.yaml 'kind' ClusterRoleBinding
206+
@$(YQ) w -i config/rbac/role_binding.yaml 'roleRef.kind' ClusterRole
155207

156208
# Generate bundle manifests
157209
- $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle \

bundle-restricted/manifests/ibm-namespace-scope-operator-restricted.clusterserviceversion.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ metadata:
2323
]
2424
capabilities: Seamless Upgrades
2525
containerImage: icr.io/cpopen/ibm-namespace-scope-operator:latest
26-
createdAt: "2022-06-23T10:44:01Z"
26+
createdAt: "2020-11-2T15:38:33Z"
2727
olm.skipRange: '<1.14.0'
28-
operators.operatorframework.io/builder: operator-sdk-v1.11.0+git
28+
operators.operatorframework.io/builder: operator-sdk-v1.19.0+git
2929
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
3030
repository: https://github.com/IBM/ibm-namespace-scope-operator
3131
support: IBM
@@ -49,7 +49,11 @@ spec:
4949
install:
5050
spec:
5151
deployments:
52-
- name: ibm-namespace-scope-operator
52+
- label:
53+
app.kubernetes.io/instance: ibm-namespace-scope-operator
54+
app.kubernetes.io/managed-by: ibm-namespace-scope-operator
55+
app.kubernetes.io/name: ibm-namespace-scope-operator
56+
name: ibm-namespace-scope-operator
5357
spec:
5458
replicas: 1
5559
selector:

bundle-restricted/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: ibm-namespace-scope-operator-restricted
77
operators.operatorframework.io.bundle.channels.v1: v3
88
operators.operatorframework.io.bundle.channel.default.v1: v3
9-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.10.0+git
9+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.19.0+git
1010
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1111
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v2
1212

bundle-restricted/tests/scorecard/config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,59 @@ stages:
1212
labels:
1313
suite: basic
1414
test: basic-check-spec-test
15+
storage:
16+
spec:
17+
mountPath: {}
1518
- entrypoint:
1619
- scorecard-test
1720
- olm-bundle-validation
1821
image: quay.io/operator-framework/scorecard-test:v1.1.0
1922
labels:
2023
suite: olm
2124
test: olm-bundle-validation-test
25+
storage:
26+
spec:
27+
mountPath: {}
2228
- entrypoint:
2329
- scorecard-test
2430
- olm-crds-have-validation
2531
image: quay.io/operator-framework/scorecard-test:v1.1.0
2632
labels:
2733
suite: olm
2834
test: olm-crds-have-validation-test
35+
storage:
36+
spec:
37+
mountPath: {}
2938
- entrypoint:
3039
- scorecard-test
3140
- olm-crds-have-resources
3241
image: quay.io/operator-framework/scorecard-test:v1.1.0
3342
labels:
3443
suite: olm
3544
test: olm-crds-have-resources-test
45+
storage:
46+
spec:
47+
mountPath: {}
3648
- entrypoint:
3749
- scorecard-test
3850
- olm-spec-descriptors
3951
image: quay.io/operator-framework/scorecard-test:v1.1.0
4052
labels:
4153
suite: olm
4254
test: olm-spec-descriptors-test
55+
storage:
56+
spec:
57+
mountPath: {}
4358
- entrypoint:
4459
- scorecard-test
4560
- olm-status-descriptors
4661
image: quay.io/operator-framework/scorecard-test:v1.1.0
4762
labels:
4863
suite: olm
4964
test: olm-status-descriptors-test
65+
storage:
66+
spec:
67+
mountPath: {}
68+
storage:
69+
spec:
70+
mountPath: {}

bundle.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
55
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
66
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=ibm-namespace-scope-operator
8-
LABEL operators.operatorframework.io.bundle.channels.v1=beta
9-
LABEL operators.operatorframework.io.bundle.channel.default.v1=beta
10-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.10.0+git
8+
LABEL operators.operatorframework.io.bundle.channels.v1=v3
9+
LABEL operators.operatorframework.io.bundle.channel.default.v1=v3
10+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.19.0+git
1111
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1212
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2
1313

bundle/manifests/ibm-namespace-scope-operator.clusterserviceversion.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ metadata:
2323
]
2424
capabilities: Seamless Upgrades
2525
containerImage: icr.io/cpopen/ibm-namespace-scope-operator:latest
26-
createdAt: "2022-06-23T10:44:01Z"
26+
createdAt: "2020-11-2T15:38:33Z"
2727
olm.skipRange: '<1.14.0'
28-
operators.operatorframework.io/builder: operator-sdk-v1.11.0+git
28+
operators.operatorframework.io/builder: operator-sdk-v1.19.0+git
2929
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
3030
repository: https://github.com/IBM/ibm-namespace-scope-operator
3131
support: IBM
@@ -72,7 +72,11 @@ spec:
7272
- bind
7373
serviceAccountName: ibm-namespace-scope-operator
7474
deployments:
75-
- name: ibm-namespace-scope-operator
75+
- label:
76+
app.kubernetes.io/instance: ibm-namespace-scope-operator
77+
app.kubernetes.io/managed-by: ibm-namespace-scope-operator
78+
app.kubernetes.io/name: ibm-namespace-scope-operator
79+
name: ibm-namespace-scope-operator
7680
spec:
7781
replicas: 1
7882
selector:

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: ibm-namespace-scope-operator
77
operators.operatorframework.io.bundle.channels.v1: v3
88
operators.operatorframework.io.bundle.channel.default.v1: v3
9-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.10.0+git
9+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.19.0+git
1010
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1111
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v2
1212

bundle/tests/scorecard/config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,59 @@ stages:
1212
labels:
1313
suite: basic
1414
test: basic-check-spec-test
15+
storage:
16+
spec:
17+
mountPath: {}
1518
- entrypoint:
1619
- scorecard-test
1720
- olm-bundle-validation
1821
image: quay.io/operator-framework/scorecard-test:v1.1.0
1922
labels:
2023
suite: olm
2124
test: olm-bundle-validation-test
25+
storage:
26+
spec:
27+
mountPath: {}
2228
- entrypoint:
2329
- scorecard-test
2430
- olm-crds-have-validation
2531
image: quay.io/operator-framework/scorecard-test:v1.1.0
2632
labels:
2733
suite: olm
2834
test: olm-crds-have-validation-test
35+
storage:
36+
spec:
37+
mountPath: {}
2938
- entrypoint:
3039
- scorecard-test
3140
- olm-crds-have-resources
3241
image: quay.io/operator-framework/scorecard-test:v1.1.0
3342
labels:
3443
suite: olm
3544
test: olm-crds-have-resources-test
45+
storage:
46+
spec:
47+
mountPath: {}
3648
- entrypoint:
3749
- scorecard-test
3850
- olm-spec-descriptors
3951
image: quay.io/operator-framework/scorecard-test:v1.1.0
4052
labels:
4153
suite: olm
4254
test: olm-spec-descriptors-test
55+
storage:
56+
spec:
57+
mountPath: {}
4358
- entrypoint:
4459
- scorecard-test
4560
- olm-status-descriptors
4661
image: quay.io/operator-framework/scorecard-test:v1.1.0
4762
labels:
4863
suite: olm
4964
test: olm-status-descriptors-test
65+
storage:
66+
spec:
67+
mountPath: {}
68+
storage:
69+
spec:
70+
mountPath: {}

common/Makefile.common.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ ifeq (, $(CONTROLLER_GEN))
5858
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
5959
cd $$CONTROLLER_GEN_TMP_DIR ;\
6060
go mod init tmp ;\
61-
GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
61+
GO111MODULE=on go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.5.0 ;\
6262
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
6363
}
64-
CONTROLLER_GEN=$(GOBIN)/controller-gen
64+
CONTROLLER_GEN=$(GOPATH)/controller-gen
6565
endif
6666

6767
# Run go vet for this project. More info: https://golang.org/cmd/vet/

0 commit comments

Comments
 (0)