Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 4e8e9dc

Browse files
committed
operator-sdk 1.15.0, kustomize 4.4.1, controller-gen 0.7.0
The newer versions don't fix any specific issue that we are having, but staying closer to upstream is always good. For example, we can rule out that the ancient operator-sdk caused the install problem with OLM 0.19.1.
1 parent 60e252f commit 4e8e9dc

File tree

3 files changed

+38
-54
lines changed

3 files changed

+38
-54
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ include test/start-stop.make
140140
include test/test.make
141141

142142
#Kustomize latest release version
143-
KUSTOMIZE_VERSION=v4.0.5
143+
KUSTOMIZE_VERSION=v4.4.1
144144
_work/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz:
145145
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz -o $(abspath $@)
146146

deploy/crd/pmem-csi.intel.com_pmemcsideployments.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# This file was generated by controller-gen v0.3.0 via 'make operator-generate-crd'
1+
# This file was generated by controller-gen v0.7.0 via 'make operator-generate-crd'
22

33
---
44
apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.3.0
8+
controller-gen.kubebuilder.io/version: v0.7.0
99
creationTimestamp: null
1010
name: pmemcsideployments.pmem-csi.intel.com
1111
spec:

operator/operator.make

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,30 @@
1-
OPERATOR_SDK_VERSION=1.6.1
1+
OPERATOR_SDK_VERSION=1.15.0
2+
CONTROLLER_GEN_VERSION=v0.7.0
3+
CONTROLLER_GEN=_work/bin/controller-gen-$(CONTROLLER_GEN_VERSION)
24

35
# download operator-sdk binary
46
_work/bin/operator-sdk-$(OPERATOR_SDK_VERSION):
5-
mkdir -p _work/bin/ 2> /dev/null
6-
# Building operator-sdk from sources as that needs fixes for:
7-
# https://github.com/operator-framework/operator-sdk/pull/4816
8-
tmpdir=`mktemp -d` && \
9-
trap 'set -x; rm -rf $$tmpdir' EXIT && \
10-
git clone --branch $(OPERATOR_SDK_VERSION)+fixes https://github.com/avalluri/operator-sdk.git $$tmpdir && \
11-
cd $$tmpdir && $(MAKE) build/operator-sdk && \
12-
cp $$tmpdir/build/operator-sdk $(abspath $@) && \
13-
chmod a+x $(abspath $@)
14-
cd $(dir $@); ln -sf operator-sdk-$(OPERATOR_SDK_VERSION) operator-sdk
7+
mkdir -p $(@D)
8+
curl -L https://github.com/operator-framework/operator-sdk/releases/download/v$(OPERATOR_SDK_VERSION)/operator-sdk_linux_amd64 -o $@
9+
chmod a+x $@
10+
ln -sf $(@F) $(@D)/operator-sdk
1511

1612
# Re-generates the K8S source. This target is supposed to run
1713
# upon any changes made to operator api.
18-
#
19-
# GOROOT is needed because of https://github.com/operator-framework/operator-sdk/issues/1854#issuecomment-525132306
20-
operator-generate-k8s: controller-gen
21-
GOROOT=$(shell $(GO) env GOROOT) $(CONTROLLER_GEN) object paths=./pkg/apis/...
14+
operator-generate-k8s: $(CONTROLLER_GEN)
15+
$< object paths=./pkg/apis/...
2216

23-
# find or download if necessary controller-gen
24-
# this make target is copied from Makefile generated
25-
# by operator-sdk init
26-
controller-gen:
27-
ifeq (, $(shell which controller-gen))
28-
@{ \
29-
set -e; \
30-
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
31-
cd $$CONTROLLER_GEN_TMP_DIR ;\
32-
GOPATH=$$($(GO) env GOPATH) ;\
33-
$(GO) mod init tmp ;\
34-
$(GO) get sigs.k8s.io/controller-tools/cmd/[email protected] ;\
35-
rm -rf $$CONTROLLER_GEN_TMP_DIR; \
36-
}
37-
CONTROLLER_GEN=$(GOPATH)/bin/controller-gen
38-
else
39-
CONTROLLER_GEN=$(shell which controller-gen)
40-
endif
17+
# Build controller-gen from source.
18+
$(CONTROLLER_GEN):
19+
mkdir -p $(@D)
20+
GOBIN=$(abspath $(@D)) $(GO) install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
21+
ln -sf controller-gen $@
4122

