From dfb1790bd512125e414cf66746302b6ed3d93eb1 Mon Sep 17 00:00:00 2001 From: Vinayakswami Hariharmath Date: Tue, 4 Jul 2023 17:00:46 +0530 Subject: [PATCH] Remove operator-sdk dependency list of changes: 1. Replaced operator-sdk command to generate crds with controller-gen cmd to align with go1.20 Signed-off-by: Vinayakswami Hariharmath --- Makefile | 27 ++++++++++++++++++++++++--- go.mod | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f79ad9200e..6cdfc15a10 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,13 @@ DEV_IMAGE ?= noobaa/noobaa-operator-dev:$(VERSION) REPO ?= github.com/noobaa/noobaa-operator CATALOG_IMAGE ?= noobaa/noobaa-operator-catalog:$(VERSION) BUNDLE_IMAGE ?= noobaa/noobaa-operator-bundle:$(VERSION) +# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) +ifeq (,$(shell go env GOBIN)) +GOBIN=$(shell go env GOPATH)/bin +else +GOBIN=$(shell go env GOBIN) +endif +CONTROLLER_GEN_VERSION=v0.9.2 GO_LINUX ?= GOOS=linux GOARCH=amd64 GOHOSTOS ?= $(shell go env GOHOSTOS) @@ -113,9 +120,9 @@ pkg/bundle/deploy.go: pkg/bundler/bundler.go version/version.go $(shell find dep mkdir -p pkg/bundle go run pkg/bundler/bundler.go deploy/ pkg/bundle/deploy.go -gen-api: $(OPERATOR_SDK) gen - $(TIME) $(OPERATOR_SDK) generate k8s - $(TIME) $(OPERATOR_SDK) generate crds --crd-version v1 +gen-api: controller-gen gen + $(TIME) $(CONTROLLER_GEN) crd:generateEmbeddedObjectMeta=true paths=./pkg/apis/... output:crd:artifacts:config=deploy/crds/ + @echo "✅ gen-api" .PHONY: gen-api @@ -265,3 +272,17 @@ test-validations: ginkgo -v pkg/validations @echo "✅ test-validations" .PHONY: test-validations + +# find or download controller-gen if necessary +controller-gen: +ifneq ($(CONTROLLER_GEN_VERSION), $(shell controller-gen --version | awk -F ":" '{print $2}')) + @{ \ + echo "Installing controller-gen@$(CONTROLLER_GEN_VERSION)" ;\ + set -e ;\ + go install -mod=readonly sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION) ;\ + echo "Installed controller-gen@$(CONTROLLER_GEN_VERSION)" ;\ + } +CONTROLLER_GEN=$(GOBIN)/controller-gen +else +CONTROLLER_GEN=$(shell which controller-gen) +endif diff --git a/go.mod b/go.mod index d914b84e3b..b84aacf663 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/noobaa/noobaa-operator/v5 -go 1.19 +go 1.20 require ( cloud.google.com/go/storage v1.30.1