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 )
2
4
3
5
# download operator-sdk binary
4
6
_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
15
11
16
12
# Re-generates the K8S source. This target is supposed to run
17
13
# 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/...
22
16
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 $@
41
22
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
49
28
# CHANNELS: A comma-separated list of channels the generated
50
29
# bundle belongs to. This supposed to be all the channel names we support.
51
30
# Currently, alpha(all < v1.0) and stable(=v1.0)
@@ -65,11 +44,10 @@ PATCH_REPLACES := sed -i -e 's;\(.*\)\(version:.*\);\1replaces: pmem-csi-operato
65
44
PATCH_DATE := sed -i -e 's;\(.*createdAt: \).*;\1$(shell date +% FT% TZ) ;g'
66
45
67
46
# Generate CRD
68
- operator-generate-crd : controller-gen
47
+ operator-generate-crd : $( CONTROLLER_GEN )
69
48
@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 ) /*
73
51
74
52
# Generate bundle manifests for OLM
75
53
# The bundle.Dockerfile file is generated in the $root folder,
@@ -81,21 +59,27 @@ operator-generate-crd: controller-gen
81
59
# test configurations.
82
60
operator-generate-bundle : _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION ) _work/kustomize operator-generate-crd
83
61
@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
86
70
$(PATCH_VERSIONS ) $(BUNDLE_DIR ) /manifests/pmem-csi-operator.clusterserviceversion.yaml
87
71
ifdef REPLACES
88
- @ $(PATCH_REPLACES) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
72
+ $(PATCH_REPLACES) $(BUNDLE_DIR)/manifests/pmem-csi-operator.clusterserviceversion.yaml
89
73
endif
90
74
$(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)
94
78
@make operator-validate-bundle
95
79
96
80
operator-validate-bundle : _work/bin/operator-sdk-$(OPERATOR_SDK_VERSION ) $(BUNDLE_DIR )
97
81
@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:" ; \
99
83
echo >&2 " $$ OUT" ; \
100
84
exit 1; \
101
85
fi
0 commit comments