Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump controller-tools to v0.9.0 #3885

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@ check: get-pgmonitor
# - KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true
.PHONY: check-envtest
check-envtest: ## Run check using envtest and a mock kube api
check-envtest: ENVTEST_USE = hack/tools/setup-envtest --bin-dir=$(CURDIR)/hack/tools/envtest use $(ENVTEST_K8S_VERSION)
check-envtest: ENVTEST_USE = $(ENVTEST) --bin-dir=$(CURDIR)/hack/tools/envtest use $(ENVTEST_K8S_VERSION)
check-envtest: SHELL = bash
check-envtest: get-pgmonitor
GOBIN='$(CURDIR)/hack/tools' $(GO) install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
check-envtest: get-pgmonitor tools/setup-envtest
@$(ENVTEST_USE) --print=overview && echo
source <($(ENVTEST_USE) --print=env) && PGO_NAMESPACE="postgres-operator" QUERIES_CONFIG_DIR="$(CURDIR)/${QUERIES_CONFIG_DIR}" \
$(GO_TEST) -count=1 -cover ./...
Expand Down Expand Up @@ -269,23 +268,24 @@ generate: generate-deepcopy
generate: generate-rbac

.PHONY: generate-crd
generate-crd: ## Generate crd
GOBIN='$(CURDIR)/hack/tools' ./hack/controller-generator.sh \
generate-crd: ## Generate Custom Resource Definitions (CRDs)
generate-crd: tools/controller-gen
$(CONTROLLER) \
crd:crdVersions='v1' \
paths='./pkg/apis/...' \
output:dir='build/crd/postgresclusters/generated' # build/crd/{plural}/generated/{group}_{plural}.yaml
@
GOBIN='$(CURDIR)/hack/tools' ./hack/controller-generator.sh \
$(CONTROLLER) \
crd:crdVersions='v1' \
paths='./pkg/apis/...' \
output:dir='build/crd/pgupgrades/generated' # build/crd/{plural}/generated/{group}_{plural}.yaml
@
GOBIN='$(CURDIR)/hack/tools' ./hack/controller-generator.sh \
$(CONTROLLER) \
crd:crdVersions='v1' \
paths='./pkg/apis/...' \
output:dir='build/crd/pgadmins/generated' # build/crd/{plural}/generated/{group}_{plural}.yaml
@
GOBIN='$(CURDIR)/hack/tools' ./hack/controller-generator.sh \
$(CONTROLLER) \
crd:crdVersions='v1' \
paths='./pkg/apis/...' \
output:dir='build/crd/crunchybridgeclusters/generated' # build/crd/{plural}/generated/{group}_{plural}.yaml
Expand All @@ -296,15 +296,40 @@ generate-crd: ## Generate crd
kubectl kustomize ./build/crd/crunchybridgeclusters > ./config/crd/bases/postgres-operator.crunchydata.com_crunchybridgeclusters.yaml

.PHONY: generate-deepcopy
generate-deepcopy: ## Generate deepcopy functions
GOBIN='$(CURDIR)/hack/tools' ./hack/controller-generator.sh \
generate-deepcopy: ## Generate DeepCopy functions
generate-deepcopy: tools/controller-gen
$(CONTROLLER) \
object:headerFile='hack/boilerplate.go.txt' \
paths='./pkg/apis/postgres-operator.crunchydata.com/...'

.PHONY: generate-rbac
generate-rbac: ## Generate rbac
GOBIN='$(CURDIR)/hack/tools' ./hack/generate-rbac.sh \
'./internal/...' 'config/rbac'
generate-rbac: ## Generate RBAC
generate-rbac: tools/controller-gen
$(CONTROLLER) \
rbac:roleName='generated' \
paths='./internal/...' \
output:dir='config/rbac' # ${directory}/role.yaml
./hack/generate-rbac.sh 'config/rbac'

##@ Tools

.PHONY: tools
tools: ## Download tools like controller-gen and kustomize if necessary.

# go-get-tool will 'go install' any package $2 and install it to $1.
define go-get-tool
@[ -f '$(1)' ] || { echo Downloading '$(2)'; GOBIN='$(abspath $(dir $(1)))' $(GO) install '$(2)'; }
endef