42-
ifeq ($(REPO_ROOT), )
43-
REPO_ROOT=$(shell pwd)
44-
endif
45-
MANIFESTS_DIR=$(REPO_ROOT)/deploy/kustomize/olm-catalog
46-
CATALOG_DIR=$(REPO_ROOT)/deploy/olm-catalog
47-
BUNDLE_DIR=$(REPO_ROOT)/deploy/olm-bundle/$(MAJOR_MINOR_PATCH_VERSION)
48-
CRD_DIR=$(REPO_ROOT)/deploy/crd
23+
24+
MANIFESTS_DIR=deploy/kustomize/olm-catalog
25+
CATALOG_DIR=deploy/olm-catalog
26+
BUNDLE_DIR=deploy/olm-bundle/$(MAJOR_MINOR_PATCH_VERSION)
27+
CRD_DIR=deploy/crd
4928
# CHANNELS: A comma-separated list of channels the generated
5029
# bundle belongs to. This supposed to be all the channel names we support.
5130
# Currently, alpha(all < v1.0) and stable(=v1.0)
@@ -65,11 +44,10 @@ PATCH_REPLACES := sed -i -e 's;\(.*\)\(version:.*\);\1replaces: pmem-csi-operato
6544
PATCH_DATE := sed -i -e 's;\(.*createdAt: \).*;\1$(shell date +%FT%TZ);g'
6645

6746
# Generate CRD
68-
operator-generate-crd: controller-gen
47+
operator-generate-crd: $(CONTROLLER_GEN)
6948
@echo "Generating CRD in $(CRD_DIR) ..."
70-
cd $(REPO_ROOT) && $(CONTROLLER_GEN) crd:trivialVersions=true,crdVersions=v1 paths=./pkg/apis/... output:dir=$(CRD_DIR)/
71-
version="$(shell $(CONTROLLER_GEN) --version |cut -f2 -d':')"; \
72-
sed -i "1s/^/# This file was generated by controller-gen$$version via 'make operator-generate-crd'\n/" $(CRD_DIR)/*
49+
$(CONTROLLER_GEN) crd paths=./pkg/apis/... output:dir=$(CRD_DIR)
50+
sed -i "1s/^/# This file was generated by controller-gen $(CONTROLLER_GEN_VERSION) via 'make operator-generate-crd'\n/" $(CRD_DIR)/*
7351

7452
# Generate bundle manifests for OLM
7553
# The bundle.Dockerfile file is generated in the $root folder,
@@ -81,21 +59,27 @@ operator-generate-crd: controller-gen
8159
# test configurations.
8260
operator-generate-bundle: _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION) _work/kustomize operator-generate-crd
8361
@echo "Generating operator bundle in $(BUNDLE_DIR) ..."
84-
@_work/kustomize build --load-restrictor LoadRestrictionsNone $(MANIFESTS_DIR) | $< generate bundle --version=$(MAJOR_MINOR_PATCH_VERSION) \
85-
--kustomize-dir=$(MANIFESTS_DIR) --output-dir=$(BUNDLE_DIR) --channels ${CHANNELS} --default-channel ${DEFAULT_CHANNEL}
62+
rm -rf $(BUNDLE_DIR)
63+
mkdir -p $(BUNDLE_DIR)
64+
# Generate input YAML first. This might fail...
65+
_work/kustomize build --load-restrictor LoadRestrictionsNone $(MANIFESTS_DIR) >$(BUNDLE_DIR)/manifests.yaml
66+
# Specifying --kustomize-dir seems redundant because stdin already contains our ClusterServiceVersion,
67+
# but without it the final ClusterServiceVersion in the bundle just has some automatically generated fields.
68+
cat $(BUNDLE_DIR)/manifests.yaml | $< generate bundle --kustomize-dir=$(MANIFESTS_DIR) --version=$(MAJOR_MINOR_PATCH_VERSION) --output-dir=$(BUNDLE_DIR) --channels ${CHANNELS} --default-channel ${DEFAULT_CHANNEL}
69+
rm $(BUNDLE_DIR)/manifests.yaml
8670
$(PATCH_VERSIONS) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
8771
ifdef REPLACES
88-
@$(PATCH_REPLACES) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
72+
$(PATCH_REPLACES) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
8973
endif
9074
$(PATCH_DATE) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
91-
@sed -i -e "s;$(BUNDLE_DIR)/;;g" -e "/scorecard/d" -e '/FROM scratch/a LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSIONS)"' bundle.Dockerfile
92-
@sed -i -e "/scorecard/d" $(BUNDLE_DIR)/metadata/annotations.yaml
93-
@mv bundle.Dockerfile $(BUNDLE_DIR)
75+
sed -i -e "s;$(BUNDLE_DIR)/;;g" -e "/scorecard/d" -e '/FROM scratch/a LABEL com.redhat.openshift.versions="$(OPENSHIFT_VERSIONS)"' bundle.Dockerfile
76+
sed -i -e "/scorecard/d" $(BUNDLE_DIR)/metadata/annotations.yaml
77+
mv bundle.Dockerfile $(BUNDLE_DIR)
9478
@make operator-validate-bundle
9579

9680
operator-validate-bundle: _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION) $(BUNDLE_DIR)
9781
@if ! OUT="$$($< bundle validate --select-optional name=operatorhub $(BUNDLE_DIR))"; then \
98-
echo >&2 "ERROR: Operator bundle did not pass validation:"; \
82+
echo >&2 "ERROR: Operator bundle in $(BUNDLE_DIR) did not pass validation:"; \
9983
echo >&2 "$$OUT"; \
10084
exit 1; \
10185
fi

0 commit comments

Comments
 (0)