Skip to content

Commit

Permalink
Remove operator-sdk dependency
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vh05 committed Jul 11, 2023
1 parent ee67c52 commit dfb1790
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit dfb1790

Please sign in to comment.