CONTROLLER ?= hack/tools/controller-gen
tools: tools/controller-gen
tools/controller-gen:
$(call go-get-tool,$(CONTROLLER),sigs.k8s.io/controller-tools/cmd/[email protected])

ENVTEST ?= hack/tools/setup-envtest
tools: tools/setup-envtest
tools/setup-envtest:
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

##@ Release

Expand Down
11 changes: 0 additions & 11 deletions build/crd/crunchybridgeclusters/immutable.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions build/crd/crunchybridgeclusters/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ resources:
- generated/postgres-operator.crunchydata.com_crunchybridgeclusters.yaml

patches:
# Remove the zero status field included by [email protected]. These zero
# values conflict with the CRD controller in Kubernetes before v1.22.
# - https://github.com/kubernetes-sigs/controller-tools/pull/630
# - https://pr.k8s.io/100970
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: crunchybridgeclusters.postgres-operator.crunchydata.com
patch: |-
- op: remove
path: /status
- target:
group: apiextensions.k8s.io
version: v1
Expand All @@ -29,9 +17,3 @@ patches:
value:
app.kubernetes.io/name: pgo
app.kubernetes.io/version: latest
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: crunchybridgeclusters.postgres-operator.crunchydata.com
path: immutable.yaml
12 changes: 0 additions & 12 deletions build/crd/pgadmins/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ resources:
- generated/postgres-operator.crunchydata.com_pgadmins.yaml

patches:
# Remove the zero status field included by [email protected]. These zero
# values conflict with the CRD controller in Kubernetes before v1.22.
# - https://github.com/kubernetes-sigs/controller-tools/pull/630
# - https://pr.k8s.io/100970
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: pgadmins.postgres-operator.crunchydata.com
patch: |-
- op: remove
path: /status
- target:
group: apiextensions.k8s.io
version: v1
Expand Down
12 changes: 0 additions & 12 deletions build/crd/pgupgrades/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ resources:
- generated/postgres-operator.crunchydata.com_pgupgrades.yaml

patches:
# Remove the zero status field included by [email protected]. These zero
# values conflict with the CRD controller in Kubernetes before v1.22.
# - https://github.com/kubernetes-sigs/controller-tools/pull/630
# - https://pr.k8s.io/100970
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: pgupgrades.postgres-operator.crunchydata.com
patch: |-
- op: remove
path: /status
- target:
group: apiextensions.k8s.io
version: v1
Expand Down
6 changes: 0 additions & 6 deletions build/crd/postgresclusters/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ patchesJson6902:
kind: CustomResourceDefinition
name: postgresclusters.postgres-operator.crunchydata.com
path: condition.yaml
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: postgresclusters.postgres-operator.crunchydata.com
path: status.yaml
- target:
group: apiextensions.k8s.io
version: v1
Expand Down
6 changes: 0 additions & 6 deletions build/crd/postgresclusters/status.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
labels:
app.kubernetes.io/name: pgo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
labels:
app.kubernetes.io/name: pgo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
labels:
app.kubernetes.io/name: pgo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
labels:
app.kubernetes.io/name: pgo
Expand Down
27 changes: 0 additions & 27 deletions hack/controller-generator.sh

This file was deleted.

10 changes: 1 addition & 9 deletions hack/generate-rbac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@

set -eu

declare -r paths="$1" directory="$2"

# Use `controller-gen` to parse Go markers.
( set -x
"${BASH_SOURCE[0]%/*}/controller-generator.sh" \
rbac:roleName='generated' \
paths="${paths}" \
output:dir="${directory}" # ${directory}/role.yaml
)
declare -r directory="$1"

# NOTE(cbandy): `kustomize` v4.1 and `kubectl` v1.22 will be able to change the
# kind of a resource: https://pr.k8s.io/101120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ type CrunchyBridgeClusterSpec struct {
// Currently Bridge offers aws, azure, and gcp only
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum={aws,azure,gcp}
// +kubebuilder:validation:XValidation:rule=`self == oldSelf`,message="immutable"
Provider string `json:"provider"`

// The provider region where the cluster is located.
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule=`self == oldSelf`,message="immutable"
Region string `json:"region"`

// Roles for which to create Secrets that contain their credentials which
Expand Down