Skip to content

Commit

Permalink
chore: update operator-sdk version to 1.32 (#742)
Browse files Browse the repository at this point in the history
* update operator-sdk version to 1.32

Signed-off-by: Anand Kumar Singh <[email protected]>

* fix: usign controller-gen 1.14.0

Signed-off-by: Anand Kumar Singh <[email protected]>

* fix: test, CRD filepath

Signed-off-by: Anand Kumar Singh <[email protected]>

---------

Signed-off-by: Anand Kumar Singh <[email protected]>
  • Loading branch information
anandrkskd authored Jul 15, 2024
1 parent 6cf2a8e commit ef35961
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 10 deletions.
46 changes: 43 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,23 @@ IMAGE_TAG_BASE ?= $(IMAGE)
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(VERSION)

# BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)

# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE):$(VERSION)

# Set the Operator SDK version to use.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
OPERATOR_SDK_VERSION ?= v1.22.2
OPERATOR_SDK_VERSION ?= v1.32.0


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand All @@ -61,6 +72,7 @@ endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: build

##@ General
Expand All @@ -76,42 +88,57 @@ all: build
# More info on the awk command:
# http://linuxcommand.org/lc3_adv_awk.php

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role webhook crd paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: test-all
test-all: manifests generate fmt vet ## Run all tests.
go test -timeout 1h ./... -coverprofile cover.out

.PHONY: test-e2e
test-e2e: manifests generate fmt vet ## Run e2e tests.
go test -p 1 -timeout 1h ./test/e2e -coverprofile cover.out -ginkgo.v
go test -p 1 -timeout 1h ./test/nondefaulte2e -coverprofile cover.out -ginkgo.v

.PHONY: test-metrics
test-metrics:
go test -timeout 30m ./test/e2e -ginkgo.focus="Argo CD metrics controller" -coverprofile cover.out -ginkgo.v


.PHONY: test-route
test-route:
go test -timeout 30m ./test/e2e -ginkgo.focus="Argo CD ConsoleLink controller" -coverprofile cover.out -ginkgo.v


.PHONY: test-gitopsservice
test-gitopsservice:
go test -p 1 -timeout 1h ./test/e2e -ginkgo.focus="GitOpsServiceController" -coverprofile cover.out -ginkgo.v


.PHONY: test-gitopsservice-nondefault
test-gitopsservice-nondefault:
go test -p 1 -timeout 30m ./test/nondefaulte2e -ginkgo.focus="GitOpsServiceNoDefaultInstall" -coverprofile cover.out -ginkgo.v

.PHONY: test
test: manifests generate fmt vet ## Run unit tests.
go test `go list ./... | grep -v test` -coverprofile cover.out

Expand Down Expand Up @@ -142,15 +169,19 @@ e2e-non-olm-tests-all:

##@ Build

.PHONY: build
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
REDIS_CONFIG_PATH="build/redis" go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
docker push ${IMG}

Expand Down Expand Up @@ -178,31 +209,40 @@ OPERATOR_SDK = $(shell which operator-sdk)
endif
endif

ifndef ignore-not-found
ignore-not-found = false
endif

##@ Deployment

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
## TODO: Remove sed usage after all v1alpha1 references are updated to v1beta1 in codebase.
## For local testing, conversion webhook defined in crd makes call to webhook for each v1alpha1 reference
## causing failures as we don't set up the webhook for local testing.
$(KUSTOMIZE) build config/crd | sed '/conversion:/,/- v1beta1/d' |kubectl apply --server-side=true -f -

.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=true -f -

.PHONY: deploy
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply --server-side=true -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=true -f -


CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])

KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected])

Expand All @@ -226,7 +266,7 @@ endef
bundle: operator-sdk manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-build
Expand All @@ -246,7 +286,7 @@ ifeq (,$(shell which opm 2>/dev/null))
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
Expand Down
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=gitops-operator
LABEL operators.operatorframework.io.bundle.channels.v1=latest,gitops-1.8
LABEL operators.operatorframework.io.bundle.channel.default.v1=latest
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.22.2
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.32.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
14 changes: 12 additions & 2 deletions bundle/manifests/gitops-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ metadata:
capabilities: Deep Insights
console.openshift.io/plugins: '["gitops-plugin"]'
containerImage: quay.io/redhat-developer/gitops-operator
createdAt: "2024-07-15T07:28:44Z"
description: Enables teams to adopt GitOps principles for managing cluster configurations
and application delivery across hybrid multi-cluster Kubernetes environments.
features.operators.openshift.io/disconnected: "true"
Expand All @@ -176,7 +177,7 @@ metadata:
operatorframework.io/cluster-monitoring: "true"
operatorframework.io/suggested-namespace: openshift-gitops-operator
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.operatorframework.io/builder: operator-sdk-v1.22.2
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/redhat-developer/gitops-operator
support: Red Hat
Expand Down Expand Up @@ -971,6 +972,8 @@ spec:
strategy: {}
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: manager
labels:
control-plane: gitops-operator
spec:
Expand Down Expand Up @@ -1007,7 +1010,13 @@ spec:
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources: {}
resources:
limits:
cpu: 500m
memory: 768Mi
requests:
cpu: 10m
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand All @@ -1028,6 +1037,7 @@ spec:
ports:
- containerPort: 8443
name: metrics
protocol: TCP
resources:
limits:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
ports:
- name: metrics
port: 8443
protocol: TCP
targetPort: metrics
selector:
control-plane: gitops-operator
Expand Down
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
operators.operatorframework.io.bundle.package.v1: gitops-operator
operators.operatorframework.io.bundle.channels.v1: latest,gitops-1.8
operators.operatorframework.io.bundle.channel.default.v1: latest
operators.operatorframework.io.metrics.builder: operator-sdk-v1.22.2
operators.operatorframework.io.metrics.builder: operator-sdk-v1.32.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
1 change: 1 addition & 0 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
- --http2-disable
ports:
- containerPort: 8443
protocol: TCP
name: metrics
resources:
limits:
Expand Down
10 changes: 9 additions & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
replicas: 1
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: manager
labels:
control-plane: gitops-operator
spec:
Expand Down Expand Up @@ -48,7 +50,13 @@ spec:
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources: {}
resources:
limits:
cpu: 500m
memory: 768Mi
requests:
cpu: 10m
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
1 change: 1 addition & 0 deletions config/rbac/auth_proxy_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
ports:
- name: metrics
port: 8443
protocol: TCP
targetPort: metrics
selector:
control-plane: gitops-operator
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var _ = BeforeSuite(func() {
useActualCluster := true
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("../..", "config", "crd", "bases"),
filepath.Join("..", "..", "config", "crd", "bases"),
},
UseExistingCluster: &useActualCluster, // use an actual OpenShift cluster specified in kubeconfig
ErrorIfCRDPathMissing: true,
Expand Down
2 changes: 1 addition & 1 deletion test/nondefaulte2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = BeforeSuite(func() {
useActualCluster := true
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{
filepath.Join("../..", "config", "crd", "bases"),
filepath.Join("..", "..", "config", "crd", "bases"),
},
UseExistingCluster: &useActualCluster, // use an actual OpenShift cluster specified in kubeconfig
ErrorIfCRDPathMissing: true,
Expand Down

0 comments on commit ef35961

Please sign in to comment.