@@ -105,7 +105,7 @@ test-e2e: generate fmt vet manifests
105105
106106# Build manager binary
107107.PHONY : manager
108- manager : generate fmt vet
108+ manager : manifests generate fmt vet
109109 $(GO ) build -o bin/manager main.go
110110
111111# Run against the configured Kubernetes cluster in ~/.kube/config
@@ -117,14 +117,37 @@ run: generate fmt vet manifests
117117 @-oc process THREESCALE_VERSION=$(THREESCALE_VERSION ) -f config/requirements/operator-requirements.yaml | oc apply -f - -n $(WATCH_NAMESPACE )
118118 $(GO ) run ./main.go --zap-devel
119119
120- # find or download controller-gen
121- # download controller-gen if necessary
122- CONTROLLER_GEN =$(PROJECT_PATH ) /bin/controller-gen
123- $(CONTROLLER_GEN ) :
124- $(call go-bin-install,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)
120+ # #@ Build Dependencies
121+
122+ # # Location to install dependencies to
123+ LOCALBIN ?= $(shell pwd) /bin
124+ $(LOCALBIN ) :
125+ mkdir -p $(LOCALBIN )
126+
127+ # # Tool Binaries
128+ KUSTOMIZE ?= $(LOCALBIN ) /kustomize
129+ CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
130+ ENVTEST ?= $(LOCALBIN ) /setup-envtest
131+
132+ # # Tool Versions
133+ KUSTOMIZE_VERSION ?= v4.5.7
134+ CONTROLLER_TOOLS_VERSION ?= v0.14.0
135+
136+ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
137+ .PHONY : kustomize
138+ kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
139+ $(KUSTOMIZE ) : $(LOCALBIN )
140+ test -s $(LOCALBIN ) /kustomize || { curl -s $( KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $( subst v,,$( KUSTOMIZE_VERSION) ) $( LOCALBIN) ; }
125141
126142.PHONY : controller-gen
127- controller-gen : $(CONTROLLER_GEN )
143+ controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
144+ $(CONTROLLER_GEN ) : $(LOCALBIN )
145+ test -s $(LOCALBIN ) /controller-gen || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
146+
147+ .PHONY : envtest
148+ envtest : $(ENVTEST ) # # Download envtest-setup locally if necessary.
149+ $(ENVTEST ) : $(LOCALBIN )
150+ test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
128151
129152.PHONY : cluster/prepare/local
130153cluster/prepare/local : kustomize cluster/prepare/project install cluster/create/system-redis cluster/create/backend-redis cluster/create/provision-database
@@ -168,17 +191,10 @@ endif
168191cluster/prepare/project :
169192 @ - oc new-project $(NAMESPACE )
170193
171- KUSTOMIZE =$(PROJECT_PATH ) /bin/kustomize
172- $(KUSTOMIZE ) :
173- $(call go-bin-install,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/v4@v4.5.7)
174-
175- .PHONY : kustomize
176- kustomize : $(KUSTOMIZE )
177-
178194OPERATOR_SDK = $(PROJECT_PATH ) /bin/operator-sdk
179195# Note: release file patterns changed after v1.2.0
180196# More info https://sdk.operatorframework.io/docs/installation/
181- OPERATOR_SDK_VERSION =v1.20 .1
197+ OPERATOR_SDK_VERSION =v1.28 .1
182198$(OPERATOR_SDK ) :
183199 curl -sSL https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION ) /operator-sdk_$(OS ) _$(ARCH ) -o $(OPERATOR_SDK )
184200 chmod +x $(OPERATOR_SDK )
@@ -260,6 +276,23 @@ docker-build: test docker-build-only
260276docker-build-only :
261277 $(DOCKER ) build . -t ${IMG}
262278
279+ # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
280+ # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
281+ # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
282+ # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
283+ # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
284+ # To properly provided solutions that supports more than one platform you should use this option.
285+ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
286+ .PHONY : docker-buildx
287+ docker-buildx : test # # Build and push docker image for the manager for cross-platform support
288+ # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
289+ sed -e ' 1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
290+ - docker buildx create --name project-v3-builder
291+ docker buildx use project-v3-builder
292+ - docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} -f Dockerfile.cross
293+ - docker buildx rm project-v3-builder
294+ rm Dockerfile.cross
295+
263296# Push the operator docker image
264297.PHONY : operator-image-push
265298operator-image-push :
@@ -323,15 +356,15 @@ $(YQ):
323356.PHONY : yq
324357yq : $(YQ )
325358
326- .PHONY : opm
327359OPM = ./bin/opm
360+ .PHONY : opm
328361opm :
329362ifeq (,$(wildcard $(OPM ) ) )
330363ifeq (,$(shell which opm 2>/dev/null) )
331364 @{ \
332365 set -e ;\
333366 mkdir -p $(dir $(OPM)) ;\
334- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.19.1 /$(OS)-$(ARCH)-opm ;\
367+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0 /$(OS)-$(ARCH)-opm ;\
335368 chmod +x $(OPM) ;\
336369 }
337370else
0 commit comments