diff --git a/.github/workflows/lint-sample.yml b/.github/workflows/lint-sample.yml index 5811f597d72..1a4a3753cdb 100644 --- a/.github/workflows/lint-sample.yml +++ b/.github/workflows/lint-sample.yml @@ -29,5 +29,5 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: v1.59 - working-directory: testdata/project-v4-with-deploy-image + working-directory: testdata/project-v4-with-plugins args: --config .golangci.yml ./... diff --git a/.github/workflows/test-e2e-samples.yml b/.github/workflows/test-e2e-samples.yml index 3184cb3c48f..8137407e814 100644 --- a/.github/workflows/test-e2e-samples.yml +++ b/.github/workflows/test-e2e-samples.yml @@ -54,9 +54,9 @@ jobs: - name: Create kind cluster run: kind create cluster - - name: Prepare project-v4-with-deploy-image + - name: Prepare project-v4-with-plugins run: | - KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/kustomization.yaml" + KUSTOMIZATION_FILE_PATH="testdata/project-v4-with-plugins/config/default/kustomization.yaml" sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH sed -i '51s/^#//' $KUSTOMIZATION_FILE_PATH # Uncomment only ValidatingWebhookConfiguration @@ -68,12 +68,12 @@ jobs: # Comment the injection for MutatingWebhookConfiguration # Fixme: We should not scaffold or it should be commented # by default when only validation webhooks are scaffolded - WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml" + WEBHOOK_INJECTION_FILE_PATH="testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml" sed -i '3,11s/^/#/' $WEBHOOK_INJECTION_FILE_PATH - cd testdata/project-v4-with-deploy-image/ + cd testdata/project-v4-with-plugins/ go mod tidy - - name: Testing make test-e2e for project-v4-with-deploy-image - working-directory: testdata/project-v4-with-deploy-image + - name: Testing make test-e2e for project-v4-with-plugins + working-directory: testdata/project-v4-with-plugins run: | make test-e2e diff --git a/docs/book/src/plugins/deploy-image-plugin-v1-alpha.md b/docs/book/src/plugins/deploy-image-plugin-v1-alpha.md index 995b0ed775f..df69edf5cfa 100644 --- a/docs/book/src/plugins/deploy-image-plugin-v1-alpha.md +++ b/docs/book/src/plugins/deploy-image-plugin-v1-alpha.md @@ -13,7 +13,7 @@ By using this plugin you will have: diff --git a/docs/book/src/reference/envtest.md b/docs/book/src/reference/envtest.md index 7c134f1c30a..d0cc529fee3 100644 --- a/docs/book/src/reference/envtest.md +++ b/docs/book/src/reference/envtest.md @@ -83,7 +83,7 @@ Logs from the test runs are prefixed with `test-env`. You can use the plugin [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) to check examples. This plugin allows users to scaffold API/Controllers to deploy and manage an Operand (image) on the cluster following the guidelines and best practices. It abstracts the complexities of achieving this goal while allowing users to customize the generated code. -Therefore, you can check that a test using ENV TEST will be generated for the controller which has the purpose to ensure that the Deployment is created successfully. You can see an example of its code implementation under the `testdata` directory with the [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) samples [here](https://github.com/kubernetes-sigs/kubebuilder/blob/v3.7.0/testdata/project-v4-with-deploy-image/controllers/busybox_controller_test.go). +Therefore, you can check that a test using ENV TEST will be generated for the controller which has the purpose to ensure that the Deployment is created successfully. You can see an example of its code implementation under the `testdata` directory with the [DeployImage](https://book.kubebuilder.io/plugins/deploy-image-plugin-v1-alpha.html) samples [here](https://github.com/kubernetes-sigs/kubebuilder/blob/v3.7.0/testdata/project-v4-with-plugins/controllers/busybox_controller_test.go). diff --git a/docs/book/src/reference/rescaffold.md b/docs/book/src/reference/rescaffold.md index 160a4e041bd..23844c001f8 100644 --- a/docs/book/src/reference/rescaffold.md +++ b/docs/book/src/reference/rescaffold.md @@ -49,5 +49,5 @@ This way, you can easily overlay your project's code changes atop the new scaffo - Check out [video to show how it works](https://youtu.be/7997RIbx8kw?si=ODYMud5lLycz7osp) - See the [desing proposal documentation](../../../../designs/helper_to_upgrade_projects_by_rescaffolding.md) -[example]: ./../../../../testdata/project-v4-with-deploy-image/PROJECT +[example]: ./../../../../testdata/project-v4-with-plugins/PROJECT [more-info]: ./../reference/project-config.md \ No newline at end of file diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh index e13f6c37364..0cab53da2de 100755 --- a/test/testdata/generate.sh +++ b/test/testdata/generate.sh @@ -32,28 +32,22 @@ function scaffold_test_project { pushd $testdata_dir/$project header_text "Generating project ${project} with flags: ${init_flags}" - go mod init sigs.k8s.io/kubebuilder/testdata/$project # our repo autodetection will traverse up to the kb module if we don't do this - header_text "Initializing project ..." $kb init $init_flags --domain testproject.org --license apache2 --owner "The Kubernetes authors" - if [ $project == "project-v4" ] || [ $project == "project-v4-config" ]; then + if [ $project == "project-v4" ] ; then header_text 'Creating APIs ...' $kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false $kb create api --group crew --version v1 --kind Captain --controller=true --resource=true --make=false --force $kb create webhook --group crew --version v1 --kind Captain --defaulting --programmatic-validation $kb create api --group crew --version v1 --kind FirstMate --controller=true --resource=true --make=false $kb create webhook --group crew --version v1 --kind FirstMate --conversion + $kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false + $kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting + fi - if [ $project == "project-v4" ]; then - $kb create api --group crew --version v1 --kind Admiral --plural=admirales --controller=true --resource=true --namespaced=false --make=false - $kb create webhook --group crew --version v1 --kind Admiral --plural=admirales --defaulting - else - $kb create api --group crew --version v1 --kind Admiral --controller=true --resource=true --namespaced=false --make=false - $kb create webhook --group crew --version v1 --kind Admiral --defaulting - fi - elif [[ $project =~ multigroup ]]; then + if [[ $project =~ multigroup ]]; then header_text 'Switching to multigroup layout ...' $kb edit --multigroup=true @@ -63,46 +57,33 @@ function scaffold_test_project { $kb create api --group ship --version v1beta1 --kind Frigate --controller=true --resource=true --make=false $kb create webhook --group ship --version v1beta1 --kind Frigate --conversion - $kb create api --group ship --version v1 --kind Destroyer --controller=true --resource=true --namespaced=false --make=false $kb create webhook --group ship --version v1 --kind Destroyer --defaulting - $kb create api --group ship --version v2alpha1 --kind Cruiser --controller=true --resource=true --namespaced=false --make=false $kb create webhook --group ship --version v2alpha1 --kind Cruiser --programmatic-validation $kb create api --group sea-creatures --version v1beta1 --kind Kraken --controller=true --resource=true --make=false - $kb create api --group sea-creatures --version v1beta2 --kind Leviathan --controller=true --resource=true --make=false - $kb create api --group foo.policy --version v1 --kind HealthCheckPolicy --controller=true --resource=true --make=false - $kb create api --group apps --version v1 --kind Deployment --controller=true --resource=false --make=false - $kb create api --group foo --version v1 --kind Bar --controller=true --resource=true --make=false $kb create api --group fiz --version v1 --kind Bar --controller=true --resource=true --make=false - if [ $project == "project-v4-multigroup" ] || [ $project == "project-v4-multigroup-with-deploy-image" ] ; then - $kb create api --version v1 --kind Lakers --controller=true --resource=true --make=false - $kb create webhook --version v1 --kind Lakers --defaulting --programmatic-validation - fi - elif [[ $project =~ deploy-image ]]; then - header_text 'Creating Memcached API with deploy-image plugin ...' - $kb create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:memcached:1.6.26-alpine3.19 --image-container-command="memcached,-m=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false - $kb create api --group example.com --version v1alpha1 --kind Busybox --image=busybox:1.36.1 --plugins="deploy-image/v1-alpha" --make=false - header_text 'Creating Memcached webhook ...' - $kb create webhook --group example.com --version v1alpha1 --kind Memcached --programmatic-validation + $kb create api --version v1 --kind Lakers --controller=true --resource=true --make=false + $kb create webhook --version v1 --kind Lakers --defaulting --programmatic-validation fi - if [[ $project == project-v4-with-grafana ]]; then - header_text 'Editing project with Grafana plugin ...' - $kb edit --plugins=grafana.kubebuilder.io/v1-alpha - fi - - make generate manifests - if [[ $project =~ v4 ]]; then - make build-installer + if [[ $project =~ multigroup ]] || [[ $project =~ with-plugins ]] ; then + header_text 'With Optional Plugins ...' + header_text 'Creating APIs with deploy-image plugin ...' + $kb create api --group example.com --version v1alpha1 --kind Memcached --image=memcached:memcached:1.6.26-alpine3.19 --image-container-command="memcached,-m=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false + $kb create api --group example.com --version v1alpha1 --kind Busybox --image=busybox:1.36.1 --plugins="deploy-image/v1-alpha" --make=false + $kb create webhook --group example.com --version v1alpha1 --kind Memcached --programmatic-validation + header_text 'Editing project with Grafana plugin ...' + $kb edit --plugins=grafana.kubebuilder.io/v1-alpha fi + make build-installer rm -f go.sum go mod tidy popd @@ -111,7 +92,5 @@ function scaffold_test_project { build_kb scaffold_test_project project-v4 --plugins="go/v4" -scaffold_test_project project-v4-multigroup --plugins="go/v4" -scaffold_test_project project-v4-multigroup-with-deploy-image --plugins="go/v4" -scaffold_test_project project-v4-with-deploy-image --plugins="go/v4" -scaffold_test_project project-v4-with-grafana --plugins="go/v4" +scaffold_test_project project-v4-multigroup-with-plugins --plugins="go/v4" +scaffold_test_project project-v4-with-plugins --plugins="go/v4" diff --git a/test/testdata/test.sh b/test/testdata/test.sh index abf7ffb5f04..ba1b4c1bb2b 100755 --- a/test/testdata/test.sh +++ b/test/testdata/test.sh @@ -32,7 +32,5 @@ build_kb # Project version v4-alpha test_project project-v4 -test_project project-v4-multigroup -test_project project-v4-multigroup-with-deploy-image -test_project project-v4-with-deploy-image -test_project project-v4-with-grafana +test_project project-v4-multigroup-with-plugins +test_project project-v4-with-plugins diff --git a/testdata/project-v4-multigroup-with-deploy-image/Makefile b/testdata/project-v4-multigroup-with-deploy-image/Makefile deleted file mode 100644 index 2739b43f8a1..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/Makefile +++ /dev/null @@ -1,212 +0,0 @@ -# Image URL to use all building/pushing image targets -IMG ?= controller:latest -# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.31.0 - -# 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 - -# CONTAINER_TOOL defines the container tool to be used for building images. -# Be aware that the target commands are only tested with Docker which is -# scaffolded by default. However, you might want to replace it to use other -# tools. (i.e. podman) -CONTAINER_TOOL ?= docker - -# Setting SHELL to bash allows bash commands to be executed by recipes. -# Options are set to exit when a recipe line exits non-zero or a piped command fails. -SHELL = /usr/bin/env bash -o pipefail -.SHELLFLAGS = -ec - -.PHONY: all -all: build - -##@ General - -# The help target prints out all targets with their descriptions organized -# beneath their categories. The categories are represented by '##@' and the -# target descriptions by '##'. The awk command is responsible for reading the -# entire set of makefiles included in this invocation, looking for lines of the -# file as xyz: ## something, and then pretty-format the target and help. Then, -# if there's a line with ##@ something, that gets pretty-printed as a category. -# More info on the usage of ANSI control characters for terminal formatting: -# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters -# 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\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 crd webhook 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 -test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out - -# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'. -# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally. -# Prometheus and CertManager are installed by default; skip with: -# - PROMETHEUS_INSTALL_SKIP=true -# - CERT_MANAGER_INSTALL_SKIP=true -.PHONY: test-e2e -test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind. - @command -v kind >/dev/null 2>&1 || { \ - echo "Kind is not installed. Please install Kind manually."; \ - exit 1; \ - } - @kind get clusters | grep -q 'kind' || { \ - echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \ - exit 1; \ - } - go test ./test/e2e/ -v -ginkgo.v - -.PHONY: lint -lint: golangci-lint ## Run golangci-lint linter - $(GOLANGCI_LINT) run - -.PHONY: lint-fix -lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes - $(GOLANGCI_LINT) run --fix - -##@ Build - -.PHONY: build -build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager cmd/main.go - -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. - go run ./cmd/main.go - -# If you wish to build the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. -# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -.PHONY: docker-build -docker-build: ## Build docker image with the manager. - $(CONTAINER_TOOL) build -t ${IMG} . - -.PHONY: docker-push -docker-push: ## Push docker image with the manager. - $(CONTAINER_TOOL) push ${IMG} - -# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple -# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: -# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/ -# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=> then the export will fail) -# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option. -PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le -.PHONY: docker-buildx -docker-buildx: ## Build and push docker image for the manager for cross-platform support - # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile - sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - - $(CONTAINER_TOOL) buildx create --name project-v4-multigroup-with-deploy-image-builder - $(CONTAINER_TOOL) buildx use project-v4-multigroup-with-deploy-image-builder - - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . - - $(CONTAINER_TOOL) buildx rm project-v4-multigroup-with-deploy-image-builder - rm Dockerfile.cross - -.PHONY: build-installer -build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. - mkdir -p dist - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build config/default > dist/install.yaml - -##@ Deployment - -ifndef ignore-not-found - ignore-not-found = false -endif - -.PHONY: install -install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f - - -.PHONY: uninstall -uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -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 -f - - -.PHONY: undeploy -undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - - -##@ Dependencies - -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -KUBECTL ?= kubectl -KUSTOMIZE ?= $(LOCALBIN)/kustomize -CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen -ENVTEST ?= $(LOCALBIN)/setup-envtest -GOLANGCI_LINT = $(LOCALBIN)/golangci-lint - -## Tool Versions -KUSTOMIZE_VERSION ?= v5.4.3 -CONTROLLER_TOOLS_VERSION ?= v0.16.1 -ENVTEST_VERSION ?= release-0.19 -GOLANGCI_LINT_VERSION ?= v1.59.1 - -.PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. -$(KUSTOMIZE): $(LOCALBIN) - $(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION)) - -.PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. -$(CONTROLLER_GEN): $(LOCALBIN) - $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) - -.PHONY: envtest -envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. -$(ENVTEST): $(LOCALBIN) - $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION)) - -.PHONY: golangci-lint -golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. -$(GOLANGCI_LINT): $(LOCALBIN) - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) - -# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist -# $1 - target path with name of binary -# $2 - package url which can be installed -# $3 - specific version of package -define go-install-tool -@[ -f "$(1)-$(3)" ] || { \ -set -e; \ -package=$(2)@$(3) ;\ -echo "Downloading $${package}" ;\ -rm -f $(1) || true ;\ -GOBIN=$(LOCALBIN) go install $${package} ;\ -mv $(1) $(1)-$(3) ;\ -} ;\ -ln -sf $(1)-$(3) $(1) -endef diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/certmanager/certificate.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/certmanager/certificate.yaml deleted file mode 100644 index baf7c627d73..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/certmanager/certificate.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# The following manifests contain a self-signed issuer CR and a certificate CR. -# More document can be found at https://docs.cert-manager.io -# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes. -apiVersion: cert-manager.io/v1 -kind: Issuer -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: selfsigned-issuer - namespace: system -spec: - selfSigned: {} ---- -apiVersion: cert-manager.io/v1 -kind: Certificate -metadata: - labels: - app.kubernetes.io/name: certificate - app.kubernetes.io/instance: serving-cert - app.kubernetes.io/component: certificate - app.kubernetes.io/created-by: project-v4-multigroup-with-deploy-image - app.kubernetes.io/part-of: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml - namespace: system -spec: - # SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize - dnsNames: - - SERVICE_NAME.SERVICE_NAMESPACE.svc - - SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local - issuerRef: - kind: Issuer - name: selfsigned-issuer - secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/kustomization.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/default/kustomization.yaml deleted file mode 100644 index ef209c84019..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/default/kustomization.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# Adds namespace to all resources. -namespace: project-v4-multigroup-with-deploy-image-system - -# Value of this field is prepended to the -# names of all resources, e.g. a deployment named -# "wordpress" becomes "alices-wordpress". -# Note that it should also match with the prefix (text before '-') of the namespace -# field above. -namePrefix: project-v4-multigroup-with-deploy-image- - -# Labels to add to all resources and selectors. -#labels: -#- includeSelectors: true -# pairs: -# someName: someValue - -resources: -- ../crd -- ../rbac -- ../manager -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in -# crd/kustomization.yaml -- ../webhook -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. -#- ../certmanager -# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. -#- ../prometheus -# [METRICS] Expose the controller manager metrics service. -- metrics_service.yaml -# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy. -# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics. -# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will -# be able to communicate with the Webhook Server. -#- ../network-policy - -# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager -patches: -# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443. -# More info: https://book.kubebuilder.io/reference/metrics -- path: manager_metrics_patch.yaml - target: - kind: Deployment - -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in -# crd/kustomization.yaml -- path: manager_webhook_patch.yaml - -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. -# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. -# 'CERTMANAGER' needs to be enabled to use ca injection -#- path: webhookcainjection_patch.yaml - -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -# Uncomment the following replacements to add the cert-manager CA injection annotations -#replacements: -# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldPath: .metadata.namespace # namespace of the certificate CR -# targets: -# - select: -# kind: ValidatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - select: -# kind: MutatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - select: -# kind: CustomResourceDefinition -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - source: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldPath: .metadata.name -# targets: -# - select: -# kind: ValidatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - select: -# kind: MutatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - select: -# kind: CustomResourceDefinition -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - source: # Add cert-manager annotation to the webhook Service -# kind: Service -# version: v1 -# name: webhook-service -# fieldPath: .metadata.name # namespace of the service -# targets: -# - select: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# fieldPaths: -# - .spec.dnsNames.0 -# - .spec.dnsNames.1 -# options: -# delimiter: '.' -# index: 0 -# create: true -# - source: -# kind: Service -# version: v1 -# name: webhook-service -# fieldPath: .metadata.namespace # namespace of the service -# targets: -# - select: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# fieldPaths: -# - .spec.dnsNames.0 -# - .spec.dnsNames.1 -# options: -# delimiter: '.' -# index: 1 -# create: true diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_webhook_patch.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_webhook_patch.yaml deleted file mode 100644 index 306f6ceec53..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_webhook_patch.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize -spec: - template: - spec: - containers: - - name: manager - ports: - - containerPort: 9443 - name: webhook-server - protocol: TCP - volumeMounts: - - mountPath: /tmp/k8s-webhook-server/serving-certs - name: cert - readOnly: true - volumes: - - name: cert - secret: - defaultMode: 420 - secretName: webhook-server-cert diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/metrics_service.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/default/metrics_service.yaml deleted file mode 100644 index d2be1833a4c..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/default/metrics_service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-service - namespace: system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: 8443 - selector: - control-plane: controller-manager diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/webhookcainjection_patch.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/default/webhookcainjection_patch.yaml deleted file mode 100644 index 78417368c6f..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/default/webhookcainjection_patch.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# This patch add annotation to admission webhook config and -# CERTIFICATE_NAMESPACE and CERTIFICATE_NAME will be substituted by kustomize -apiVersion: admissionregistration.k8s.io/v1 -kind: MutatingWebhookConfiguration -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: mutating-webhook-configuration - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - labels: - app.kubernetes.io/name: validatingwebhookconfiguration - app.kubernetes.io/instance: validating-webhook-configuration - app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: project-v4-multigroup-with-deploy-image - app.kubernetes.io/part-of: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: validating-webhook-configuration - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml deleted file mode 100644 index 14e2a89ee75..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# This NetworkPolicy allows ingress traffic -# with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those -# namespaces are able to gathering data from the metrics endpoint. -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: allow-metrics-traffic - namespace: system -spec: - podSelector: - matchLabels: - control-plane: controller-manager - policyTypes: - - Ingress - ingress: - # This allows ingress traffic from any namespace with the label metrics: enabled - - from: - - namespaceSelector: - matchLabels: - metrics: enabled # Only from namespaces with this label - ports: - - port: 8443 - protocol: TCP diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml deleted file mode 100644 index c5a8be28260..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# This NetworkPolicy allows ingress traffic to your webhook server running -# as part of the controller-manager from specific namespaces and pods. CR(s) which uses webhooks -# will only work when applied in namespaces labeled with 'webhook: enabled' -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: allow-webhook-traffic - namespace: system -spec: - podSelector: - matchLabels: - control-plane: controller-manager - policyTypes: - - Ingress - ingress: - # This allows ingress traffic from any namespace with the label webhook: enabled - - from: - - namespaceSelector: - matchLabels: - webhook: enabled # Only from namespaces with this label - ports: - - port: 443 - protocol: TCP diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/prometheus/monitor.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/prometheus/monitor.yaml deleted file mode 100644 index 34e71995b62..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/prometheus/monitor.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Prometheus Monitor Service (Metrics) -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-monitor - namespace: system -spec: - endpoints: - - path: /metrics - port: https # Ensure this is the name of the port that exposes HTTPS metrics - scheme: https - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - tlsConfig: - # TODO(user): The option insecureSkipVerify: true is not recommended for production since it disables - # certificate verification. This poses a significant security risk by making the system vulnerable to - # man-in-the-middle attacks, where an attacker could intercept and manipulate the communication between - # Prometheus and the monitored services. This could lead to unauthorized access to sensitive metrics data, - # compromising the integrity and confidentiality of the information. - # Please use the following options for secure configurations: - # caFile: /etc/metrics-certs/ca.crt - # certFile: /etc/metrics-certs/tls.crt - # keyFile: /etc/metrics-certs/tls.key - insecureSkipVerify: true - selector: - matchLabels: - control-plane: controller-manager diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_editor_role.yaml deleted file mode 100644 index 68ef9aa89e4..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit captains. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: crew-captain-editor-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_viewer_role.yaml deleted file mode 100644 index 3f638c7766e..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/crew_captain_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view captains. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: crew-captain-viewer-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - get - - list - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_viewer_role.yaml deleted file mode 100644 index 66ab8490b61..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view bars. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: fiz-bar-viewer-role -rules: -- apiGroups: - - fiz.testproject.org - resources: - - bars - verbs: - - get - - list - - watch -- apiGroups: - - fiz.testproject.org - resources: - - bars/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml deleted file mode 100644 index 1c7824d9942..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit healthcheckpolicies. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: foo.policy-healthcheckpolicy-editor-role -rules: -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml deleted file mode 100644 index b4ad7c339a3..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view healthcheckpolicies. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: foo.policy-healthcheckpolicy-viewer-role -rules: -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - get - - list - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_editor_role.yaml deleted file mode 100644 index b20dabf9bad..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit bars. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: foo-bar-editor-role -rules: -- apiGroups: - - foo.testproject.org - resources: - - bars - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.testproject.org - resources: - - bars/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_viewer_role.yaml deleted file mode 100644 index 0994bd6706a..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/foo_bar_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view bars. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: foo-bar-viewer-role -rules: -- apiGroups: - - foo.testproject.org - resources: - - bars - verbs: - - get - - list - - watch -- apiGroups: - - foo.testproject.org - resources: - - bars/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_viewer_role.yaml deleted file mode 100644 index e0863e68a65..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view lakers. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: lakers-viewer-role -rules: -- apiGroups: - - testproject.org - resources: - - lakers - verbs: - - get - - list - - watch -- apiGroups: - - testproject.org - resources: - - lakers/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role.yaml deleted file mode 100644 index f844786953c..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# permissions to do leader election. -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: leader-election-role -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role_binding.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role_binding.yaml deleted file mode 100644 index 7612b3e3f66..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/leader_election_role_binding.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: leader-election-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: leader-election-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/role_binding.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/role_binding.yaml deleted file mode 100644 index 599a71b991f..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/role_binding.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: manager-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_editor_role.yaml deleted file mode 100644 index 4424f108e5b..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit krakens. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: sea-creatures-kraken-editor-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_viewer_role.yaml deleted file mode 100644 index 1912dd24ffb..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_kraken_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view krakens. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: sea-creatures-kraken-viewer-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - verbs: - - get - - list - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_editor_role.yaml deleted file mode 100644 index b856daabda2..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit leviathans. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: sea-creatures-leviathan-editor-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_viewer_role.yaml deleted file mode 100644 index cb22d2cc7ea..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/sea-creatures_leviathan_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view leviathans. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: sea-creatures-leviathan-viewer-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans - verbs: - - get - - list - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/service_account.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/service_account.yaml deleted file mode 100644 index 929b9eb1584..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/service_account.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: controller-manager - namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_editor_role.yaml deleted file mode 100644 index f9e767b202b..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit cruisers. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-cruiser-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - cruisers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_viewer_role.yaml deleted file mode 100644 index b3ab524cd6d..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_cruiser_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view cruisers. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-cruiser-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - cruisers - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_editor_role.yaml deleted file mode 100644 index 2aa4623823d..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit destroyers. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-destroyer-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - destroyers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - destroyers/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_viewer_role.yaml deleted file mode 100644 index e35439a76ee..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_destroyer_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view destroyers. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-destroyer-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - destroyers - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - destroyers/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_editor_role.yaml deleted file mode 100644 index 6938a6b55ea..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_editor_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to edit frigates. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-frigate-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - frigates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - frigates/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_viewer_role.yaml deleted file mode 100644 index 4d12c969627..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/ship_frigate_viewer_role.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# permissions for end users to view frigates. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: ship-frigate-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - frigates - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - frigates/status - verbs: - - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/crew_v1_captain.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/crew_v1_captain.yaml deleted file mode 100644 index 5ee2dcbccdf..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/crew_v1_captain.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: crew.testproject.org/v1 -kind: Captain -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: captain-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/fiz_v1_bar.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/fiz_v1_bar.yaml deleted file mode 100644 index 98d30c85204..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/fiz_v1_bar.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: fiz.testproject.org/v1 -kind: Bar -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: bar-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo.policy_v1_healthcheckpolicy.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo.policy_v1_healthcheckpolicy.yaml deleted file mode 100644 index 5fc59688452..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo.policy_v1_healthcheckpolicy.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: foo.policy.testproject.org/v1 -kind: HealthCheckPolicy -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: healthcheckpolicy-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo_v1_bar.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo_v1_bar.yaml deleted file mode 100644 index c9fc87fdb34..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/foo_v1_bar.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: foo.testproject.org/v1 -kind: Bar -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: bar-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml deleted file mode 100644 index f5e9802fed3..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml +++ /dev/null @@ -1,13 +0,0 @@ -## Append samples of your project ## -resources: -- crew_v1_captain.yaml -- ship_v1beta1_frigate.yaml -- ship_v1_destroyer.yaml -- ship_v2alpha1_cruiser.yaml -- sea-creatures_v1beta1_kraken.yaml -- sea-creatures_v1beta2_leviathan.yaml -- foo.policy_v1_healthcheckpolicy.yaml -- foo_v1_bar.yaml -- fiz_v1_bar.yaml -- v1_lakers.yaml -# +kubebuilder:scaffold:manifestskustomizesamples diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta1_kraken.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta1_kraken.yaml deleted file mode 100644 index 962a8694f99..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta1_kraken.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: sea-creatures.testproject.org/v1beta1 -kind: Kraken -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: kraken-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta2_leviathan.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta2_leviathan.yaml deleted file mode 100644 index 9f81f626ca4..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/sea-creatures_v1beta2_leviathan.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: sea-creatures.testproject.org/v1beta2 -kind: Leviathan -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: leviathan-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1_destroyer.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1_destroyer.yaml deleted file mode 100644 index d3e31a73a65..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1_destroyer.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: ship.testproject.org/v1 -kind: Destroyer -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: destroyer-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1beta1_frigate.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1beta1_frigate.yaml deleted file mode 100644 index 71166a0cf15..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v1beta1_frigate.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: ship.testproject.org/v1beta1 -kind: Frigate -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: frigate-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v2alpha1_cruiser.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v2alpha1_cruiser.yaml deleted file mode 100644 index e6872d9f31a..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/ship_v2alpha1_cruiser.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: ship.testproject.org/v2alpha1 -kind: Cruiser -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: cruiser-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/v1_lakers.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/v1_lakers.yaml deleted file mode 100644 index 134b5aafa57..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/v1_lakers.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: testproject.org/v1 -kind: Lakers -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: lakers-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/service.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/webhook/service.yaml deleted file mode 100644 index 55a8a9cbcb7..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: webhook-service - namespace: system -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 9443 - selector: - control-plane: controller-manager diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller.go deleted file mode 100644 index aeb22951253..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package foopolicy - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1" -) - -// HealthCheckPolicyReconciler reconciles a HealthCheckPolicy object -type HealthCheckPolicyReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the HealthCheckPolicy object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *HealthCheckPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *HealthCheckPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&foopolicyv1.HealthCheckPolicy{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller_test.go deleted file mode 100644 index 57b911e8893..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/healthcheckpolicy_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package foopolicy - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1" -) - -var _ = Describe("HealthCheckPolicy Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - healthcheckpolicy := &foopolicyv1.HealthCheckPolicy{} - - BeforeEach(func() { - By("creating the custom resource for the Kind HealthCheckPolicy") - err := k8sClient.Get(ctx, typeNamespacedName, healthcheckpolicy) - if err != nil && errors.IsNotFound(err) { - resource := &foopolicyv1.HealthCheckPolicy{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &foopolicyv1.HealthCheckPolicy{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance HealthCheckPolicy") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &HealthCheckPolicyReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller.go deleted file mode 100644 index 4605f649509..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/v1" -) - -// LakersReconciler reconciles a Lakers object -type LakersReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=testproject.org,resources=lakers,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=testproject.org,resources=lakers/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=testproject.org,resources=lakers/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Lakers object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *LakersReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *LakersReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&testprojectorgv1.Lakers{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller_test.go deleted file mode 100644 index 55ddba24b09..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/lakers_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/v1" -) - -var _ = Describe("Lakers Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - lakers := &testprojectorgv1.Lakers{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Lakers") - err := k8sClient.Get(ctx, typeNamespacedName, lakers) - if err != nil && errors.IsNotFound(err) { - resource := &testprojectorgv1.Lakers{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &testprojectorgv1.Lakers{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Lakers") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &LakersReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller.go deleted file mode 100644 index 4df51119033..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package seacreatures - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1" -) - -// KrakenReconciler reconciles a Kraken object -type KrakenReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Kraken object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *KrakenReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *KrakenReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&seacreaturesv1beta1.Kraken{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller_test.go deleted file mode 100644 index 531252dca2b..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/kraken_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package seacreatures - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1" -) - -var _ = Describe("Kraken Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - kraken := &seacreaturesv1beta1.Kraken{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Kraken") - err := k8sClient.Get(ctx, typeNamespacedName, kraken) - if err != nil && errors.IsNotFound(err) { - resource := &seacreaturesv1beta1.Kraken{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &seacreaturesv1beta1.Kraken{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Kraken") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &KrakenReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller.go deleted file mode 100644 index ef6b284961f..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package seacreatures - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2" -) - -// LeviathanReconciler reconciles a Leviathan object -type LeviathanReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Leviathan object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *LeviathanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *LeviathanReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&seacreaturesv1beta2.Leviathan{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller_test.go deleted file mode 100644 index 9c0a6d79d87..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/leviathan_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package seacreatures - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2" -) - -var _ = Describe("Leviathan Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - leviathan := &seacreaturesv1beta2.Leviathan{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Leviathan") - err := k8sClient.Get(ctx, typeNamespacedName, leviathan) - if err != nil && errors.IsNotFound(err) { - resource := &seacreaturesv1beta2.Leviathan{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &seacreaturesv1beta2.Leviathan{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Leviathan") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &LeviathanReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/suite_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/suite_test.go deleted file mode 100644 index 8de94de7707..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures/suite_test.go +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package seacreatures - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = seacreaturesv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = seacreaturesv1beta2.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller.go deleted file mode 100644 index 26685efed97..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1" -) - -// CruiserReconciler reconciles a Cruiser object -type CruiserReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Cruiser object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *CruiserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *CruiserReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&shipv2alpha1.Cruiser{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller_test.go deleted file mode 100644 index 6c008717e68..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/cruiser_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1" -) - -var _ = Describe("Cruiser Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - cruiser := &shipv2alpha1.Cruiser{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Cruiser") - err := k8sClient.Get(ctx, typeNamespacedName, cruiser) - if err != nil && errors.IsNotFound(err) { - resource := &shipv2alpha1.Cruiser{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &shipv2alpha1.Cruiser{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Cruiser") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &CruiserReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller.go deleted file mode 100644 index a6969cebc5a..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1" -) - -// FrigateReconciler reconciles a Frigate object -type FrigateReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Frigate object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *FrigateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *FrigateReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&shipv1beta1.Frigate{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller_test.go deleted file mode 100644 index d8597e00598..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/frigate_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1" -) - -var _ = Describe("Frigate Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - frigate := &shipv1beta1.Frigate{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Frigate") - err := k8sClient.Get(ctx, typeNamespacedName, frigate) - if err != nil && errors.IsNotFound(err) { - resource := &shipv1beta1.Frigate{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &shipv1beta1.Frigate{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Frigate") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &FrigateReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/suite_test.go b/testdata/project-v4-multigroup-with-deploy-image/internal/controller/suite_test.go deleted file mode 100644 index 2fd64959065..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/suite_test.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controller - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/v1" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = testprojectorgv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_suite_test.go b/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_suite_test.go deleted file mode 100644 index 2404cc6ea74..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_suite_test.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e - -import ( - "fmt" - "os" - "os/exec" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/test/utils" -) - -var ( - // Optional Environment Variables: - // - PROMETHEUS_INSTALL_SKIP=true: Skips Prometheus Operator installation during test setup. - // - CERT_MANAGER_INSTALL_SKIP=true: Skips CertManager installation during test setup. - // These variables are useful if Prometheus or CertManager is already installed, avoiding - // re-installation and conflicts. - skipPrometheusInstall = os.Getenv("PROMETHEUS_INSTALL_SKIP") == "true" - skipCertManagerInstall = os.Getenv("CERT_MANAGER_INSTALL_SKIP") == "true" - // isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster - isPrometheusOperatorAlreadyInstalled = false - // isCertManagerAlreadyInstalled will be set true when CertManager CRDs be found on the cluster - isCertManagerAlreadyInstalled = false - - // projectImage is the name of the image which will be build and loaded - // with the code source changes to be tested. - projectImage = "example.com/project-v4-multigroup-with-deploy-image:v0.0.1" -) - -// TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated, -// temporary environment to validate project changes with the the purposed to be used in CI jobs. -// The default setup requires Kind, builds/loads the Manager Docker image locally, and installs -// CertManager and Prometheus. -func TestE2E(t *testing.T) { - RegisterFailHandler(Fail) - _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-multigroup-with-deploy-image integration test suite\n") - RunSpecs(t, "e2e suite") -} - -var _ = BeforeSuite(func() { - By("Ensure that Prometheus is enabled") - _ = utils.UncommentCode("config/default/kustomization.yaml", "#- ../prometheus", "#") - - By("generating files") - cmd := exec.Command("make", "generate") - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to run make generate") - - By("generating manifests") - cmd = exec.Command("make", "manifests") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to run make manifests") - - By("building the manager(Operator) image") - cmd = exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the manager(Operator) image") - - // TODO(user): If you want to change the e2e test vendor from Kind, ensure the image is - // built and available before running the tests. Also, remove the following block. - By("loading the manager(Operator) image on Kind") - err = utils.LoadImageToKindClusterWithName(projectImage) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the manager(Operator) image into Kind") - - // The tests-e2e are intended to run on a temporary cluster that is created and destroyed for testing. - // To prevent errors when tests run in environments with Prometheus or CertManager already installed, - // we check for their presence before execution. - // Setup Prometheus and CertManager before the suite if not skipped and if not already installed - if !skipPrometheusInstall { - By("checking if prometheus is installed already") - isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled() - if !isPrometheusOperatorAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n") - Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator") - } else { - _, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n") - } - } - if !skipCertManagerInstall { - By("checking if cert manager is installed already") - isCertManagerAlreadyInstalled = utils.IsCertManagerCRDsInstalled() - if !isCertManagerAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Installing CertManager...\n") - Expect(utils.InstallCertManager()).To(Succeed(), "Failed to install CertManager") - } else { - _, _ = fmt.Fprintf(GinkgoWriter, "WARNING: CertManager is already installed. Skipping installation...\n") - } - } -}) - -var _ = AfterSuite(func() { - // Teardown Prometheus and CertManager after the suite if not skipped and if they were not already installed - if !skipPrometheusInstall && !isPrometheusOperatorAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n") - utils.UninstallPrometheusOperator() - } - if !skipCertManagerInstall && !isCertManagerAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling CertManager...\n") - utils.UninstallCertManager() - } -}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go b/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go deleted file mode 100644 index 9c6095b56c1..00000000000 --- a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go +++ /dev/null @@ -1,299 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e - -import ( - "encoding/json" - "fmt" - "os" - "os/exec" - "path/filepath" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/test/utils" -) - -// namespace where the project is deployed in -const namespace = "project-v4-multigroup-with-deploy-image-system" - -// serviceAccountName created for the project -const serviceAccountName = "project-v4-multigroup-with-deploy-image-controller-manager" - -// metricsServiceName is the name of the metrics service of the project -const metricsServiceName = "project-v4-multigroup-with-deploy-image-controller-manager-metrics-service" - -// metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data -const metricsRoleBindingName = "project-v4-multigroup-with-deploy-image-metrics-binding" - -var _ = Describe("Manager", Ordered, func() { - // Before running the tests, set up the environment by creating the namespace, - // installing CRDs, and deploying the controller. - BeforeAll(func() { - By("creating manager namespace") - cmd := exec.Command("kubectl", "create", "ns", namespace) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") - - By("installing CRDs") - cmd = exec.Command("make", "install") - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") - - By("deploying the controller-manager") - cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") - }) - - // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, - // and deleting the namespace. - AfterAll(func() { - By("cleaning up the curl pod for metrics") - cmd := exec.Command("kubectl", "delete", "pod", "curl-metrics", "-n", namespace) - _, _ = utils.Run(cmd) - - By("undeploying the controller-manager") - cmd = exec.Command("make", "undeploy") - _, _ = utils.Run(cmd) - - By("uninstalling CRDs") - cmd = exec.Command("make", "uninstall") - _, _ = utils.Run(cmd) - - By("removing manager namespace") - cmd = exec.Command("kubectl", "delete", "ns", namespace) - _, _ = utils.Run(cmd) - }) - - SetDefaultEventuallyTimeout(2 * time.Minute) - SetDefaultEventuallyPollingInterval(time.Second) - - // The Context block contains the actual tests that validate the manager's behavior. - Context("Manager", func() { - var controllerPodName string - It("should run successfully", func() { - By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func(g Gomega) { - // Get the name of the controller-manager pod - cmd := exec.Command("kubectl", "get", - "pods", "-l", "control-plane=controller-manager", - "-o", "go-template={{ range .items }}"+ - "{{ if not .metadata.deletionTimestamp }}"+ - "{{ .metadata.name }}"+ - "{{ \"\\n\" }}{{ end }}{{ end }}", - "-n", namespace, - ) - - podOutput, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) - g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") - controllerPodName = podNames[0] - g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) - - // Validate the pod's status - cmd = exec.Command("kubectl", "get", - "pods", controllerPodName, "-o", "jsonpath={.status.phase}", - "-n", namespace, - ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") - } - // Repeatedly check if the controller-manager pod is running until it succeeds or times out. - Eventually(verifyControllerUp).Should(Succeed()) - }) - - It("should ensure the metrics endpoint is serving metrics", func() { - By("creating a ClusterRoleBinding for the service account to allow access to metrics") - cmd := exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName, - "--clusterrole=project-v4-multigroup-with-deploy-image-metrics-reader", - fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), - ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") - - By("validating that the metrics service is available") - cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") - - By("validating that the ServiceMonitor for Prometheus is applied in the namespace") - cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") - - By("getting the service account token") - token, err := serviceAccountToken() - Expect(err).NotTo(HaveOccurred()) - Expect(token).NotTo(BeEmpty()) - - By("waiting for the metrics endpoint to be ready") - verifyMetricsEndpointReady := func(g Gomega) { - cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") - } - Eventually(verifyMetricsEndpointReady).Should(Succeed()) - - By("verifying that the controller manager is serving the metrics server") - verifyMetricsServerStarted := func(g Gomega) { - cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), - "Metrics server not yet started") - } - Eventually(verifyMetricsServerStarted).Should(Succeed()) - - By("creating the curl-metrics pod to access the metrics endpoint") - cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never", - "--namespace", namespace, - "--image=curlimages/curl:7.78.0", - "--", "/bin/sh", "-c", fmt.Sprintf( - "curl -v -k -H 'Authorization: Bearer %s' https://%s.%s.svc.cluster.local:8443/metrics", - token, metricsServiceName, namespace)) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create curl-metrics pod") - - By("waiting for the curl-metrics pod to complete.") - verifyCurlUp := func(g Gomega) { - cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", - "-o", "jsonpath={.status.phase}", - "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") - } - Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) - - By("getting the metrics by checking curl-metrics logs") - metricsOutput := getMetricsOutput() - Expect(metricsOutput).To(ContainSubstring( - "controller_runtime_reconcile_total", - )) - }) - - It("should provisioned cert-manager", func() { - By("validating that cert-manager has the certificate Secret") - verifyCertManager := func(g Gomega) { - cmd := exec.Command("kubectl", "get", "secrets", "webhook-server-cert", "-n", namespace) - _, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - } - Eventually(verifyCertManager).Should(Succeed()) - }) - - It("should have CA injection for mutating webhooks", func() { - By("checking CA injection for mutating webhooks") - verifyCAInjection := func(g Gomega) { - cmd := exec.Command("kubectl", "get", - "mutatingwebhookconfigurations.admissionregistration.k8s.io", - "project-v4-multigroup-with-deploy-image-mutating-webhook-configuration", - "-o", "go-template={{ range .webhooks }}{{ .clientConfig.caBundle }}{{ end }}") - mwhOutput, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(len(mwhOutput)).To(BeNumerically(">", 10)) - } - Eventually(verifyCAInjection).Should(Succeed()) - }) - - It("should have CA injection for validating webhooks", func() { - By("checking CA injection for validating webhooks") - verifyCAInjection := func(g Gomega) { - cmd := exec.Command("kubectl", "get", - "validatingwebhookconfigurations.admissionregistration.k8s.io", - "project-v4-multigroup-with-deploy-image-validating-webhook-configuration", - "-o", "go-template={{ range .webhooks }}{{ .clientConfig.caBundle }}{{ end }}") - vwhOutput, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(len(vwhOutput)).To(BeNumerically(">", 10)) - } - Eventually(verifyCAInjection).Should(Succeed()) - }) - - // +kubebuilder:scaffold:e2e-webhooks-checks - - // TODO: Customize the e2e test suite with scenarios specific to your project. - // Consider applying sample/CR(s) and check their status and/or verifying - // the reconciliation by using the metrics, i.e.: - // metricsOutput := getMetricsOutput() - // Expect(metricsOutput).To(ContainSubstring( - // fmt.Sprintf(`controller_runtime_reconcile_total{controller="%s",result="success"} 1`, - // strings.ToLower(), - // )) - }) -}) - -// serviceAccountToken returns a token for the specified service account in the given namespace. -// It uses the Kubernetes TokenRequest API to generate a token by directly sending a request -// and parsing the resulting token from the API response. -func serviceAccountToken() (string, error) { - const tokenRequestRawString = `{ - "apiVersion": "authentication.k8s.io/v1", - "kind": "TokenRequest" - }` - - // Temporary file to store the token request - secretName := fmt.Sprintf("%s-token-request", serviceAccountName) - tokenRequestFile := filepath.Join("/tmp", secretName) - err := os.WriteFile(tokenRequestFile, []byte(tokenRequestRawString), os.FileMode(0o644)) - if err != nil { - return "", err - } - - var out string - var rawJson string - verifyTokenCreation := func(g Gomega) { - // Execute kubectl command to create the token - cmd := exec.Command("kubectl", "create", "--raw", fmt.Sprintf( - "/api/v1/namespaces/%s/serviceaccounts/%s/token", - namespace, - serviceAccountName, - ), "-f", tokenRequestFile) - - output, err := cmd.CombinedOutput() - g.Expect(err).NotTo(HaveOccurred()) - - rawJson = string(output) - - // Parse the JSON output to extract the token - var token tokenRequest - err = json.Unmarshal([]byte(rawJson), &token) - g.Expect(err).NotTo(HaveOccurred()) - - out = token.Status.Token - } - Eventually(verifyTokenCreation).Should(Succeed()) - - return out, err -} - -// getMetricsOutput retrieves and returns the logs from the curl pod used to access the metrics endpoint. -func getMetricsOutput() string { - By("getting the curl-metrics logs") - cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) - metricsOutput, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr -} - -// tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, -// containing only the token field that we need to extract. -type tokenRequest struct { - Status struct { - Token string `json:"token"` - } `json:"status"` -} diff --git a/testdata/project-v4-multigroup-with-deploy-image/.devcontainer/devcontainer.json b/testdata/project-v4-multigroup-with-plugins/.devcontainer/devcontainer.json similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/.devcontainer/devcontainer.json rename to testdata/project-v4-multigroup-with-plugins/.devcontainer/devcontainer.json diff --git a/testdata/project-v4-multigroup-with-deploy-image/.devcontainer/post-install.sh b/testdata/project-v4-multigroup-with-plugins/.devcontainer/post-install.sh similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/.devcontainer/post-install.sh rename to testdata/project-v4-multigroup-with-plugins/.devcontainer/post-install.sh diff --git a/testdata/project-v4-multigroup-with-deploy-image/.dockerignore b/testdata/project-v4-multigroup-with-plugins/.dockerignore similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/.dockerignore rename to testdata/project-v4-multigroup-with-plugins/.dockerignore diff --git a/testdata/project-v4-multigroup-with-deploy-image/.gitignore b/testdata/project-v4-multigroup-with-plugins/.gitignore similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/.gitignore rename to testdata/project-v4-multigroup-with-plugins/.gitignore diff --git a/testdata/project-v4-multigroup-with-deploy-image/.golangci.yml b/testdata/project-v4-multigroup-with-plugins/.golangci.yml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/.golangci.yml rename to testdata/project-v4-multigroup-with-plugins/.golangci.yml diff --git a/testdata/project-v4-multigroup-with-deploy-image/Dockerfile b/testdata/project-v4-multigroup-with-plugins/Dockerfile similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/Dockerfile rename to testdata/project-v4-multigroup-with-plugins/Dockerfile diff --git a/testdata/project-v4-multigroup/Makefile b/testdata/project-v4-multigroup-with-plugins/Makefile similarity index 98% rename from testdata/project-v4-multigroup/Makefile rename to testdata/project-v4-multigroup-with-plugins/Makefile index 03cb580d51b..18fc8fa1240 100644 --- a/testdata/project-v4-multigroup/Makefile +++ b/testdata/project-v4-multigroup-with-plugins/Makefile @@ -120,10 +120,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le docker-buildx: ## Build and push docker image for the manager for cross-platform support # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - - $(CONTAINER_TOOL) buildx create --name project-v4-multigroup-builder - $(CONTAINER_TOOL) buildx use project-v4-multigroup-builder + - $(CONTAINER_TOOL) buildx create --name project-v4-multigroup-with-plugins-builder + $(CONTAINER_TOOL) buildx use project-v4-multigroup-with-plugins-builder - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . - - $(CONTAINER_TOOL) buildx rm project-v4-multigroup-builder + - $(CONTAINER_TOOL) buildx rm project-v4-multigroup-with-plugins-builder rm Dockerfile.cross .PHONY: build-installer diff --git a/testdata/project-v4-multigroup-with-deploy-image/PROJECT b/testdata/project-v4-multigroup-with-plugins/PROJECT similarity index 66% rename from testdata/project-v4-multigroup-with-deploy-image/PROJECT rename to testdata/project-v4-multigroup-with-plugins/PROJECT index c225adc3d9e..5bbce7c9935 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/PROJECT +++ b/testdata/project-v4-multigroup-with-plugins/PROJECT @@ -6,8 +6,27 @@ domain: testproject.org layout: - go.kubebuilder.io/v4 multigroup: true -projectName: project-v4-multigroup-with-deploy-image -repo: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image +plugins: + deploy-image.go.kubebuilder.io/v1-alpha: + resources: + - domain: testproject.org + group: example.com + kind: Memcached + options: + containerCommand: memcached,-m=64,-o,modern,-v + containerPort: "11211" + image: memcached:memcached:1.6.26-alpine3.19 + runAsUser: "1001" + version: v1alpha1 + - domain: testproject.org + group: example.com + kind: Busybox + options: + image: busybox:1.36.1 + version: v1alpha1 + grafana.kubebuilder.io/v1-alpha: {} +projectName: project-v4-multigroup-with-plugins +repo: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins resources: - api: crdVersion: v1 @@ -16,7 +35,7 @@ resources: domain: testproject.org group: crew kind: Captain - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/crew/v1 version: v1 webhooks: defaulting: true @@ -29,7 +48,7 @@ resources: domain: testproject.org group: ship kind: Frigate - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1 version: v1beta1 webhooks: conversion: true @@ -40,7 +59,7 @@ resources: domain: testproject.org group: ship kind: Destroyer - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1 version: v1 webhooks: defaulting: true @@ -51,7 +70,7 @@ resources: domain: testproject.org group: ship kind: Cruiser - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1 version: v2alpha1 webhooks: validation: true @@ -63,7 +82,7 @@ resources: domain: testproject.org group: sea-creatures kind: Kraken - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1 version: v1beta1 - api: crdVersion: v1 @@ -72,7 +91,7 @@ resources: domain: testproject.org group: sea-creatures kind: Leviathan - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2 version: v1beta2 - api: crdVersion: v1 @@ -81,7 +100,7 @@ resources: domain: testproject.org group: foo.policy kind: HealthCheckPolicy - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1 version: v1 - controller: true group: apps @@ -95,7 +114,7 @@ resources: domain: testproject.org group: foo kind: Bar - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo/v1 version: v1 - api: crdVersion: v1 @@ -104,7 +123,7 @@ resources: domain: testproject.org group: fiz kind: Bar - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/fiz/v1 version: v1 - api: crdVersion: v1 @@ -112,10 +131,31 @@ resources: controller: true domain: testproject.org kind: Lakers - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/v1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/v1 version: v1 webhooks: defaulting: true validation: true webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: testproject.org + group: example.com + kind: Memcached + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1 + version: v1alpha1 + webhooks: + validation: true + webhookVersion: v1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: testproject.org + group: example.com + kind: Busybox + path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1 + version: v1alpha1 version: "3" diff --git a/testdata/project-v4-multigroup-with-deploy-image/README.md b/testdata/project-v4-multigroup-with-plugins/README.md similarity index 92% rename from testdata/project-v4-multigroup-with-deploy-image/README.md rename to testdata/project-v4-multigroup-with-plugins/README.md index eef188fbd05..ccf8dfda123 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/README.md +++ b/testdata/project-v4-multigroup-with-plugins/README.md @@ -1,4 +1,4 @@ -# project-v4-multigroup-with-deploy-image +# project-v4-multigroup-with-plugins // TODO(user): Add simple overview of use/purpose ## Description @@ -16,7 +16,7 @@ **Build and push your image to the location specified by `IMG`:** ```sh -make docker-build docker-push IMG=/project-v4-multigroup-with-deploy-image:tag +make docker-build docker-push IMG=/project-v4-multigroup-with-plugins:tag ``` **NOTE:** This image ought to be published in the personal registry you specified. @@ -32,7 +32,7 @@ make install **Deploy the Manager to the cluster with the image specified by `IMG`:** ```sh -make deploy IMG=/project-v4-multigroup-with-deploy-image:tag +make deploy IMG=/project-v4-multigroup-with-plugins:tag ``` > **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin @@ -73,7 +73,7 @@ Following are the steps to build the installer and distribute this project to us 1. Build the installer for the image built and published in the registry: ```sh -make build-installer IMG=/project-v4-multigroup-with-deploy-image:tag +make build-installer IMG=/project-v4-multigroup-with-plugins:tag ``` NOTE: The makefile target mentioned above generates an 'install.yaml' @@ -86,7 +86,7 @@ its dependencies. Users can just run kubectl apply -f to install the project, i.e.: ```sh -kubectl apply -f https://raw.githubusercontent.com//project-v4-multigroup-with-deploy-image//dist/install.yaml +kubectl apply -f https://raw.githubusercontent.com//project-v4-multigroup-with-plugins//dist/install.yaml ``` ## Contributing diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_types.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_types.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_webhook.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_webhook.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_webhook_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/captain_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/captain_webhook_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/webhook_suite_test.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/webhook_suite_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/webhook_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/webhook_suite_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/crew/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/crew/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/crew/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/busybox_types.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/busybox_types.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/busybox_types.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/busybox_types.go diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/groupversion_info.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/groupversion_info.go diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_types.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_types.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_types.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_types.go diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_webhook.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_webhook.go diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_webhook_test.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/memcached_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/memcached_webhook_test.go diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/webhook_suite_test.go similarity index 98% rename from testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/webhook_suite_test.go index 031400e44cc..94caeb96601 100644 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/webhook_suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/webhook_suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v1alpha1 import ( "context" @@ -115,7 +115,7 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = (&Cruiser{}).SetupWebhookWithManager(mgr) + err = (&Memcached{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) // +kubebuilder:scaffold:webhook diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/bar_types.go b/testdata/project-v4-multigroup-with-plugins/api/fiz/v1/bar_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/bar_types.go rename to testdata/project-v4-multigroup-with-plugins/api/fiz/v1/bar_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/fiz/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/fiz/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/fiz/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/fiz/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/healthcheckpolicy_types.go b/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/healthcheckpolicy_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/healthcheckpolicy_types.go rename to testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/healthcheckpolicy_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/bar_types.go b/testdata/project-v4-multigroup-with-plugins/api/foo/v1/bar_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/bar_types.go rename to testdata/project-v4-multigroup-with-plugins/api/foo/v1/bar_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/foo/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/foo/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/foo/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/foo/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/foo/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/kraken_types.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/kraken_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/kraken_types.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/kraken_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/leviathan_types.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/leviathan_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/leviathan_types.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/leviathan_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_types.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_types.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_webhook.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_webhook.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_webhook_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/destroyer_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/destroyer_webhook_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/webhook_suite_test.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/webhook_suite_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/webhook_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/webhook_suite_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_types.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_types.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_webhook.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_webhook.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_webhook_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/frigate_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/frigate_webhook_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_types.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_types.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_webhook.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_webhook.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_webhook_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/cruiser_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/cruiser_webhook_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/webhook_suite_test.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/webhook_suite_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/webhook_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/webhook_suite_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/groupversion_info.go b/testdata/project-v4-multigroup-with-plugins/api/v1/groupversion_info.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/groupversion_info.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/groupversion_info.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_types.go b/testdata/project-v4-multigroup-with-plugins/api/v1/lakers_types.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_types.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/lakers_types.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_webhook.go b/testdata/project-v4-multigroup-with-plugins/api/v1/lakers_webhook.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_webhook.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/lakers_webhook.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_webhook_test.go b/testdata/project-v4-multigroup-with-plugins/api/v1/lakers_webhook_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/lakers_webhook_test.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/lakers_webhook_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/webhook_suite_test.go b/testdata/project-v4-multigroup-with-plugins/api/v1/webhook_suite_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/webhook_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/webhook_suite_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/api/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup-with-plugins/api/v1/zz_generated.deepcopy.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/api/v1/zz_generated.deepcopy.go rename to testdata/project-v4-multigroup-with-plugins/api/v1/zz_generated.deepcopy.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/cmd/main.go b/testdata/project-v4-multigroup-with-plugins/cmd/main.go similarity index 85% rename from testdata/project-v4-multigroup-with-deploy-image/cmd/main.go rename to testdata/project-v4-multigroup-with-plugins/cmd/main.go index 2f3408ec2be..c329ac98dea 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/cmd/main.go +++ b/testdata/project-v4-multigroup-with-plugins/cmd/main.go @@ -35,24 +35,26 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1" - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1" - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1" - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta1" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/sea-creatures/v1beta2" - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1" - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/v1" - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller" - appscontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps" - crewcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew" - fizcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz" - foocontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo" - foopolicycontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy" - seacreaturescontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/sea-creatures" - shipcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/crew/v1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" + fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/fiz/v1" + foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1" + foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo/v1" + seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1" + seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2" + shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1" + shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1" + shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1" + testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/v1" + "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller" + appscontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/apps" + crewcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/crew" + examplecomcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com" + fizcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz" + foocontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/foo" + foopolicycontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy" + seacreaturescontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures" + shipcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/internal/controller/ship" // +kubebuilder:scaffold:imports ) @@ -74,6 +76,7 @@ func init() { utilruntime.Must(foov1.AddToScheme(scheme)) utilruntime.Must(fizv1.AddToScheme(scheme)) utilruntime.Must(testprojectorgv1.AddToScheme(scheme)) + utilruntime.Must(examplecomv1alpha1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme } @@ -151,7 +154,7 @@ func main() { WebhookServer: webhookServer, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "65c8a5ec.testproject.org", + LeaderElectionID: "f0637429.testproject.org", // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily // when the Manager ends. This requires the binary to immediately end when the // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly @@ -281,6 +284,29 @@ func main() { os.Exit(1) } } + if err = (&examplecomcontroller.MemcachedReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("memcached-controller"), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Memcached") + os.Exit(1) + } + if err = (&examplecomcontroller.BusyboxReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Recorder: mgr.GetEventRecorderFor("busybox-controller"), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "Busybox") + os.Exit(1) + } + // nolint:goconst + if os.Getenv("ENABLE_WEBHOOKS") != "false" { + if err = (&examplecomv1alpha1.Memcached{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "Memcached") + os.Exit(1) + } + } // +kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/testdata/project-v4-with-deploy-image/config/certmanager/certificate.yaml b/testdata/project-v4-multigroup-with-plugins/config/certmanager/certificate.yaml similarity index 85% rename from testdata/project-v4-with-deploy-image/config/certmanager/certificate.yaml rename to testdata/project-v4-multigroup-with-plugins/config/certmanager/certificate.yaml index 57aab1d5e54..4863e8cb944 100644 --- a/testdata/project-v4-with-deploy-image/config/certmanager/certificate.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/certmanager/certificate.yaml @@ -5,7 +5,7 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: selfsigned-issuer namespace: system @@ -19,8 +19,8 @@ metadata: app.kubernetes.io/name: certificate app.kubernetes.io/instance: serving-cert app.kubernetes.io/component: certificate - app.kubernetes.io/created-by: project-v4-with-deploy-image - app.kubernetes.io/part-of: project-v4-with-deploy-image + app.kubernetes.io/created-by: project-v4-multigroup-with-plugins + app.kubernetes.io/part-of: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/certmanager/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/certmanager/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/certmanager/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/certmanager/kustomization.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/certmanager/kustomizeconfig.yaml b/testdata/project-v4-multigroup-with-plugins/config/certmanager/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/certmanager/kustomizeconfig.yaml rename to testdata/project-v4-multigroup-with-plugins/config/certmanager/kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/crew.testproject.org_captains.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/crew.testproject.org_captains.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/crew.testproject.org_captains.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/crew.testproject.org_captains.yaml diff --git a/testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_busyboxes.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/example.com.testproject.org_busyboxes.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_busyboxes.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/example.com.testproject.org_busyboxes.yaml diff --git a/testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_memcacheds.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/example.com.testproject.org_memcacheds.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/crd/bases/example.com.testproject.org_memcacheds.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/example.com.testproject.org_memcacheds.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/fiz.testproject.org_bars.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/fiz.testproject.org_bars.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/fiz.testproject.org_bars.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/fiz.testproject.org_bars.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/foo.testproject.org_bars.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/foo.testproject.org_bars.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/foo.testproject.org_bars.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/foo.testproject.org_bars.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/sea-creatures.testproject.org_krakens.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/sea-creatures.testproject.org_krakens.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/sea-creatures.testproject.org_krakens.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/sea-creatures.testproject.org_krakens.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_cruisers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_cruisers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_cruisers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_cruisers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_destroyers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_destroyers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_destroyers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_destroyers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_frigates.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_frigates.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/ship.testproject.org_frigates.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/ship.testproject.org_frigates.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/testproject.org_lakers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/bases/testproject.org_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/bases/testproject.org_lakers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/bases/testproject.org_lakers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/kustomization.yaml similarity index 88% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/kustomization.yaml index c9e3a747c5e..8e7e5508352 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/crd/kustomization.yaml @@ -12,6 +12,8 @@ resources: - bases/foo.testproject.org_bars.yaml - bases/fiz.testproject.org_bars.yaml - bases/testproject.org_lakers.yaml +- bases/example.com.testproject.org_memcacheds.yaml +- bases/example.com.testproject.org_busyboxes.yaml # +kubebuilder:scaffold:crdkustomizeresource patches: @@ -22,6 +24,7 @@ patches: - path: patches/webhook_in_ship_destroyers.yaml - path: patches/webhook_in_ship_cruisers.yaml - path: patches/webhook_in_lakers.yaml +- path: patches/webhook_in_example.com_memcacheds.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. @@ -36,6 +39,8 @@ patches: #- path: patches/cainjection_in_foo_bars.yaml #- path: patches/cainjection_in_fiz_bars.yaml #- path: patches/cainjection_in_lakers.yaml +#- path: patches/cainjection_in_example.com_memcacheds.yaml +#- path: patches/cainjection_in_example.com_busyboxes.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomizeconfig.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomizeconfig.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_crew_captains.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_crew_captains.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_crew_captains.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_crew_captains.yaml diff --git a/testdata/project-v4-with-deploy-image/config/crd/patches/cainjection_in_memcacheds.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_example.com_memcacheds.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/crd/patches/cainjection_in_memcacheds.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_example.com_memcacheds.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_lakers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_lakers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_lakers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_cruisers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_cruisers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_cruisers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_cruisers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_destroyers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_destroyers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_destroyers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_destroyers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_frigates.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_frigates.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_ship_frigates.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/cainjection_in_ship_frigates.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_crew_captains.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_crew_captains.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_crew_captains.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_crew_captains.yaml diff --git a/testdata/project-v4-with-deploy-image/config/crd/patches/webhook_in_memcacheds.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_example.com_memcacheds.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/crd/patches/webhook_in_memcacheds.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_example.com_memcacheds.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_lakers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_lakers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_lakers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_cruisers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_cruisers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_cruisers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_cruisers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_destroyers.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_destroyers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_destroyers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_destroyers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_frigates.yaml b/testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_frigates.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_ship_frigates.yaml rename to testdata/project-v4-multigroup-with-plugins/config/crd/patches/webhook_in_ship_frigates.yaml diff --git a/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/default/kustomization.yaml similarity index 98% rename from testdata/project-v4-with-deploy-image/config/default/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/default/kustomization.yaml index ba24525ade9..27944e9bb67 100644 --- a/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/default/kustomization.yaml @@ -1,12 +1,12 @@ # Adds namespace to all resources. -namespace: project-v4-with-deploy-image-system +namespace: project-v4-multigroup-with-plugins-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named # "wordpress" becomes "alices-wordpress". # Note that it should also match with the prefix (text before '-') of the namespace # field above. -namePrefix: project-v4-with-deploy-image- +namePrefix: project-v4-multigroup-with-plugins- # Labels to add to all resources and selectors. #labels: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml b/testdata/project-v4-multigroup-with-plugins/config/default/manager_metrics_patch.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/default/manager_metrics_patch.yaml rename to testdata/project-v4-multigroup-with-plugins/config/default/manager_metrics_patch.yaml diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_webhook_patch.yaml b/testdata/project-v4-multigroup-with-plugins/config/default/manager_webhook_patch.yaml similarity index 89% rename from testdata/project-v4-with-deploy-image/config/default/manager_webhook_patch.yaml rename to testdata/project-v4-multigroup-with-plugins/config/default/manager_webhook_patch.yaml index 966b5cb2193..0c62bd808e3 100644 --- a/testdata/project-v4-with-deploy-image/config/default/manager_webhook_patch.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/default/manager_webhook_patch.yaml @@ -4,7 +4,7 @@ metadata: name: controller-manager namespace: system labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize spec: template: diff --git a/testdata/project-v4-with-deploy-image/config/default/metrics_service.yaml b/testdata/project-v4-multigroup-with-plugins/config/default/metrics_service.yaml similarity index 83% rename from testdata/project-v4-with-deploy-image/config/default/metrics_service.yaml rename to testdata/project-v4-multigroup-with-plugins/config/default/metrics_service.yaml index d774226430d..704d659ba50 100644 --- a/testdata/project-v4-with-deploy-image/config/default/metrics_service.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/default/metrics_service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-service namespace: system diff --git a/testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml b/testdata/project-v4-multigroup-with-plugins/config/default/webhookcainjection_patch.yaml similarity index 81% rename from testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml rename to testdata/project-v4-multigroup-with-plugins/config/default/webhookcainjection_patch.yaml index b2301beb6c6..2dc7f8c6c0e 100644 --- a/testdata/project-v4-with-deploy-image/config/default/webhookcainjection_patch.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/default/webhookcainjection_patch.yaml @@ -4,7 +4,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: mutating-webhook-configuration annotations: @@ -17,8 +17,8 @@ metadata: app.kubernetes.io/name: validatingwebhookconfiguration app.kubernetes.io/instance: validating-webhook-configuration app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: project-v4-with-deploy-image - app.kubernetes.io/part-of: project-v4-with-deploy-image + app.kubernetes.io/created-by: project-v4-multigroup-with-plugins + app.kubernetes.io/part-of: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: validating-webhook-configuration annotations: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/manager/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/manager/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/manager/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/manager/kustomization.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/manager/manager.yaml b/testdata/project-v4-multigroup-with-plugins/config/manager/manager.yaml similarity index 91% rename from testdata/project-v4-multigroup-with-deploy-image/config/manager/manager.yaml rename to testdata/project-v4-multigroup-with-plugins/config/manager/manager.yaml index 6059ca1e238..f1e76e514e8 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/manager/manager.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/manager/manager.yaml @@ -3,7 +3,7 @@ kind: Namespace metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: system --- @@ -14,7 +14,7 @@ metadata: namespace: system labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize spec: selector: @@ -65,6 +65,11 @@ spec: - --health-probe-bind-address=:8081 image: controller:latest name: manager + env: + - name: BUSYBOX_IMAGE + value: busybox:1.36.1 + - name: MEMCACHED_IMAGE + value: memcached:memcached:1.6.26-alpine3.19 securityContext: allowPrivilegeEscalation: false capabilities: diff --git a/testdata/project-v4-with-grafana/config/network-policy/allow-metrics-traffic.yaml b/testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-metrics-traffic.yaml similarity index 92% rename from testdata/project-v4-with-grafana/config/network-policy/allow-metrics-traffic.yaml rename to testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-metrics-traffic.yaml index 87772311883..3ecfbaef9b4 100644 --- a/testdata/project-v4-with-grafana/config/network-policy/allow-metrics-traffic.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-metrics-traffic.yaml @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: labels: - app.kubernetes.io/name: project-v4-with-grafana + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: allow-metrics-traffic namespace: system diff --git a/testdata/project-v4-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml b/testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-webhook-traffic.yaml similarity index 92% rename from testdata/project-v4-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml rename to testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-webhook-traffic.yaml index 81fdaf9fbb0..dfddc609676 100644 --- a/testdata/project-v4-with-deploy-image/config/network-policy/allow-webhook-traffic.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/network-policy/allow-webhook-traffic.yaml @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: allow-webhook-traffic namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/network-policy/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/network-policy/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/network-policy/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/network-policy/kustomization.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/prometheus/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/prometheus/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/prometheus/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/prometheus/kustomization.yaml diff --git a/testdata/project-v4-with-deploy-image/config/prometheus/monitor.yaml b/testdata/project-v4-multigroup-with-plugins/config/prometheus/monitor.yaml similarity index 95% rename from testdata/project-v4-with-deploy-image/config/prometheus/monitor.yaml rename to testdata/project-v4-multigroup-with-plugins/config/prometheus/monitor.yaml index c5a21a37e1d..59401d3eb91 100644 --- a/testdata/project-v4-with-deploy-image/config/prometheus/monitor.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/prometheus/monitor.yaml @@ -4,7 +4,7 @@ kind: ServiceMonitor metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-monitor namespace: system diff --git a/testdata/project-v4-multigroup/config/rbac/crew_captain_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_editor_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/crew_captain_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_editor_role.yaml index c6a33cbfbda..796bc0dd587 100644 --- a/testdata/project-v4-multigroup/config/rbac/crew_captain_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: crew-captain-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/crew_captain_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_viewer_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/crew_captain_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_viewer_role.yaml index 7d723490e56..6efc6d4b280 100644 --- a/testdata/project-v4-multigroup/config/rbac/crew_captain_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/crew_captain_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: crew-captain-viewer-role rules: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_editor_role.yaml similarity index 52% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_editor_role.yaml index 336f67a59bf..16229fc8a76 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/fiz_bar_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_editor_role.yaml @@ -1,16 +1,16 @@ -# permissions for end users to edit bars. +# permissions for end users to edit busyboxes. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize - name: fiz-bar-editor-role + name: example.com-busybox-editor-role rules: - apiGroups: - - fiz.testproject.org + - example.com.testproject.org resources: - - bars + - busyboxes verbs: - create - delete @@ -20,8 +20,8 @@ rules: - update - watch - apiGroups: - - fiz.testproject.org + - example.com.testproject.org resources: - - bars/status + - busyboxes/status verbs: - get diff --git a/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_viewer_role.yaml new file mode 100644 index 00000000000..e1af6615259 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_busybox_viewer_role.yaml @@ -0,0 +1,23 @@ +# permissions for end users to view busyboxes. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: project-v4-multigroup-with-plugins + app.kubernetes.io/managed-by: kustomize + name: example.com-busybox-viewer-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes + verbs: + - get + - list + - watch +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/status + verbs: + - get diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_editor_role.yaml similarity index 52% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_editor_role.yaml index d77c7e58169..88f94b2461d 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_editor_role.yaml @@ -1,16 +1,16 @@ -# permissions for end users to edit lakers. +# permissions for end users to edit memcacheds. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize - name: lakers-editor-role + name: example.com-memcached-editor-role rules: - apiGroups: - - testproject.org + - example.com.testproject.org resources: - - lakers + - memcacheds verbs: - create - delete @@ -20,8 +20,8 @@ rules: - update - watch - apiGroups: - - testproject.org + - example.com.testproject.org resources: - - lakers/status + - memcacheds/status verbs: - get diff --git a/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_viewer_role.yaml new file mode 100644 index 00000000000..7096a6a6d2f --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/example.com_memcached_viewer_role.yaml @@ -0,0 +1,23 @@ +# permissions for end users to view memcacheds. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: project-v4-multigroup-with-plugins + app.kubernetes.io/managed-by: kustomize + name: example.com-memcached-viewer-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds + verbs: + - get + - list + - watch +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds/status + verbs: + - get diff --git a/testdata/project-v4-multigroup/config/rbac/fiz_bar_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_editor_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/fiz_bar_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_editor_role.yaml index 6ce5d8f2ef9..13411ba8b7e 100644 --- a/testdata/project-v4-multigroup/config/rbac/fiz_bar_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: fiz-bar-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/fiz_bar_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_viewer_role.yaml similarity index 85% rename from testdata/project-v4-multigroup/config/rbac/fiz_bar_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_viewer_role.yaml index 744a0a955c0..f1e648ef097 100644 --- a/testdata/project-v4-multigroup/config/rbac/fiz_bar_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/fiz_bar_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: fiz-bar-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml similarity index 88% rename from testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml index 66fa7944f70..1b24df8bc53 100644 --- a/testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: foo.policy-healthcheckpolicy-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml index dff3ea7abc0..3dead6f26e3 100644 --- a/testdata/project-v4-multigroup/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo.policy_healthcheckpolicy_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: foo.policy-healthcheckpolicy-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/foo_bar_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_editor_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/foo_bar_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_editor_role.yaml index f05089941a4..85879eecbcf 100644 --- a/testdata/project-v4-multigroup/config/rbac/foo_bar_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: foo-bar-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/foo_bar_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_viewer_role.yaml similarity index 85% rename from testdata/project-v4-multigroup/config/rbac/foo_bar_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_viewer_role.yaml index eabf9ee517b..a3413719636 100644 --- a/testdata/project-v4-multigroup/config/rbac/foo_bar_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/foo_bar_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: foo-bar-viewer-role rules: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/kustomization.yaml similarity index 91% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/kustomization.yaml index 5bdd66e47ff..3c61dc1aeb4 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/kustomization.yaml @@ -22,6 +22,10 @@ resources: # default, aiding admins in cluster management. Those roles are # not used by the Project itself. You can comment the following lines # if you do not want those helpers be installed with your Project. +- example.com_busybox_editor_role.yaml +- example.com_busybox_viewer_role.yaml +- example.com_memcached_editor_role.yaml +- example.com_memcached_viewer_role.yaml - lakers_editor_role.yaml - lakers_viewer_role.yaml - fiz_bar_editor_role.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/lakers_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_editor_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/lakers_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_editor_role.yaml index d2ee17631dd..3da50c14ff8 100644 --- a/testdata/project-v4-multigroup/config/rbac/lakers_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: lakers-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/lakers_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_viewer_role.yaml similarity index 85% rename from testdata/project-v4-multigroup/config/rbac/lakers_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_viewer_role.yaml index 3097aa81c5e..232ef1e0f89 100644 --- a/testdata/project-v4-multigroup/config/rbac/lakers_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/lakers_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: lakers-viewer-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/leader_election_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role.yaml similarity index 89% rename from testdata/project-v4-with-deploy-image/config/rbac/leader_election_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role.yaml index 260a6f9e5db..9549e9e8afc 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/leader_election_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: leader-election-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/leader_election_role_binding.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role_binding.yaml similarity index 83% rename from testdata/project-v4-with-deploy-image/config/rbac/leader_election_role_binding.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role_binding.yaml index c3425c4bcc0..05f0dbe0941 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/leader_election_role_binding.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/leader_election_role_binding.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: leader-election-rolebinding roleRef: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_auth_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_auth_role.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_auth_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_auth_role.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_auth_role_binding.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_auth_role_binding.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_auth_role_binding.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_auth_role_binding.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_reader_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_reader_role.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/metrics_reader_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/metrics_reader_role.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/role.yaml similarity index 82% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/role.yaml index b3e54a59959..b72e5e0810b 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/role.yaml @@ -30,6 +30,21 @@ rules: - get - patch - update +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch - apiGroups: - crew.testproject.org resources: @@ -56,6 +71,35 @@ rules: - get - patch - update +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes + - memcacheds + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/finalizers + - memcacheds/finalizers + verbs: + - update +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/status + - memcacheds/status + verbs: + - get + - patch + - update - apiGroups: - fiz.testproject.org - foo.testproject.org diff --git a/testdata/project-v4-with-deploy-image/config/rbac/role_binding.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/role_binding.yaml similarity index 83% rename from testdata/project-v4-with-deploy-image/config/rbac/role_binding.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/role_binding.yaml index d0bc8dd159f..4dc562e9d2c 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/role_binding.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/role_binding.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: manager-rolebinding roleRef: diff --git a/testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_editor_role.yaml similarity index 88% rename from testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_editor_role.yaml index 1d372dccf66..179ef7c2f00 100644 --- a/testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: sea-creatures-kraken-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_viewer_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_viewer_role.yaml index a65c4916546..ba1ca466c85 100644 --- a/testdata/project-v4-multigroup/config/rbac/sea-creatures_kraken_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_kraken_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: sea-creatures-kraken-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_editor_role.yaml similarity index 88% rename from testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_editor_role.yaml index 77d2ff19c22..24d146e561e 100644 --- a/testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: sea-creatures-leviathan-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_viewer_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_viewer_role.yaml index e0344e4699b..01b698ed8bf 100644 --- a/testdata/project-v4-multigroup/config/rbac/sea-creatures_leviathan_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/sea-creatures_leviathan_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: sea-creatures-leviathan-viewer-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/service_account.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/service_account.yaml similarity index 70% rename from testdata/project-v4-with-deploy-image/config/rbac/service_account.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/service_account.yaml index 34cd64fa535..1bf80cdd862 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/service_account.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/service_account.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ServiceAccount metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager namespace: system diff --git a/testdata/project-v4-multigroup/config/rbac/ship_cruiser_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_editor_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/ship_cruiser_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_editor_role.yaml index 32a0bcaf91e..7f761bbe29a 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_cruiser_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-cruiser-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/ship_cruiser_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_viewer_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/ship_cruiser_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_viewer_role.yaml index 287ffcc397a..173adf61c78 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_cruiser_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_cruiser_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-cruiser-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/ship_destroyer_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_editor_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/ship_destroyer_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_editor_role.yaml index 8b0aa1da540..07891024559 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_destroyer_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-destroyer-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/ship_destroyer_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_viewer_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/ship_destroyer_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_viewer_role.yaml index 027ff57455a..9ddd515d49b 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_destroyer_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_destroyer_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-destroyer-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/ship_frigate_editor_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_editor_role.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/rbac/ship_frigate_editor_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_editor_role.yaml index d0b243c8886..29da45db91a 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_frigate_editor_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-frigate-editor-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/ship_frigate_viewer_role.yaml b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_viewer_role.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/ship_frigate_viewer_role.yaml rename to testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_viewer_role.yaml index f8d54802480..25ae44f07ea 100644 --- a/testdata/project-v4-multigroup/config/rbac/ship_frigate_viewer_role.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/rbac/ship_frigate_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: ship-frigate-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/samples/crew_v1_captain.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/crew_v1_captain.yaml similarity index 73% rename from testdata/project-v4-multigroup/config/samples/crew_v1_captain.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/crew_v1_captain.yaml index 0eed664c7cb..4b48232fa8c 100644 --- a/testdata/project-v4-multigroup/config/samples/crew_v1_captain.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/crew_v1_captain.yaml @@ -2,7 +2,7 @@ apiVersion: crew.testproject.org/v1 kind: Captain metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: captain-sample spec: diff --git a/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml new file mode 100644 index 00000000000..546f0da8c70 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml @@ -0,0 +1,11 @@ +apiVersion: example.com.testproject.org/v1alpha1 +kind: Busybox +metadata: + labels: + app.kubernetes.io/name: project-v4-multigroup-with-plugins + app.kubernetes.io/managed-by: kustomize + name: busybox-sample +spec: + # TODO(user): edit the following value to ensure the number + # of Pods/Instances your Operand must have on cluster + size: 1 diff --git a/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml new file mode 100644 index 00000000000..f4e11b26f96 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml @@ -0,0 +1,14 @@ +apiVersion: example.com.testproject.org/v1alpha1 +kind: Memcached +metadata: + labels: + app.kubernetes.io/name: project-v4-multigroup-with-plugins + app.kubernetes.io/managed-by: kustomize + name: memcached-sample +spec: + # TODO(user): edit the following value to ensure the number + # of Pods/Instances your Operand must have on cluster + size: 1 + + # TODO(user): edit the following value to ensure the container has the right port to be initialized + containerPort: 11211 diff --git a/testdata/project-v4-multigroup/config/samples/fiz_v1_bar.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/fiz_v1_bar.yaml similarity index 72% rename from testdata/project-v4-multigroup/config/samples/fiz_v1_bar.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/fiz_v1_bar.yaml index ded18d76876..c39b3f20bcb 100644 --- a/testdata/project-v4-multigroup/config/samples/fiz_v1_bar.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/fiz_v1_bar.yaml @@ -2,7 +2,7 @@ apiVersion: fiz.testproject.org/v1 kind: Bar metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: bar-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/foo.policy_v1_healthcheckpolicy.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/foo.policy_v1_healthcheckpolicy.yaml similarity index 76% rename from testdata/project-v4-multigroup/config/samples/foo.policy_v1_healthcheckpolicy.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/foo.policy_v1_healthcheckpolicy.yaml index 945fe8b48ad..2e04bd8b357 100644 --- a/testdata/project-v4-multigroup/config/samples/foo.policy_v1_healthcheckpolicy.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/foo.policy_v1_healthcheckpolicy.yaml @@ -2,7 +2,7 @@ apiVersion: foo.policy.testproject.org/v1 kind: HealthCheckPolicy metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: healthcheckpolicy-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/foo_v1_bar.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/foo_v1_bar.yaml similarity index 72% rename from testdata/project-v4-multigroup/config/samples/foo_v1_bar.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/foo_v1_bar.yaml index 6de418e33d7..9f5017b6397 100644 --- a/testdata/project-v4-multigroup/config/samples/foo_v1_bar.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/foo_v1_bar.yaml @@ -2,7 +2,7 @@ apiVersion: foo.testproject.org/v1 kind: Bar metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: bar-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/kustomization.yaml similarity index 83% rename from testdata/project-v4-multigroup/config/samples/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/kustomization.yaml index f5e9802fed3..c005ab32db6 100644 --- a/testdata/project-v4-multigroup/config/samples/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/kustomization.yaml @@ -10,4 +10,6 @@ resources: - foo_v1_bar.yaml - fiz_v1_bar.yaml - v1_lakers.yaml +- example.com_v1alpha1_memcached.yaml +- example.com_v1alpha1_busybox.yaml # +kubebuilder:scaffold:manifestskustomizesamples diff --git a/testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta1_kraken.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta1_kraken.yaml similarity index 74% rename from testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta1_kraken.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta1_kraken.yaml index 0e0453d7c80..a8b96f8693a 100644 --- a/testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta1_kraken.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta1_kraken.yaml @@ -2,7 +2,7 @@ apiVersion: sea-creatures.testproject.org/v1beta1 kind: Kraken metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: kraken-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta2_leviathan.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta2_leviathan.yaml similarity index 75% rename from testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta2_leviathan.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta2_leviathan.yaml index 5d2125ed9b7..d7fc5483410 100644 --- a/testdata/project-v4-multigroup/config/samples/sea-creatures_v1beta2_leviathan.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/sea-creatures_v1beta2_leviathan.yaml @@ -2,7 +2,7 @@ apiVersion: sea-creatures.testproject.org/v1beta2 kind: Leviathan metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: leviathan-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/ship_v1_destroyer.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1_destroyer.yaml similarity index 73% rename from testdata/project-v4-multigroup/config/samples/ship_v1_destroyer.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1_destroyer.yaml index 946dee59890..f886969d458 100644 --- a/testdata/project-v4-multigroup/config/samples/ship_v1_destroyer.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1_destroyer.yaml @@ -2,7 +2,7 @@ apiVersion: ship.testproject.org/v1 kind: Destroyer metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: destroyer-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/ship_v1beta1_frigate.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1beta1_frigate.yaml similarity index 74% rename from testdata/project-v4-multigroup/config/samples/ship_v1beta1_frigate.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1beta1_frigate.yaml index b758b075bcf..ab9a3d0bf59 100644 --- a/testdata/project-v4-multigroup/config/samples/ship_v1beta1_frigate.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v1beta1_frigate.yaml @@ -2,7 +2,7 @@ apiVersion: ship.testproject.org/v1beta1 kind: Frigate metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: frigate-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/ship_v2alpha1_cruiser.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v2alpha1_cruiser.yaml similarity index 74% rename from testdata/project-v4-multigroup/config/samples/ship_v2alpha1_cruiser.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/ship_v2alpha1_cruiser.yaml index 58d0c89226b..d0fffb70ad3 100644 --- a/testdata/project-v4-multigroup/config/samples/ship_v2alpha1_cruiser.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/ship_v2alpha1_cruiser.yaml @@ -2,7 +2,7 @@ apiVersion: ship.testproject.org/v2alpha1 kind: Cruiser metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: cruiser-sample spec: diff --git a/testdata/project-v4-multigroup/config/samples/v1_lakers.yaml b/testdata/project-v4-multigroup-with-plugins/config/samples/v1_lakers.yaml similarity index 72% rename from testdata/project-v4-multigroup/config/samples/v1_lakers.yaml rename to testdata/project-v4-multigroup-with-plugins/config/samples/v1_lakers.yaml index 50825eb1a12..876a5ffa5ec 100644 --- a/testdata/project-v4-multigroup/config/samples/v1_lakers.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/samples/v1_lakers.yaml @@ -2,7 +2,7 @@ apiVersion: testproject.org/v1 kind: Lakers metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: lakers-sample spec: diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/kustomization.yaml b/testdata/project-v4-multigroup-with-plugins/config/webhook/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/webhook/kustomization.yaml rename to testdata/project-v4-multigroup-with-plugins/config/webhook/kustomization.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/kustomizeconfig.yaml b/testdata/project-v4-multigroup-with-plugins/config/webhook/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/webhook/kustomizeconfig.yaml rename to testdata/project-v4-multigroup-with-plugins/config/webhook/kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/manifests.yaml b/testdata/project-v4-multigroup-with-plugins/config/webhook/manifests.yaml similarity index 86% rename from testdata/project-v4-multigroup-with-deploy-image/config/webhook/manifests.yaml rename to testdata/project-v4-multigroup-with-plugins/config/webhook/manifests.yaml index 62374002227..8537370eb6e 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/webhook/manifests.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/webhook/manifests.yaml @@ -90,6 +90,26 @@ webhooks: resources: - captains sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-example-com-testproject-org-v1alpha1-memcached + failurePolicy: Fail + name: vmemcached.kb.io + rules: + - apiGroups: + - example.com.testproject.org + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - memcacheds + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/testdata/project-v4-with-deploy-image/config/webhook/service.yaml b/testdata/project-v4-multigroup-with-plugins/config/webhook/service.yaml similarity index 80% rename from testdata/project-v4-with-deploy-image/config/webhook/service.yaml rename to testdata/project-v4-multigroup-with-plugins/config/webhook/service.yaml index 8501804b4d3..1204bff3b6d 100644 --- a/testdata/project-v4-with-deploy-image/config/webhook/service.yaml +++ b/testdata/project-v4-multigroup-with-plugins/config/webhook/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins app.kubernetes.io/managed-by: kustomize name: webhook-service namespace: system diff --git a/testdata/project-v4-multigroup-with-deploy-image/dist/install.yaml b/testdata/project-v4-multigroup-with-plugins/dist/install.yaml similarity index 63% rename from testdata/project-v4-multigroup-with-deploy-image/dist/install.yaml rename to testdata/project-v4-multigroup-with-plugins/dist/install.yaml index 063d8d0691a..eff089a2d54 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/dist/install.yaml +++ b/testdata/project-v4-multigroup-with-plugins/dist/install.yaml @@ -3,9 +3,9 @@ kind: Namespace metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins control-plane: controller-manager - name: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-system --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -117,6 +117,122 @@ spec: --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + name: busyboxes.example.com.testproject.org +spec: + group: example.com.testproject.org + names: + kind: Busybox + listKind: BusyboxList + plural: busyboxes + singular: busybox + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Busybox is the Schema for the busyboxes API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: BusyboxSpec defines the desired state of Busybox + properties: + size: + description: |- + Size defines the number of Busybox instances + The following markers will use OpenAPI v3 schema to validate the value + More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + format: int32 + maximum: 3 + minimum: 1 + type: integer + type: object + status: + description: BusyboxStatus defines the observed state of Busybox + properties: + conditions: + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.1 @@ -127,8 +243,8 @@ spec: webhook: clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -191,8 +307,8 @@ spec: webhook: clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -255,8 +371,8 @@ spec: webhook: clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -319,8 +435,8 @@ spec: webhook: clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -491,8 +607,8 @@ spec: webhook: clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -597,23 +713,154 @@ spec: subresources: status: {} --- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + name: memcacheds.example.com.testproject.org +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system + path: /convert + conversionReviewVersions: + - v1 + group: example.com.testproject.org + names: + kind: Memcached + listKind: MemcachedList + plural: memcacheds + singular: memcached + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Memcached is the Schema for the memcacheds API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: MemcachedSpec defines the desired state of Memcached + properties: + containerPort: + description: Port defines the port that will be used to init the container + with the image + format: int32 + type: integer + size: + description: |- + Size defines the number of Memcached instances + The following markers will use OpenAPI v3 schema to validate the value + More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + format: int32 + maximum: 3 + minimum: 1 + type: integer + type: object + status: + description: MemcachedStatus defines the observed state of Memcached + properties: + conditions: + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- apiVersion: v1 kind: ServiceAccount metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-controller-manager - namespace: project-v4-multigroup-with-deploy-image-system + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-controller-manager + namespace: project-v4-multigroup-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-leader-election-role - namespace: project-v4-multigroup-with-deploy-image-system + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-leader-election-role + namespace: project-v4-multigroup-with-plugins-system rules: - apiGroups: - "" @@ -652,8 +899,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-crew-captain-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-crew-captain-editor-role rules: - apiGroups: - crew.testproject.org @@ -679,8 +926,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-crew-captain-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-crew-captain-viewer-role rules: - apiGroups: - crew.testproject.org @@ -702,8 +949,108 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-fiz-bar-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-example.com-busybox-editor-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-example.com-busybox-viewer-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes + verbs: + - get + - list + - watch +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-example.com-memcached-editor-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-example.com-memcached-viewer-role +rules: +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds + verbs: + - get + - list + - watch +- apiGroups: + - example.com.testproject.org + resources: + - memcacheds/status + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-fiz-bar-editor-role rules: - apiGroups: - fiz.testproject.org @@ -729,8 +1076,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-fiz-bar-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-fiz-bar-viewer-role rules: - apiGroups: - fiz.testproject.org @@ -752,8 +1099,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-foo-bar-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-foo-bar-editor-role rules: - apiGroups: - foo.testproject.org @@ -779,8 +1126,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-foo-bar-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-foo-bar-viewer-role rules: - apiGroups: - foo.testproject.org @@ -802,8 +1149,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-foo.policy-healthcheckpolicy-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-foo.policy-healthcheckpolicy-editor-role rules: - apiGroups: - foo.policy.testproject.org @@ -829,8 +1176,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-foo.policy-healthcheckpolicy-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-foo.policy-healthcheckpolicy-viewer-role rules: - apiGroups: - foo.policy.testproject.org @@ -852,8 +1199,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-lakers-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-lakers-editor-role rules: - apiGroups: - testproject.org @@ -879,8 +1226,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-lakers-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-lakers-viewer-role rules: - apiGroups: - testproject.org @@ -900,7 +1247,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-multigroup-with-deploy-image-manager-role + name: project-v4-multigroup-with-plugins-manager-role rules: - apiGroups: - apps @@ -928,6 +1275,21 @@ rules: - get - patch - update +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch - apiGroups: - crew.testproject.org resources: @@ -954,6 +1316,35 @@ rules: - get - patch - update +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes + - memcacheds + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/finalizers + - memcacheds/finalizers + verbs: + - update +- apiGroups: + - example.com.testproject.org + resources: + - busyboxes/status + - memcacheds/status + verbs: + - get + - patch + - update - apiGroups: - fiz.testproject.org - foo.testproject.org @@ -1100,7 +1491,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-multigroup-with-deploy-image-metrics-auth-role + name: project-v4-multigroup-with-plugins-metrics-auth-role rules: - apiGroups: - authentication.k8s.io @@ -1118,7 +1509,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-multigroup-with-deploy-image-metrics-reader + name: project-v4-multigroup-with-plugins-metrics-reader rules: - nonResourceURLs: - /metrics @@ -1130,8 +1521,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-sea-creatures-kraken-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-sea-creatures-kraken-editor-role rules: - apiGroups: - sea-creatures.testproject.org @@ -1157,8 +1548,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-sea-creatures-kraken-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-sea-creatures-kraken-viewer-role rules: - apiGroups: - sea-creatures.testproject.org @@ -1180,8 +1571,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-sea-creatures-leviathan-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-sea-creatures-leviathan-editor-role rules: - apiGroups: - sea-creatures.testproject.org @@ -1207,8 +1598,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-sea-creatures-leviathan-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-sea-creatures-leviathan-viewer-role rules: - apiGroups: - sea-creatures.testproject.org @@ -1230,8 +1621,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-cruiser-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-cruiser-editor-role rules: - apiGroups: - ship.testproject.org @@ -1257,8 +1648,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-cruiser-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-cruiser-viewer-role rules: - apiGroups: - ship.testproject.org @@ -1280,8 +1671,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-destroyer-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-destroyer-editor-role rules: - apiGroups: - ship.testproject.org @@ -1307,8 +1698,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-destroyer-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-destroyer-viewer-role rules: - apiGroups: - ship.testproject.org @@ -1330,8 +1721,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-frigate-editor-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-frigate-editor-role rules: - apiGroups: - ship.testproject.org @@ -1357,8 +1748,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-ship-frigate-viewer-role + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-ship-frigate-viewer-role rules: - apiGroups: - ship.testproject.org @@ -1380,56 +1771,56 @@ kind: RoleBinding metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-leader-election-rolebinding - namespace: project-v4-multigroup-with-deploy-image-system + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-leader-election-rolebinding + namespace: project-v4-multigroup-with-plugins-system roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: project-v4-multigroup-with-deploy-image-leader-election-role + name: project-v4-multigroup-with-plugins-leader-election-role subjects: - kind: ServiceAccount - name: project-v4-multigroup-with-deploy-image-controller-manager - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-controller-manager + namespace: project-v4-multigroup-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-manager-rolebinding + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-manager-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: project-v4-multigroup-with-deploy-image-manager-role + name: project-v4-multigroup-with-plugins-manager-role subjects: - kind: ServiceAccount - name: project-v4-multigroup-with-deploy-image-controller-manager - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-controller-manager + namespace: project-v4-multigroup-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: project-v4-multigroup-with-deploy-image-metrics-auth-rolebinding + name: project-v4-multigroup-with-plugins-metrics-auth-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: project-v4-multigroup-with-deploy-image-metrics-auth-role + name: project-v4-multigroup-with-plugins-metrics-auth-role subjects: - kind: ServiceAccount - name: project-v4-multigroup-with-deploy-image-controller-manager - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-controller-manager + namespace: project-v4-multigroup-with-plugins-system --- apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins control-plane: controller-manager - name: project-v4-multigroup-with-deploy-image-controller-manager-metrics-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-controller-manager-metrics-service + namespace: project-v4-multigroup-with-plugins-system spec: ports: - name: https @@ -1444,9 +1835,9 @@ kind: Service metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + app.kubernetes.io/name: project-v4-multigroup-with-plugins + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system spec: ports: - port: 443 @@ -1460,10 +1851,10 @@ kind: Deployment metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup-with-deploy-image + app.kubernetes.io/name: project-v4-multigroup-with-plugins control-plane: controller-manager - name: project-v4-multigroup-with-deploy-image-controller-manager - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-controller-manager + namespace: project-v4-multigroup-with-plugins-system spec: replicas: 1 selector: @@ -1483,6 +1874,11 @@ spec: - --health-probe-bind-address=:8081 command: - /manager + env: + - name: BUSYBOX_IMAGE + value: busybox:1.36.1 + - name: MEMCACHED_IMAGE + value: memcached:memcached:1.6.26-alpine3.19 image: controller:latest livenessProbe: httpGet: @@ -1519,7 +1915,7 @@ spec: readOnly: true securityContext: runAsNonRoot: true - serviceAccountName: project-v4-multigroup-with-deploy-image-controller-manager + serviceAccountName: project-v4-multigroup-with-plugins-controller-manager terminationGracePeriodSeconds: 10 volumes: - name: cert @@ -1530,14 +1926,14 @@ spec: apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: - name: project-v4-multigroup-with-deploy-image-mutating-webhook-configuration + name: project-v4-multigroup-with-plugins-mutating-webhook-configuration webhooks: - admissionReviewVersions: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /mutate-crew-testproject-org-v1-captain failurePolicy: Fail name: mcaptain.kb.io @@ -1556,8 +1952,8 @@ webhooks: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /mutate-ship-testproject-org-v1-destroyer failurePolicy: Fail name: mdestroyer.kb.io @@ -1576,8 +1972,8 @@ webhooks: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /mutate-testproject-org-v1-lakers failurePolicy: Fail name: mlakers.kb.io @@ -1596,14 +1992,14 @@ webhooks: apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: - name: project-v4-multigroup-with-deploy-image-validating-webhook-configuration + name: project-v4-multigroup-with-plugins-validating-webhook-configuration webhooks: - admissionReviewVersions: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /validate-crew-testproject-org-v1-captain failurePolicy: Fail name: vcaptain.kb.io @@ -1622,8 +2018,28 @@ webhooks: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system + path: /validate-example-com-testproject-org-v1alpha1-memcached + failurePolicy: Fail + name: vmemcached.kb.io + rules: + - apiGroups: + - example.com.testproject.org + apiVersions: + - v1alpha1 + operations: + - CREATE + - UPDATE + resources: + - memcacheds + sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /validate-ship-testproject-org-v2alpha1-cruiser failurePolicy: Fail name: vcruiser.kb.io @@ -1642,8 +2058,8 @@ webhooks: - v1 clientConfig: service: - name: project-v4-multigroup-with-deploy-image-webhook-service - namespace: project-v4-multigroup-with-deploy-image-system + name: project-v4-multigroup-with-plugins-webhook-service + namespace: project-v4-multigroup-with-plugins-system path: /validate-testproject-org-v1-lakers failurePolicy: Fail name: vlakers.kb.io diff --git a/testdata/project-v4-multigroup-with-deploy-image/go.mod b/testdata/project-v4-multigroup-with-plugins/go.mod similarity index 99% rename from testdata/project-v4-multigroup-with-deploy-image/go.mod rename to testdata/project-v4-multigroup-with-plugins/go.mod index 8a7e66e7e17..844feee23d9 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/go.mod +++ b/testdata/project-v4-multigroup-with-plugins/go.mod @@ -1,4 +1,4 @@ -module sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image +module sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins go 1.22.0 diff --git a/testdata/project-v4-with-grafana/grafana/controller-resources-metrics.json b/testdata/project-v4-multigroup-with-plugins/grafana/controller-resources-metrics.json similarity index 100% rename from testdata/project-v4-with-grafana/grafana/controller-resources-metrics.json rename to testdata/project-v4-multigroup-with-plugins/grafana/controller-resources-metrics.json diff --git a/testdata/project-v4-with-grafana/grafana/controller-runtime-metrics.json b/testdata/project-v4-multigroup-with-plugins/grafana/controller-runtime-metrics.json similarity index 100% rename from testdata/project-v4-with-grafana/grafana/controller-runtime-metrics.json rename to testdata/project-v4-multigroup-with-plugins/grafana/controller-runtime-metrics.json diff --git a/testdata/project-v4-with-grafana/grafana/custom-metrics/config.yaml b/testdata/project-v4-multigroup-with-plugins/grafana/custom-metrics/config.yaml similarity index 100% rename from testdata/project-v4-with-grafana/grafana/custom-metrics/config.yaml rename to testdata/project-v4-multigroup-with-plugins/grafana/custom-metrics/config.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/hack/boilerplate.go.txt b/testdata/project-v4-multigroup-with-plugins/hack/boilerplate.go.txt similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/hack/boilerplate.go.txt rename to testdata/project-v4-multigroup-with-plugins/hack/boilerplate.go.txt diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/deployment_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/apps/deployment_controller.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/deployment_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/apps/deployment_controller.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/deployment_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/apps/deployment_controller_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/deployment_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/apps/deployment_controller_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/apps/suite_test.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/apps/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/apps/suite_test.go diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller.go index d9bea97e751..924564ab3c2 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/crew/v1" ) // CaptainReconciler reconciles a Captain object diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller_test.go index b2be385dd91..99056904a9d 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/captain_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/captain_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/crew/v1" ) var _ = Describe("Captain Controller", func() { diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/suite_test.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/crew/suite_test.go index 6278a1a114a..7550b6a6919 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/crew/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/crew/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/crew/v1" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/crew/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller.go new file mode 100644 index 00000000000..1df858c2c02 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller.go @@ -0,0 +1,442 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package examplecom + +import ( + "context" + "fmt" + "os" + "strings" + "time" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/log" + + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" +) + +const busyboxFinalizer = "example.com.testproject.org/finalizer" + +// Definitions to manage status conditions +const ( + // typeAvailableBusybox represents the status of the Deployment reconciliation + typeAvailableBusybox = "Available" + // typeDegradedBusybox represents the status used when the custom resource is deleted and the finalizer operations are yet to occur. + typeDegradedBusybox = "Degraded" +) + +// BusyboxReconciler reconciles a Busybox object +type BusyboxReconciler struct { + client.Client + Scheme *runtime.Scheme + Recorder record.EventRecorder +} + +// The following markers are used to generate the rules permissions (RBAC) on config/rbac using controller-gen +// when the command is executed. +// To know more about markers see: https://book.kubebuilder.io/reference/markers.html + +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=busyboxes,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=busyboxes/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=busyboxes/finalizers,verbs=update +// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch +// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// It is essential for the controller's reconciliation loop to be idempotent. By following the Operator +// pattern you will create Controllers which provide a reconcile function +// responsible for synchronizing resources until the desired state is reached on the cluster. +// Breaking this recommendation goes against the design principles of controller-runtime. +// and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. +// For further info: +// - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ +// - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile +func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := log.FromContext(ctx) + + // Fetch the Busybox instance + // The purpose is check if the Custom Resource for the Kind Busybox + // is applied on the cluster if not we return nil to stop the reconciliation + busybox := &examplecomv1alpha1.Busybox{} + err := r.Get(ctx, req.NamespacedName, busybox) + if err != nil { + if apierrors.IsNotFound(err) { + // If the custom resource is not found then it usually means that it was deleted or not created + // In this way, we will stop the reconciliation + log.Info("busybox resource not found. Ignoring since object must be deleted") + return ctrl.Result{}, nil + } + // Error reading the object - requeue the request. + log.Error(err, "Failed to get busybox") + return ctrl.Result{}, err + } + + // Let's just set the status as Unknown when no status is available + if busybox.Status.Conditions == nil || len(busybox.Status.Conditions) == 0 { + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeAvailableBusybox, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"}) + if err = r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + // Let's re-fetch the busybox Custom Resource after updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + // if we try to update it again in the following operations + if err := r.Get(ctx, req.NamespacedName, busybox); err != nil { + log.Error(err, "Failed to re-fetch busybox") + return ctrl.Result{}, err + } + } + + // Let's add a finalizer. Then, we can define some operations which should + // occur before the custom resource is deleted. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers + if !controllerutil.ContainsFinalizer(busybox, busyboxFinalizer) { + log.Info("Adding Finalizer for Busybox") + if ok := controllerutil.AddFinalizer(busybox, busyboxFinalizer); !ok { + log.Error(err, "Failed to add finalizer into the custom resource") + return ctrl.Result{Requeue: true}, nil + } + + if err = r.Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update custom resource to add finalizer") + return ctrl.Result{}, err + } + } + + // Check if the Busybox instance is marked to be deleted, which is + // indicated by the deletion timestamp being set. + isBusyboxMarkedToBeDeleted := busybox.GetDeletionTimestamp() != nil + if isBusyboxMarkedToBeDeleted { + if controllerutil.ContainsFinalizer(busybox, busyboxFinalizer) { + log.Info("Performing Finalizer Operations for Busybox before delete CR") + + // Let's add here a status "Downgrade" to reflect that this resource began its process to be terminated. + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeDegradedBusybox, + Status: metav1.ConditionUnknown, Reason: "Finalizing", + Message: fmt.Sprintf("Performing finalizer operations for the custom resource: %s ", busybox.Name)}) + + if err := r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + // Perform all operations required before removing the finalizer and allow + // the Kubernetes API to remove the custom resource. + r.doFinalizerOperationsForBusybox(busybox) + + // TODO(user): If you add operations to the doFinalizerOperationsForBusybox method + // then you need to ensure that all worked fine before deleting and updating the Downgrade status + // otherwise, you should requeue here. + + // Re-fetch the busybox Custom Resource before updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + if err := r.Get(ctx, req.NamespacedName, busybox); err != nil { + log.Error(err, "Failed to re-fetch busybox") + return ctrl.Result{}, err + } + + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeDegradedBusybox, + Status: metav1.ConditionTrue, Reason: "Finalizing", + Message: fmt.Sprintf("Finalizer operations for custom resource %s name were successfully accomplished", busybox.Name)}) + + if err := r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + log.Info("Removing Finalizer for Busybox after successfully perform the operations") + if ok := controllerutil.RemoveFinalizer(busybox, busyboxFinalizer); !ok { + log.Error(err, "Failed to remove finalizer for Busybox") + return ctrl.Result{Requeue: true}, nil + } + + if err := r.Update(ctx, busybox); err != nil { + log.Error(err, "Failed to remove finalizer for Busybox") + return ctrl.Result{}, err + } + } + return ctrl.Result{}, nil + } + + // Check if the deployment already exists, if not create a new one + found := &appsv1.Deployment{} + err = r.Get(ctx, types.NamespacedName{Name: busybox.Name, Namespace: busybox.Namespace}, found) + if err != nil && apierrors.IsNotFound(err) { + // Define a new deployment + dep, err := r.deploymentForBusybox(busybox) + if err != nil { + log.Error(err, "Failed to define new Deployment resource for Busybox") + + // The following implementation will update the status + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeAvailableBusybox, + Status: metav1.ConditionFalse, Reason: "Reconciling", + Message: fmt.Sprintf("Failed to create Deployment for the custom resource (%s): (%s)", busybox.Name, err)}) + + if err := r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, err + } + + log.Info("Creating a new Deployment", + "Deployment.Namespace", dep.Namespace, "Deployment.Name", dep.Name) + if err = r.Create(ctx, dep); err != nil { + log.Error(err, "Failed to create new Deployment", + "Deployment.Namespace", dep.Namespace, "Deployment.Name", dep.Name) + return ctrl.Result{}, err + } + + // Deployment created successfully + // We will requeue the reconciliation so that we can ensure the state + // and move forward for the next operations + return ctrl.Result{RequeueAfter: time.Minute}, nil + } else if err != nil { + log.Error(err, "Failed to get Deployment") + // Let's return the error for the reconciliation be re-trigged again + return ctrl.Result{}, err + } + + // The CRD API defines that the Busybox type have a BusyboxSpec.Size field + // to set the quantity of Deployment instances to the desired state on the cluster. + // Therefore, the following code will ensure the Deployment size is the same as defined + // via the Size spec of the Custom Resource which we are reconciling. + size := busybox.Spec.Size + if *found.Spec.Replicas != size { + found.Spec.Replicas = &size + if err = r.Update(ctx, found); err != nil { + log.Error(err, "Failed to update Deployment", + "Deployment.Namespace", found.Namespace, "Deployment.Name", found.Name) + + // Re-fetch the busybox Custom Resource before updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + if err := r.Get(ctx, req.NamespacedName, busybox); err != nil { + log.Error(err, "Failed to re-fetch busybox") + return ctrl.Result{}, err + } + + // The following implementation will update the status + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeAvailableBusybox, + Status: metav1.ConditionFalse, Reason: "Resizing", + Message: fmt.Sprintf("Failed to update the size for the custom resource (%s): (%s)", busybox.Name, err)}) + + if err := r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, err + } + + // Now, that we update the size we want to requeue the reconciliation + // so that we can ensure that we have the latest state of the resource before + // update. Also, it will help ensure the desired state on the cluster + return ctrl.Result{Requeue: true}, nil + } + + // The following implementation will update the status + meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeAvailableBusybox, + Status: metav1.ConditionTrue, Reason: "Reconciling", + Message: fmt.Sprintf("Deployment for custom resource (%s) with %d replicas created successfully", busybox.Name, size)}) + + if err := r.Status().Update(ctx, busybox); err != nil { + log.Error(err, "Failed to update Busybox status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, nil +} + +// finalizeBusybox will perform the required operations before delete the CR. +func (r *BusyboxReconciler) doFinalizerOperationsForBusybox(cr *examplecomv1alpha1.Busybox) { + // TODO(user): Add the cleanup steps that the operator + // needs to do before the CR can be deleted. Examples + // of finalizers include performing backups and deleting + // resources that are not owned by this CR, like a PVC. + + // Note: It is not recommended to use finalizers with the purpose of deleting resources which are + // created and managed in the reconciliation. These ones, such as the Deployment created on this reconcile, + // are defined as dependent of the custom resource. See that we use the method ctrl.SetControllerReference. + // to set the ownerRef which means that the Deployment will be deleted by the Kubernetes API. + // More info: https://kubernetes.io/docs/tasks/administer-cluster/use-cascading-deletion/ + + // The following implementation will raise an event + r.Recorder.Event(cr, "Warning", "Deleting", + fmt.Sprintf("Custom Resource %s is being deleted from the namespace %s", + cr.Name, + cr.Namespace)) +} + +// deploymentForBusybox returns a Busybox Deployment object +func (r *BusyboxReconciler) deploymentForBusybox( + busybox *examplecomv1alpha1.Busybox) (*appsv1.Deployment, error) { + ls := labelsForBusybox() + replicas := busybox.Spec.Size + + // Get the Operand image + image, err := imageForBusybox() + if err != nil { + return nil, err + } + + dep := &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: busybox.Name, + Namespace: busybox.Namespace, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: &replicas, + Selector: &metav1.LabelSelector{ + MatchLabels: ls, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: ls, + }, + Spec: corev1.PodSpec{ + // TODO(user): Uncomment the following code to configure the nodeAffinity expression + // according to the platforms which are supported by your solution. It is considered + // best practice to support multiple architectures. build your manager image using the + // makefile target docker-buildx. Also, you can use docker manifest inspect + // to check what are the platforms supported. + // More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity + // Affinity: &corev1.Affinity{ + // NodeAffinity: &corev1.NodeAffinity{ + // RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ + // NodeSelectorTerms: []corev1.NodeSelectorTerm{ + // { + // MatchExpressions: []corev1.NodeSelectorRequirement{ + // { + // Key: "kubernetes.io/arch", + // Operator: "In", + // Values: []string{"amd64", "arm64", "ppc64le", "s390x"}, + // }, + // { + // Key: "kubernetes.io/os", + // Operator: "In", + // Values: []string{"linux"}, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + SecurityContext: &corev1.PodSecurityContext{ + RunAsNonRoot: &[]bool{true}[0], + // IMPORTANT: seccomProfile was introduced with Kubernetes 1.19 + // If you are looking for to produce solutions to be supported + // on lower versions you must remove this option. + SeccompProfile: &corev1.SeccompProfile{ + Type: corev1.SeccompProfileTypeRuntimeDefault, + }, + }, + Containers: []corev1.Container{{ + Image: image, + Name: "busybox", + ImagePullPolicy: corev1.PullIfNotPresent, + // Ensure restrictive context for the container + // More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted + SecurityContext: &corev1.SecurityContext{ + RunAsNonRoot: &[]bool{true}[0], + AllowPrivilegeEscalation: &[]bool{false}[0], + Capabilities: &corev1.Capabilities{ + Drop: []corev1.Capability{ + "ALL", + }, + }, + }, + }}, + }, + }, + }, + } + + // Set the ownerRef for the Deployment + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/ + if err := ctrl.SetControllerReference(busybox, dep, r.Scheme); err != nil { + return nil, err + } + return dep, nil +} + +// labelsForBusybox returns the labels for selecting the resources +// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ +func labelsForBusybox() map[string]string { + var imageTag string + image, err := imageForBusybox() + if err == nil { + imageTag = strings.Split(image, ":")[1] + } + return map[string]string{"app.kubernetes.io/name": "project-v4-multigroup-with-plugins", + "app.kubernetes.io/version": imageTag, + "app.kubernetes.io/managed-by": "BusyboxController", + } +} + +// imageForBusybox gets the Operand image which is managed by this controller +// from the BUSYBOX_IMAGE environment variable defined in the config/manager/manager.yaml +func imageForBusybox() (string, error) { + var imageEnvVar = "BUSYBOX_IMAGE" + image, found := os.LookupEnv(imageEnvVar) + if !found { + return "", fmt.Errorf("Unable to find %s environment variable with the image", imageEnvVar) + } + return image, nil +} + +// SetupWithManager sets up the controller with the Manager. +// The whole idea is to be watching the resources that matter for the controller. +// When a resource that the controller is interested in changes, the Watch triggers +// the controller’s reconciliation loop, ensuring that the actual state of the resource +// matches the desired state as defined in the controller’s logic. +// +// Notice how we configured the Manager to monitor events such as the creation, update, +// or deletion of a Custom Resource (CR) of the Busybox kind, as well as any changes +// to the Deployment that the controller manages and owns. +func (r *BusyboxReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + // Watch the Busybox CR(s) and trigger reconciliation whenever it + // is created, updated, or deleted + For(&examplecomv1alpha1.Busybox{}). + // Watch the Deployment managed by the BusyboxReconciler. If any changes occur to the Deployment + // owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster + // state aligns with the desired state. See that the ownerRef was set when the Deployment was created. + Owns(&appsv1.Deployment{}). + Complete(r) +} diff --git a/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller_test.go new file mode 100644 index 00000000000..4bdc2cb6845 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/busybox_controller_test.go @@ -0,0 +1,153 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package examplecom + +import ( + "context" + "fmt" + "os" + "time" + + //nolint:golint + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" +) + +var _ = Describe("Busybox controller", func() { + Context("Busybox controller test", func() { + + const BusyboxName = "test-busybox" + + ctx := context.Background() + + namespace := &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: BusyboxName, + Namespace: BusyboxName, + }, + } + + typeNamespacedName := types.NamespacedName{ + Name: BusyboxName, + Namespace: BusyboxName, + } + busybox := &examplecomv1alpha1.Busybox{} + + BeforeEach(func() { + By("Creating the Namespace to perform the tests") + err := k8sClient.Create(ctx, namespace) + Expect(err).To(Not(HaveOccurred())) + + By("Setting the Image ENV VAR which stores the Operand image") + err = os.Setenv("BUSYBOX_IMAGE", "example.com/image:test") + Expect(err).To(Not(HaveOccurred())) + + By("creating the custom resource for the Kind Busybox") + err = k8sClient.Get(ctx, typeNamespacedName, busybox) + if err != nil && errors.IsNotFound(err) { + // Let's mock our custom resource at the same way that we would + // apply on the cluster the manifest under config/samples + busybox := &examplecomv1alpha1.Busybox{ + ObjectMeta: metav1.ObjectMeta{ + Name: BusyboxName, + Namespace: namespace.Name, + }, + Spec: examplecomv1alpha1.BusyboxSpec{ + Size: 1, + }, + } + + err = k8sClient.Create(ctx, busybox) + Expect(err).To(Not(HaveOccurred())) + } + }) + + AfterEach(func() { + By("removing the custom resource for the Kind Busybox") + found := &examplecomv1alpha1.Busybox{} + err := k8sClient.Get(ctx, typeNamespacedName, found) + Expect(err).To(Not(HaveOccurred())) + + Eventually(func() error { + return k8sClient.Delete(context.TODO(), found) + }, 2*time.Minute, time.Second).Should(Succeed()) + + // TODO(user): Attention if you improve this code by adding other context test you MUST + // be aware of the current delete namespace limitations. + // More info: https://book.kubebuilder.io/reference/envtest.html#testing-considerations + By("Deleting the Namespace to perform the tests") + _ = k8sClient.Delete(ctx, namespace) + + By("Removing the Image ENV VAR which stores the Operand image") + _ = os.Unsetenv("BUSYBOX_IMAGE") + }) + + It("should successfully reconcile a custom resource for Busybox", func() { + By("Checking if the custom resource was successfully created") + Eventually(func() error { + found := &examplecomv1alpha1.Busybox{} + return k8sClient.Get(ctx, typeNamespacedName, found) + }, time.Minute, time.Second).Should(Succeed()) + + By("Reconciling the custom resource created") + busyboxReconciler := &BusyboxReconciler{ + Client: k8sClient, + Scheme: k8sClient.Scheme(), + } + + _, err := busyboxReconciler.Reconcile(ctx, reconcile.Request{ + NamespacedName: typeNamespacedName, + }) + Expect(err).To(Not(HaveOccurred())) + + By("Checking if Deployment was successfully created in the reconciliation") + Eventually(func() error { + found := &appsv1.Deployment{} + return k8sClient.Get(ctx, typeNamespacedName, found) + }, time.Minute, time.Second).Should(Succeed()) + + By("Checking the latest Status Condition added to the Busybox instance") + Eventually(func() error { + if busybox.Status.Conditions != nil && + len(busybox.Status.Conditions) != 0 { + latestStatusCondition := busybox.Status.Conditions[len(busybox.Status.Conditions)-1] + expectedLatestStatusCondition := metav1.Condition{ + Type: typeAvailableBusybox, + Status: metav1.ConditionTrue, + Reason: "Reconciling", + Message: fmt.Sprintf( + "Deployment for custom resource (%s) with %d replicas created successfully", + busybox.Name, + busybox.Spec.Size), + } + if latestStatusCondition != expectedLatestStatusCondition { + return fmt.Errorf("The latest status condition added to the Busybox instance is not as expected") + } + } + return nil + }, time.Minute, time.Second).Should(Succeed()) + }) + }) +}) diff --git a/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller.go new file mode 100644 index 00000000000..a1a24ac0507 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller.go @@ -0,0 +1,448 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package examplecom + +import ( + "context" + "fmt" + "os" + "strings" + "time" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/record" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/log" + + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" +) + +const memcachedFinalizer = "example.com.testproject.org/finalizer" + +// Definitions to manage status conditions +const ( + // typeAvailableMemcached represents the status of the Deployment reconciliation + typeAvailableMemcached = "Available" + // typeDegradedMemcached represents the status used when the custom resource is deleted and the finalizer operations are yet to occur. + typeDegradedMemcached = "Degraded" +) + +// MemcachedReconciler reconciles a Memcached object +type MemcachedReconciler struct { + client.Client + Scheme *runtime.Scheme + Recorder record.EventRecorder +} + +// The following markers are used to generate the rules permissions (RBAC) on config/rbac using controller-gen +// when the command is executed. +// To know more about markers see: https://book.kubebuilder.io/reference/markers.html + +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=memcacheds,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=memcacheds/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=example.com.testproject.org,resources=memcacheds/finalizers,verbs=update +// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch +// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// It is essential for the controller's reconciliation loop to be idempotent. By following the Operator +// pattern you will create Controllers which provide a reconcile function +// responsible for synchronizing resources until the desired state is reached on the cluster. +// Breaking this recommendation goes against the design principles of controller-runtime. +// and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. +// For further info: +// - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ +// - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile +func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + log := log.FromContext(ctx) + + // Fetch the Memcached instance + // The purpose is check if the Custom Resource for the Kind Memcached + // is applied on the cluster if not we return nil to stop the reconciliation + memcached := &examplecomv1alpha1.Memcached{} + err := r.Get(ctx, req.NamespacedName, memcached) + if err != nil { + if apierrors.IsNotFound(err) { + // If the custom resource is not found then it usually means that it was deleted or not created + // In this way, we will stop the reconciliation + log.Info("memcached resource not found. Ignoring since object must be deleted") + return ctrl.Result{}, nil + } + // Error reading the object - requeue the request. + log.Error(err, "Failed to get memcached") + return ctrl.Result{}, err + } + + // Let's just set the status as Unknown when no status is available + if memcached.Status.Conditions == nil || len(memcached.Status.Conditions) == 0 { + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeAvailableMemcached, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"}) + if err = r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + // Let's re-fetch the memcached Custom Resource after updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + // if we try to update it again in the following operations + if err := r.Get(ctx, req.NamespacedName, memcached); err != nil { + log.Error(err, "Failed to re-fetch memcached") + return ctrl.Result{}, err + } + } + + // Let's add a finalizer. Then, we can define some operations which should + // occur before the custom resource is deleted. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers + if !controllerutil.ContainsFinalizer(memcached, memcachedFinalizer) { + log.Info("Adding Finalizer for Memcached") + if ok := controllerutil.AddFinalizer(memcached, memcachedFinalizer); !ok { + log.Error(err, "Failed to add finalizer into the custom resource") + return ctrl.Result{Requeue: true}, nil + } + + if err = r.Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update custom resource to add finalizer") + return ctrl.Result{}, err + } + } + + // Check if the Memcached instance is marked to be deleted, which is + // indicated by the deletion timestamp being set. + isMemcachedMarkedToBeDeleted := memcached.GetDeletionTimestamp() != nil + if isMemcachedMarkedToBeDeleted { + if controllerutil.ContainsFinalizer(memcached, memcachedFinalizer) { + log.Info("Performing Finalizer Operations for Memcached before delete CR") + + // Let's add here a status "Downgrade" to reflect that this resource began its process to be terminated. + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeDegradedMemcached, + Status: metav1.ConditionUnknown, Reason: "Finalizing", + Message: fmt.Sprintf("Performing finalizer operations for the custom resource: %s ", memcached.Name)}) + + if err := r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + // Perform all operations required before removing the finalizer and allow + // the Kubernetes API to remove the custom resource. + r.doFinalizerOperationsForMemcached(memcached) + + // TODO(user): If you add operations to the doFinalizerOperationsForMemcached method + // then you need to ensure that all worked fine before deleting and updating the Downgrade status + // otherwise, you should requeue here. + + // Re-fetch the memcached Custom Resource before updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + if err := r.Get(ctx, req.NamespacedName, memcached); err != nil { + log.Error(err, "Failed to re-fetch memcached") + return ctrl.Result{}, err + } + + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeDegradedMemcached, + Status: metav1.ConditionTrue, Reason: "Finalizing", + Message: fmt.Sprintf("Finalizer operations for custom resource %s name were successfully accomplished", memcached.Name)}) + + if err := r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + log.Info("Removing Finalizer for Memcached after successfully perform the operations") + if ok := controllerutil.RemoveFinalizer(memcached, memcachedFinalizer); !ok { + log.Error(err, "Failed to remove finalizer for Memcached") + return ctrl.Result{Requeue: true}, nil + } + + if err := r.Update(ctx, memcached); err != nil { + log.Error(err, "Failed to remove finalizer for Memcached") + return ctrl.Result{}, err + } + } + return ctrl.Result{}, nil + } + + // Check if the deployment already exists, if not create a new one + found := &appsv1.Deployment{} + err = r.Get(ctx, types.NamespacedName{Name: memcached.Name, Namespace: memcached.Namespace}, found) + if err != nil && apierrors.IsNotFound(err) { + // Define a new deployment + dep, err := r.deploymentForMemcached(memcached) + if err != nil { + log.Error(err, "Failed to define new Deployment resource for Memcached") + + // The following implementation will update the status + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeAvailableMemcached, + Status: metav1.ConditionFalse, Reason: "Reconciling", + Message: fmt.Sprintf("Failed to create Deployment for the custom resource (%s): (%s)", memcached.Name, err)}) + + if err := r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, err + } + + log.Info("Creating a new Deployment", + "Deployment.Namespace", dep.Namespace, "Deployment.Name", dep.Name) + if err = r.Create(ctx, dep); err != nil { + log.Error(err, "Failed to create new Deployment", + "Deployment.Namespace", dep.Namespace, "Deployment.Name", dep.Name) + return ctrl.Result{}, err + } + + // Deployment created successfully + // We will requeue the reconciliation so that we can ensure the state + // and move forward for the next operations + return ctrl.Result{RequeueAfter: time.Minute}, nil + } else if err != nil { + log.Error(err, "Failed to get Deployment") + // Let's return the error for the reconciliation be re-trigged again + return ctrl.Result{}, err + } + + // The CRD API defines that the Memcached type have a MemcachedSpec.Size field + // to set the quantity of Deployment instances to the desired state on the cluster. + // Therefore, the following code will ensure the Deployment size is the same as defined + // via the Size spec of the Custom Resource which we are reconciling. + size := memcached.Spec.Size + if *found.Spec.Replicas != size { + found.Spec.Replicas = &size + if err = r.Update(ctx, found); err != nil { + log.Error(err, "Failed to update Deployment", + "Deployment.Namespace", found.Namespace, "Deployment.Name", found.Name) + + // Re-fetch the memcached Custom Resource before updating the status + // so that we have the latest state of the resource on the cluster and we will avoid + // raising the error "the object has been modified, please apply + // your changes to the latest version and try again" which would re-trigger the reconciliation + if err := r.Get(ctx, req.NamespacedName, memcached); err != nil { + log.Error(err, "Failed to re-fetch memcached") + return ctrl.Result{}, err + } + + // The following implementation will update the status + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeAvailableMemcached, + Status: metav1.ConditionFalse, Reason: "Resizing", + Message: fmt.Sprintf("Failed to update the size for the custom resource (%s): (%s)", memcached.Name, err)}) + + if err := r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, err + } + + // Now, that we update the size we want to requeue the reconciliation + // so that we can ensure that we have the latest state of the resource before + // update. Also, it will help ensure the desired state on the cluster + return ctrl.Result{Requeue: true}, nil + } + + // The following implementation will update the status + meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeAvailableMemcached, + Status: metav1.ConditionTrue, Reason: "Reconciling", + Message: fmt.Sprintf("Deployment for custom resource (%s) with %d replicas created successfully", memcached.Name, size)}) + + if err := r.Status().Update(ctx, memcached); err != nil { + log.Error(err, "Failed to update Memcached status") + return ctrl.Result{}, err + } + + return ctrl.Result{}, nil +} + +// finalizeMemcached will perform the required operations before delete the CR. +func (r *MemcachedReconciler) doFinalizerOperationsForMemcached(cr *examplecomv1alpha1.Memcached) { + // TODO(user): Add the cleanup steps that the operator + // needs to do before the CR can be deleted. Examples + // of finalizers include performing backups and deleting + // resources that are not owned by this CR, like a PVC. + + // Note: It is not recommended to use finalizers with the purpose of deleting resources which are + // created and managed in the reconciliation. These ones, such as the Deployment created on this reconcile, + // are defined as dependent of the custom resource. See that we use the method ctrl.SetControllerReference. + // to set the ownerRef which means that the Deployment will be deleted by the Kubernetes API. + // More info: https://kubernetes.io/docs/tasks/administer-cluster/use-cascading-deletion/ + + // The following implementation will raise an event + r.Recorder.Event(cr, "Warning", "Deleting", + fmt.Sprintf("Custom Resource %s is being deleted from the namespace %s", + cr.Name, + cr.Namespace)) +} + +// deploymentForMemcached returns a Memcached Deployment object +func (r *MemcachedReconciler) deploymentForMemcached( + memcached *examplecomv1alpha1.Memcached) (*appsv1.Deployment, error) { + ls := labelsForMemcached() + replicas := memcached.Spec.Size + + // Get the Operand image + image, err := imageForMemcached() + if err != nil { + return nil, err + } + + dep := &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: memcached.Name, + Namespace: memcached.Namespace, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: &replicas, + Selector: &metav1.LabelSelector{ + MatchLabels: ls, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: ls, + }, + Spec: corev1.PodSpec{ + // TODO(user): Uncomment the following code to configure the nodeAffinity expression + // according to the platforms which are supported by your solution. It is considered + // best practice to support multiple architectures. build your manager image using the + // makefile target docker-buildx. Also, you can use docker manifest inspect + // to check what are the platforms supported. + // More info: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity + // Affinity: &corev1.Affinity{ + // NodeAffinity: &corev1.NodeAffinity{ + // RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{ + // NodeSelectorTerms: []corev1.NodeSelectorTerm{ + // { + // MatchExpressions: []corev1.NodeSelectorRequirement{ + // { + // Key: "kubernetes.io/arch", + // Operator: "In", + // Values: []string{"amd64", "arm64", "ppc64le", "s390x"}, + // }, + // { + // Key: "kubernetes.io/os", + // Operator: "In", + // Values: []string{"linux"}, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + SecurityContext: &corev1.PodSecurityContext{ + RunAsNonRoot: &[]bool{true}[0], + // IMPORTANT: seccomProfile was introduced with Kubernetes 1.19 + // If you are looking for to produce solutions to be supported + // on lower versions you must remove this option. + SeccompProfile: &corev1.SeccompProfile{ + Type: corev1.SeccompProfileTypeRuntimeDefault, + }, + }, + Containers: []corev1.Container{{ + Image: image, + Name: "memcached", + ImagePullPolicy: corev1.PullIfNotPresent, + // Ensure restrictive context for the container + // More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted + SecurityContext: &corev1.SecurityContext{ + RunAsNonRoot: &[]bool{true}[0], + RunAsUser: &[]int64{1001}[0], + AllowPrivilegeEscalation: &[]bool{false}[0], + Capabilities: &corev1.Capabilities{ + Drop: []corev1.Capability{ + "ALL", + }, + }, + }, + Ports: []corev1.ContainerPort{{ + ContainerPort: memcached.Spec.ContainerPort, + Name: "memcached", + }}, + Command: []string{"memcached", "-m=64", "-o", "modern", "-v"}, + }}, + }, + }, + }, + } + + // Set the ownerRef for the Deployment + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/owners-dependents/ + if err := ctrl.SetControllerReference(memcached, dep, r.Scheme); err != nil { + return nil, err + } + return dep, nil +} + +// labelsForMemcached returns the labels for selecting the resources +// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ +func labelsForMemcached() map[string]string { + var imageTag string + image, err := imageForMemcached() + if err == nil { + imageTag = strings.Split(image, ":")[1] + } + return map[string]string{"app.kubernetes.io/name": "project-v4-multigroup-with-plugins", + "app.kubernetes.io/version": imageTag, + "app.kubernetes.io/managed-by": "MemcachedController", + } +} + +// imageForMemcached gets the Operand image which is managed by this controller +// from the MEMCACHED_IMAGE environment variable defined in the config/manager/manager.yaml +func imageForMemcached() (string, error) { + var imageEnvVar = "MEMCACHED_IMAGE" + image, found := os.LookupEnv(imageEnvVar) + if !found { + return "", fmt.Errorf("Unable to find %s environment variable with the image", imageEnvVar) + } + return image, nil +} + +// SetupWithManager sets up the controller with the Manager. +// The whole idea is to be watching the resources that matter for the controller. +// When a resource that the controller is interested in changes, the Watch triggers +// the controller’s reconciliation loop, ensuring that the actual state of the resource +// matches the desired state as defined in the controller’s logic. +// +// Notice how we configured the Manager to monitor events such as the creation, update, +// or deletion of a Custom Resource (CR) of the Memcached kind, as well as any changes +// to the Deployment that the controller manages and owns. +func (r *MemcachedReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + // Watch the Memcached CR(s) and trigger reconciliation whenever it + // is created, updated, or deleted + For(&examplecomv1alpha1.Memcached{}). + // Watch the Deployment managed by the MemcachedReconciler. If any changes occur to the Deployment + // owned and managed by this controller, it will trigger reconciliation, ensuring that the cluster + // state aligns with the desired state. See that the ownerRef was set when the Deployment was created. + Owns(&appsv1.Deployment{}). + Complete(r) +} diff --git a/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller_test.go new file mode 100644 index 00000000000..3b2cbf6f538 --- /dev/null +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/memcached_controller_test.go @@ -0,0 +1,154 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package examplecom + +import ( + "context" + "fmt" + "os" + "time" + + //nolint:golint + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" +) + +var _ = Describe("Memcached controller", func() { + Context("Memcached controller test", func() { + + const MemcachedName = "test-memcached" + + ctx := context.Background() + + namespace := &corev1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + Name: MemcachedName, + Namespace: MemcachedName, + }, + } + + typeNamespacedName := types.NamespacedName{ + Name: MemcachedName, + Namespace: MemcachedName, + } + memcached := &examplecomv1alpha1.Memcached{} + + BeforeEach(func() { + By("Creating the Namespace to perform the tests") + err := k8sClient.Create(ctx, namespace) + Expect(err).To(Not(HaveOccurred())) + + By("Setting the Image ENV VAR which stores the Operand image") + err = os.Setenv("MEMCACHED_IMAGE", "example.com/image:test") + Expect(err).To(Not(HaveOccurred())) + + By("creating the custom resource for the Kind Memcached") + err = k8sClient.Get(ctx, typeNamespacedName, memcached) + if err != nil && errors.IsNotFound(err) { + // Let's mock our custom resource at the same way that we would + // apply on the cluster the manifest under config/samples + memcached := &examplecomv1alpha1.Memcached{ + ObjectMeta: metav1.ObjectMeta{ + Name: MemcachedName, + Namespace: namespace.Name, + }, + Spec: examplecomv1alpha1.MemcachedSpec{ + Size: 1, + ContainerPort: 11211, + }, + } + + err = k8sClient.Create(ctx, memcached) + Expect(err).To(Not(HaveOccurred())) + } + }) + + AfterEach(func() { + By("removing the custom resource for the Kind Memcached") + found := &examplecomv1alpha1.Memcached{} + err := k8sClient.Get(ctx, typeNamespacedName, found) + Expect(err).To(Not(HaveOccurred())) + + Eventually(func() error { + return k8sClient.Delete(context.TODO(), found) + }, 2*time.Minute, time.Second).Should(Succeed()) + + // TODO(user): Attention if you improve this code by adding other context test you MUST + // be aware of the current delete namespace limitations. + // More info: https://book.kubebuilder.io/reference/envtest.html#testing-considerations + By("Deleting the Namespace to perform the tests") + _ = k8sClient.Delete(ctx, namespace) + + By("Removing the Image ENV VAR which stores the Operand image") + _ = os.Unsetenv("MEMCACHED_IMAGE") + }) + + It("should successfully reconcile a custom resource for Memcached", func() { + By("Checking if the custom resource was successfully created") + Eventually(func() error { + found := &examplecomv1alpha1.Memcached{} + return k8sClient.Get(ctx, typeNamespacedName, found) + }, time.Minute, time.Second).Should(Succeed()) + + By("Reconciling the custom resource created") + memcachedReconciler := &MemcachedReconciler{ + Client: k8sClient, + Scheme: k8sClient.Scheme(), + } + + _, err := memcachedReconciler.Reconcile(ctx, reconcile.Request{ + NamespacedName: typeNamespacedName, + }) + Expect(err).To(Not(HaveOccurred())) + + By("Checking if Deployment was successfully created in the reconciliation") + Eventually(func() error { + found := &appsv1.Deployment{} + return k8sClient.Get(ctx, typeNamespacedName, found) + }, time.Minute, time.Second).Should(Succeed()) + + By("Checking the latest Status Condition added to the Memcached instance") + Eventually(func() error { + if memcached.Status.Conditions != nil && + len(memcached.Status.Conditions) != 0 { + latestStatusCondition := memcached.Status.Conditions[len(memcached.Status.Conditions)-1] + expectedLatestStatusCondition := metav1.Condition{ + Type: typeAvailableMemcached, + Status: metav1.ConditionTrue, + Reason: "Reconciling", + Message: fmt.Sprintf( + "Deployment for custom resource (%s) with %d replicas created successfully", + memcached.Name, + memcached.Spec.Size), + } + if latestStatusCondition != expectedLatestStatusCondition { + return fmt.Errorf("The latest status condition added to the Memcached instance is not as expected") + } + } + return nil + }, time.Minute, time.Second).Should(Succeed()) + }) + }) +}) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/suite_test.go similarity index 93% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/suite_test.go index 443b6e97462..a46a3bf7497 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo.policy/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/example.com/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package foopolicy +package examplecom import ( "context" @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo.policy/v1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/example.com/v1alpha1" // +kubebuilder:scaffold:imports ) @@ -77,7 +77,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - err = foopolicyv1.AddToScheme(scheme.Scheme) + err = examplecomv1alpha1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) // +kubebuilder:scaffold:scheme diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller.go index a29f9b5ce27..7ed849a7d3b 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1" + fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/fiz/v1" ) // BarReconciler reconciles a Bar object diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller_test.go index 2b9c388f1d5..66e969dfbba 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/bar_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/bar_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1" + fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/fiz/v1" ) var _ = Describe("Bar Controller", func() { diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/suite_test.go similarity index 99% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/suite_test.go index 5545a274be6..c456259e68b 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/fiz/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/fiz/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/fiz/v1" + fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/fiz/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller.go index bcd1ed6021e..999be069c3d 100644 --- a/testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo.policy/v1" + foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1" ) // HealthCheckPolicyReconciler reconciles a HealthCheckPolicy object diff --git a/testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller_test.go index 55de998a0a2..241a36521a2 100644 --- a/testdata/project-v4-multigroup/internal/controller/foo.policy/healthcheckpolicy_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/healthcheckpolicy_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo.policy/v1" + foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1" ) var _ = Describe("HealthCheckPolicy Controller", func() { diff --git a/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/suite_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/suite_test.go index a7a3cafc613..5938bc3f30e 100644 --- a/testdata/project-v4-multigroup/internal/controller/foo.policy/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo.policy/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo.policy/v1" + foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo.policy/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller.go index 149973eab2f..a6fc2cfa5e9 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1" + foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo/v1" ) // BarReconciler reconciles a Bar object diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller_test.go index c0bd76e8f26..4a176a3ed86 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/bar_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/bar_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1" + foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo/v1" ) var _ = Describe("Bar Controller", func() { diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/suite_test.go similarity index 99% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/foo/suite_test.go index 4e63dcf1b9d..608f8cd1dd3 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/foo/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/foo/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/foo/v1" + foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/foo/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup/internal/controller/lakers_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/lakers_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller.go index d52562a3014..e2ef764c09e 100644 --- a/testdata/project-v4-multigroup/internal/controller/lakers_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/v1" + testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/v1" ) // LakersReconciler reconciles a Lakers object diff --git a/testdata/project-v4-multigroup/internal/controller/lakers_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/lakers_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller_test.go index 84ae3e086e0..1f3d19fd795 100644 --- a/testdata/project-v4-multigroup/internal/controller/lakers_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/lakers_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/v1" + testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/v1" ) var _ = Describe("Lakers Controller", func() { diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller.go similarity index 97% rename from testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller.go index 3ed11fd2f98..8d91ecdbc1e 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta1" + seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1" ) // KrakenReconciler reconciles a Kraken object diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller_test.go index b0eae061ff8..33722ed65e4 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/kraken_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/kraken_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta1" + seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1" ) var _ = Describe("Kraken Controller", func() { diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller.go similarity index 97% rename from testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller.go index bf137eb0255..c31c5c533a6 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta2" + seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2" ) // LeviathanReconciler reconciles a Leviathan object diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller_test.go index 5b1e491aa89..d4d86ca1aa1 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/leviathan_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/leviathan_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta2" + seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2" ) var _ = Describe("Leviathan Controller", func() { diff --git a/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/suite_test.go similarity index 96% rename from testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/suite_test.go index d2f44fafbe2..d0af2c0593f 100644 --- a/testdata/project-v4-multigroup/internal/controller/sea-creatures/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/sea-creatures/suite_test.go @@ -33,8 +33,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta1" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta2" + seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta1" + seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/sea-creatures/v1beta2" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller.go index 161c3e3358b..ed87ec7089b 100644 --- a/testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v2alpha1" + shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1" ) // CruiserReconciler reconciles a Cruiser object diff --git a/testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller_test.go index 5d432ab735e..f60ede5f866 100644 --- a/testdata/project-v4-multigroup/internal/controller/ship/cruiser_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/cruiser_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v2alpha1" + shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1" ) var _ = Describe("Cruiser Controller", func() { diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller.go index 06102652693..d408be2d5b9 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1" + shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1" ) // DestroyerReconciler reconciles a Destroyer object diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller_test.go index fff4e22fc60..7c91b76bb7a 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/destroyer_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/destroyer_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1" + shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1" ) var _ = Describe("Destroyer Controller", func() { diff --git a/testdata/project-v4-multigroup/internal/controller/ship/frigate_controller.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/ship/frigate_controller.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller.go index 120c374d4e2..ebfa13039b2 100644 --- a/testdata/project-v4-multigroup/internal/controller/ship/frigate_controller.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1beta1" + shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1" ) // FrigateReconciler reconciles a Frigate object diff --git a/testdata/project-v4-multigroup/internal/controller/ship/frigate_controller_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/ship/frigate_controller_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller_test.go index f36a8679754..1674d98921c 100644 --- a/testdata/project-v4-multigroup/internal/controller/ship/frigate_controller_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/frigate_controller_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1beta1" + shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1" ) var _ = Describe("Frigate Controller", func() { diff --git a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/suite_test.go similarity index 96% rename from testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/ship/suite_test.go index 9192c6ee3cd..3c259a3d0a1 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/internal/controller/ship/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/ship/suite_test.go @@ -33,9 +33,9 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v1beta1" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-deploy-image/api/ship/v2alpha1" + shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1" + shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v1beta1" + shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/ship/v2alpha1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup/internal/controller/suite_test.go b/testdata/project-v4-multigroup-with-plugins/internal/controller/suite_test.go similarity index 98% rename from testdata/project-v4-multigroup/internal/controller/suite_test.go rename to testdata/project-v4-multigroup-with-plugins/internal/controller/suite_test.go index 5dc7c07a170..a87ec273537 100644 --- a/testdata/project-v4-multigroup/internal/controller/suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/internal/controller/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/v1" + testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/api/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-multigroup/test/e2e/e2e_suite_test.go b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_suite_test.go similarity index 96% rename from testdata/project-v4-multigroup/test/e2e/e2e_suite_test.go rename to testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_suite_test.go index be68fdc2df9..aa6e2a37aca 100644 --- a/testdata/project-v4-multigroup/test/e2e/e2e_suite_test.go +++ b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_suite_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/test/utils" + "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/test/utils" ) var ( @@ -43,7 +43,7 @@ var ( // projectImage is the name of the image which will be build and loaded // with the code source changes to be tested. - projectImage = "example.com/project-v4-multigroup:v0.0.1" + projectImage = "example.com/project-v4-multigroup-with-plugins:v0.0.1" ) // TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated, @@ -52,7 +52,7 @@ var ( // CertManager and Prometheus. func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-multigroup integration test suite\n") + _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-multigroup-with-plugins integration test suite\n") RunSpecs(t, "e2e suite") } diff --git a/testdata/project-v4-multigroup/test/e2e/e2e_test.go b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go similarity index 94% rename from testdata/project-v4-multigroup/test/e2e/e2e_test.go rename to testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go index fb396885421..91a6842439b 100644 --- a/testdata/project-v4-multigroup/test/e2e/e2e_test.go +++ b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go @@ -27,20 +27,20 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/test/utils" + "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup-with-plugins/test/utils" ) // namespace where the project is deployed in -const namespace = "project-v4-multigroup-system" +const namespace = "project-v4-multigroup-with-plugins-system" // serviceAccountName created for the project -const serviceAccountName = "project-v4-multigroup-controller-manager" +const serviceAccountName = "project-v4-multigroup-with-plugins-controller-manager" // metricsServiceName is the name of the metrics service of the project -const metricsServiceName = "project-v4-multigroup-controller-manager-metrics-service" +const metricsServiceName = "project-v4-multigroup-with-plugins-controller-manager-metrics-service" // metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data -const metricsRoleBindingName = "project-v4-multigroup-metrics-binding" +const metricsRoleBindingName = "project-v4-multigroup-with-plugins-metrics-binding" var _ = Describe("Manager", Ordered, func() { // Before running the tests, set up the environment by creating the namespace, @@ -119,7 +119,7 @@ var _ = Describe("Manager", Ordered, func() { It("should ensure the metrics endpoint is serving metrics", func() { By("creating a ClusterRoleBinding for the service account to allow access to metrics") cmd := exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName, - "--clusterrole=project-v4-multigroup-metrics-reader", + "--clusterrole=project-v4-multigroup-with-plugins-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) _, err := utils.Run(cmd) @@ -199,7 +199,7 @@ var _ = Describe("Manager", Ordered, func() { verifyCAInjection := func(g Gomega) { cmd := exec.Command("kubectl", "get", "mutatingwebhookconfigurations.admissionregistration.k8s.io", - "project-v4-multigroup-mutating-webhook-configuration", + "project-v4-multigroup-with-plugins-mutating-webhook-configuration", "-o", "go-template={{ range .webhooks }}{{ .clientConfig.caBundle }}{{ end }}") mwhOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred()) @@ -213,7 +213,7 @@ var _ = Describe("Manager", Ordered, func() { verifyCAInjection := func(g Gomega) { cmd := exec.Command("kubectl", "get", "validatingwebhookconfigurations.admissionregistration.k8s.io", - "project-v4-multigroup-validating-webhook-configuration", + "project-v4-multigroup-with-plugins-validating-webhook-configuration", "-o", "go-template={{ range .webhooks }}{{ .clientConfig.caBundle }}{{ end }}") vwhOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred()) diff --git a/testdata/project-v4-multigroup-with-deploy-image/test/utils/utils.go b/testdata/project-v4-multigroup-with-plugins/test/utils/utils.go similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/test/utils/utils.go rename to testdata/project-v4-multigroup-with-plugins/test/utils/utils.go diff --git a/testdata/project-v4-multigroup/PROJECT b/testdata/project-v4-multigroup/PROJECT deleted file mode 100644 index 92f8bcfd7a5..00000000000 --- a/testdata/project-v4-multigroup/PROJECT +++ /dev/null @@ -1,121 +0,0 @@ -# Code generated by tool. DO NOT EDIT. -# This file is used to track the info used to scaffold your project -# and allow the plugins properly work. -# More info: https://book.kubebuilder.io/reference/project-config.html -domain: testproject.org -layout: -- go.kubebuilder.io/v4 -multigroup: true -projectName: project-v4-multigroup -repo: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup -resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: crew - kind: Captain - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/crew/v1 - version: v1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: ship - kind: Frigate - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1beta1 - version: v1beta1 - webhooks: - conversion: true - webhookVersion: v1 -- api: - crdVersion: v1 - controller: true - domain: testproject.org - group: ship - kind: Destroyer - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1 - version: v1 - webhooks: - defaulting: true - webhookVersion: v1 -- api: - crdVersion: v1 - controller: true - domain: testproject.org - group: ship - kind: Cruiser - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v2alpha1 - version: v2alpha1 - webhooks: - validation: true - webhookVersion: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: sea-creatures - kind: Kraken - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta1 - version: v1beta1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: sea-creatures - kind: Leviathan - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta2 - version: v1beta2 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: foo.policy - kind: HealthCheckPolicy - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo.policy/v1 - version: v1 -- controller: true - group: apps - kind: Deployment - path: k8s.io/api/apps/v1 - version: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: foo - kind: Bar - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo/v1 - version: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: fiz - kind: Bar - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/fiz/v1 - version: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - kind: Lakers - path: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/v1 - version: v1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 -version: "3" diff --git a/testdata/project-v4-multigroup/README.md b/testdata/project-v4-multigroup/README.md deleted file mode 100644 index be36750a352..00000000000 --- a/testdata/project-v4-multigroup/README.md +++ /dev/null @@ -1,114 +0,0 @@ -# project-v4-multigroup -// TODO(user): Add simple overview of use/purpose - -## Description -// TODO(user): An in-depth paragraph about your project and overview of use - -## Getting Started - -### Prerequisites -- go version v1.22.0+ -- docker version 17.03+. -- kubectl version v1.11.3+. -- Access to a Kubernetes v1.11.3+ cluster. - -### To Deploy on the cluster -**Build and push your image to the location specified by `IMG`:** - -```sh -make docker-build docker-push IMG=/project-v4-multigroup:tag -``` - -**NOTE:** This image ought to be published in the personal registry you specified. -And it is required to have access to pull the image from the working environment. -Make sure you have the proper permission to the registry if the above commands don’t work. - -**Install the CRDs into the cluster:** - -```sh -make install -``` - -**Deploy the Manager to the cluster with the image specified by `IMG`:** - -```sh -make deploy IMG=/project-v4-multigroup:tag -``` - -> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin -privileges or be logged in as admin. - -**Create instances of your solution** -You can apply the samples (examples) from the config/sample: - -```sh -kubectl apply -k config/samples/ -``` - ->**NOTE**: Ensure that the samples has default values to test it out. - -### To Uninstall -**Delete the instances (CRs) from the cluster:** - -```sh -kubectl delete -k config/samples/ -``` - -**Delete the APIs(CRDs) from the cluster:** - -```sh -make uninstall -``` - -**UnDeploy the controller from the cluster:** - -```sh -make undeploy -``` - -## Project Distribution - -Following are the steps to build the installer and distribute this project to users. - -1. Build the installer for the image built and published in the registry: - -```sh -make build-installer IMG=/project-v4-multigroup:tag -``` - -NOTE: The makefile target mentioned above generates an 'install.yaml' -file in the dist directory. This file contains all the resources built -with Kustomize, which are necessary to install this project without -its dependencies. - -2. Using the installer - -Users can just run kubectl apply -f to install the project, i.e.: - -```sh -kubectl apply -f https://raw.githubusercontent.com//project-v4-multigroup//dist/install.yaml -``` - -## Contributing -// TODO(user): Add detailed information on how you would like others to contribute to this project - -**NOTE:** Run `make help` for more information on all potential `make` targets - -More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html) - -## License - -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - diff --git a/testdata/project-v4-multigroup/api/crew/v1/captain_types.go b/testdata/project-v4-multigroup/api/crew/v1/captain_types.go deleted file mode 100644 index 1b45736ca18..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/captain_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// CaptainSpec defines the desired state of Captain. -type CaptainSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Captain. Edit captain_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// CaptainStatus defines the observed state of Captain. -type CaptainStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Captain is the Schema for the captains API. -type Captain struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec CaptainSpec `json:"spec,omitempty"` - Status CaptainStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// CaptainList contains a list of Captain. -type CaptainList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Captain `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Captain{}, &CaptainList{}) -} diff --git a/testdata/project-v4-multigroup/api/crew/v1/captain_webhook.go b/testdata/project-v4-multigroup/api/crew/v1/captain_webhook.go deleted file mode 100644 index 1104ef10ae3..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/captain_webhook.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "fmt" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// nolint:unused -// log is for logging in this package. -var captainlog = logf.Log.WithName("captain-resource") - -// SetupWebhookWithManager will setup the manager to manage the webhooks. -func (r *Captain) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - WithValidator(&CaptainCustomValidator{}). - WithDefaulter(&CaptainCustomDefaulter{}). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -// +kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-captain,mutating=true,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=mcaptain.kb.io,admissionReviewVersions=v1 - -// +kubebuilder:object:generate=false -// CaptainCustomDefaulter struct is responsible for setting default values on the custom resource of the -// Kind Captain when those are created or updated. -// -// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, -// as it is used only for temporary operations and does not need to be deeply copied. -type CaptainCustomDefaulter struct { - // TODO(user): Add more fields as needed for defaulting -} - -var _ webhook.CustomDefaulter = &CaptainCustomDefaulter{} - -// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind Captain. -func (d *CaptainCustomDefaulter) Default(ctx context.Context, obj runtime.Object) error { - captain, ok := obj.(*Captain) - if !ok { - return fmt.Errorf("expected an Captain object but got %T", obj) - } - captainlog.Info("Defaulting for Captain", "name", captain.GetName()) - - // TODO(user): fill in your defaulting logic. - - return nil -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here. -// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook. -// +kubebuilder:webhook:path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=vcaptain.kb.io,admissionReviewVersions=v1 - -// +kubebuilder:object:generate=false -// CaptainCustomValidator struct is responsible for validating the Captain resource -// when it is created, updated, or deleted. -// -// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, -// as this struct is used only for temporary operations and does not need to be deeply copied. -type CaptainCustomValidator struct { - //TODO(user): Add more fields as needed for validation -} - -var _ webhook.CustomValidator = &CaptainCustomValidator{} - -// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Captain. -func (v *CaptainCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - captain, ok := obj.(*Captain) - if !ok { - return nil, fmt.Errorf("expected a Captain object but got %T", obj) - } - captainlog.Info("Validation for Captain upon creation", "name", captain.GetName()) - - // TODO(user): fill in your validation logic upon object creation. - - return nil, nil -} - -// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Captain. -func (v *CaptainCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - captain, ok := newObj.(*Captain) - if !ok { - return nil, fmt.Errorf("expected a Captain object but got %T", newObj) - } - captainlog.Info("Validation for Captain upon update", "name", captain.GetName()) - - // TODO(user): fill in your validation logic upon object update. - - return nil, nil -} - -// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Captain. -func (v *CaptainCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - captain, ok := obj.(*Captain) - if !ok { - return nil, fmt.Errorf("expected a Captain object but got %T", obj) - } - captainlog.Info("Validation for Captain upon deletion", "name", captain.GetName()) - - // TODO(user): fill in your validation logic upon object deletion. - - return nil, nil -} diff --git a/testdata/project-v4-multigroup/api/crew/v1/captain_webhook_test.go b/testdata/project-v4-multigroup/api/crew/v1/captain_webhook_test.go deleted file mode 100644 index 8997d73e654..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/captain_webhook_test.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - // TODO (user): Add any additional imports if needed -) - -var _ = Describe("Captain Webhook", func() { - var ( - obj *Captain - ) - - BeforeEach(func() { - obj = &Captain{} - Expect(obj).NotTo(BeNil(), "Expected obj to be initialized") - - // TODO (user): Add any setup logic common to all tests - }) - - AfterEach(func() { - // TODO (user): Add any teardown logic common to all tests - }) - - Context("When creating Captain under Defaulting Webhook", func() { - // TODO (user): Add logic for defaulting webhooks - // Example: - // It("Should apply defaults when a required field is empty", func() { - // By("simulating a scenario where defaults should be applied") - // obj.SomeFieldWithDefault = "" - // err := obj.Default(ctx) - // Expect(err).NotTo(HaveOccurred()) - // Expect(obj.SomeFieldWithDefault).To(Equal("default_value")) - // }) - }) - - Context("When creating or updating Captain under Validating Webhook", func() { - // TODO (user): Add logic for validating webhooks - // Example: - // It("Should deny creation if a required field is missing", func() { - // By("simulating an invalid creation scenario") - // obj.SomeRequiredField = "" - // warnings, err := obj.ValidateCreate(ctx) - // Expect(err).To(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - // - // It("Should admit creation if all required fields are present", func() { - // By("simulating an invalid creation scenario") - // obj.SomeRequiredField = "valid_value" - // warnings, err := obj.ValidateCreate(ctx) - // Expect(err).NotTo(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - // - // It("Should validate updates correctly", func() { - // By("simulating a valid update scenario") - // oldObj := &Captain{SomeRequiredField: "valid_value"} - // obj.SomeRequiredField = "updated_value" - // warnings, err := obj.ValidateUpdate(ctx, oldObj) - // Expect(err).NotTo(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - }) - -}) diff --git a/testdata/project-v4-multigroup/api/crew/v1/groupversion_info.go b/testdata/project-v4-multigroup/api/crew/v1/groupversion_info.go deleted file mode 100644 index 9c6c30fccf9..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1 contains API Schema definitions for the crew v1 API group. -// +kubebuilder:object:generate=true -// +groupName=crew.testproject.org -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "crew.testproject.org", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go deleted file mode 100644 index 6614182b4e2..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/webhook_suite_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "runtime" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - admissionv1 "k8s.io/api/admission/v1" - // +kubebuilder:scaffold:imports - apimachineryruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var ( - cancel context.CancelFunc - cfg *rest.Config - ctx context.Context - k8sClient client.Client - testEnv *envtest.Environment -) - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Webhook Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, - }, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := apimachineryruntime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager. - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - WebhookServer: webhook.NewServer(webhook.Options{ - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - }), - LeaderElection: false, - Metrics: metricsserver.Options{BindAddress: "0"}, - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&Captain{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:webhook - - go func() { - defer GinkgoRecover() - err = mgr.Start(ctx) - Expect(err).NotTo(HaveOccurred()) - }() - - // wait for the webhook server to get ready. - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - - return conn.Close() - }).Should(Succeed()) -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/api/crew/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/crew/v1/zz_generated.deepcopy.go deleted file mode 100644 index 438b50de573..00000000000 --- a/testdata/project-v4-multigroup/api/crew/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Captain) DeepCopyInto(out *Captain) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Captain. -func (in *Captain) DeepCopy() *Captain { - if in == nil { - return nil - } - out := new(Captain) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Captain) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CaptainList) DeepCopyInto(out *CaptainList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Captain, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainList. -func (in *CaptainList) DeepCopy() *CaptainList { - if in == nil { - return nil - } - out := new(CaptainList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CaptainList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CaptainSpec) DeepCopyInto(out *CaptainSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainSpec. -func (in *CaptainSpec) DeepCopy() *CaptainSpec { - if in == nil { - return nil - } - out := new(CaptainSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CaptainStatus) DeepCopyInto(out *CaptainStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainStatus. -func (in *CaptainStatus) DeepCopy() *CaptainStatus { - if in == nil { - return nil - } - out := new(CaptainStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/fiz/v1/bar_types.go b/testdata/project-v4-multigroup/api/fiz/v1/bar_types.go deleted file mode 100644 index c3d4884be9e..00000000000 --- a/testdata/project-v4-multigroup/api/fiz/v1/bar_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// BarSpec defines the desired state of Bar. -type BarSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Bar. Edit bar_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// BarStatus defines the observed state of Bar. -type BarStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Bar is the Schema for the bars API. -type Bar struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BarSpec `json:"spec,omitempty"` - Status BarStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// BarList contains a list of Bar. -type BarList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Bar `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Bar{}, &BarList{}) -} diff --git a/testdata/project-v4-multigroup/api/fiz/v1/groupversion_info.go b/testdata/project-v4-multigroup/api/fiz/v1/groupversion_info.go deleted file mode 100644 index acb3305b576..00000000000 --- a/testdata/project-v4-multigroup/api/fiz/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1 contains API Schema definitions for the fiz v1 API group. -// +kubebuilder:object:generate=true -// +groupName=fiz.testproject.org -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "fiz.testproject.org", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/fiz/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/fiz/v1/zz_generated.deepcopy.go deleted file mode 100644 index b82929d3f21..00000000000 --- a/testdata/project-v4-multigroup/api/fiz/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Bar) DeepCopyInto(out *Bar) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Bar. -func (in *Bar) DeepCopy() *Bar { - if in == nil { - return nil - } - out := new(Bar) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Bar) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarList) DeepCopyInto(out *BarList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Bar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarList. -func (in *BarList) DeepCopy() *BarList { - if in == nil { - return nil - } - out := new(BarList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BarList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarSpec) DeepCopyInto(out *BarSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarSpec. -func (in *BarSpec) DeepCopy() *BarSpec { - if in == nil { - return nil - } - out := new(BarSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarStatus) DeepCopyInto(out *BarStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarStatus. -func (in *BarStatus) DeepCopy() *BarStatus { - if in == nil { - return nil - } - out := new(BarStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/foo.policy/v1/groupversion_info.go b/testdata/project-v4-multigroup/api/foo.policy/v1/groupversion_info.go deleted file mode 100644 index 03b284b34bf..00000000000 --- a/testdata/project-v4-multigroup/api/foo.policy/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1 contains API Schema definitions for the foo.policy v1 API group. -// +kubebuilder:object:generate=true -// +groupName=foo.policy.testproject.org -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "foo.policy.testproject.org", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/foo.policy/v1/healthcheckpolicy_types.go b/testdata/project-v4-multigroup/api/foo.policy/v1/healthcheckpolicy_types.go deleted file mode 100644 index 49b587d1499..00000000000 --- a/testdata/project-v4-multigroup/api/foo.policy/v1/healthcheckpolicy_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// HealthCheckPolicySpec defines the desired state of HealthCheckPolicy. -type HealthCheckPolicySpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of HealthCheckPolicy. Edit healthcheckpolicy_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// HealthCheckPolicyStatus defines the observed state of HealthCheckPolicy. -type HealthCheckPolicyStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// HealthCheckPolicy is the Schema for the healthcheckpolicies API. -type HealthCheckPolicy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec HealthCheckPolicySpec `json:"spec,omitempty"` - Status HealthCheckPolicyStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// HealthCheckPolicyList contains a list of HealthCheckPolicy. -type HealthCheckPolicyList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []HealthCheckPolicy `json:"items"` -} - -func init() { - SchemeBuilder.Register(&HealthCheckPolicy{}, &HealthCheckPolicyList{}) -} diff --git a/testdata/project-v4-multigroup/api/foo.policy/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/foo.policy/v1/zz_generated.deepcopy.go deleted file mode 100644 index d0cfbe15c38..00000000000 --- a/testdata/project-v4-multigroup/api/foo.policy/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HealthCheckPolicy) DeepCopyInto(out *HealthCheckPolicy) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheckPolicy. -func (in *HealthCheckPolicy) DeepCopy() *HealthCheckPolicy { - if in == nil { - return nil - } - out := new(HealthCheckPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *HealthCheckPolicy) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HealthCheckPolicyList) DeepCopyInto(out *HealthCheckPolicyList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]HealthCheckPolicy, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheckPolicyList. -func (in *HealthCheckPolicyList) DeepCopy() *HealthCheckPolicyList { - if in == nil { - return nil - } - out := new(HealthCheckPolicyList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *HealthCheckPolicyList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HealthCheckPolicySpec) DeepCopyInto(out *HealthCheckPolicySpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheckPolicySpec. -func (in *HealthCheckPolicySpec) DeepCopy() *HealthCheckPolicySpec { - if in == nil { - return nil - } - out := new(HealthCheckPolicySpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HealthCheckPolicyStatus) DeepCopyInto(out *HealthCheckPolicyStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheckPolicyStatus. -func (in *HealthCheckPolicyStatus) DeepCopy() *HealthCheckPolicyStatus { - if in == nil { - return nil - } - out := new(HealthCheckPolicyStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/foo/v1/bar_types.go b/testdata/project-v4-multigroup/api/foo/v1/bar_types.go deleted file mode 100644 index c3d4884be9e..00000000000 --- a/testdata/project-v4-multigroup/api/foo/v1/bar_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// BarSpec defines the desired state of Bar. -type BarSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Bar. Edit bar_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// BarStatus defines the observed state of Bar. -type BarStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Bar is the Schema for the bars API. -type Bar struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec BarSpec `json:"spec,omitempty"` - Status BarStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// BarList contains a list of Bar. -type BarList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Bar `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Bar{}, &BarList{}) -} diff --git a/testdata/project-v4-multigroup/api/foo/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/foo/v1/zz_generated.deepcopy.go deleted file mode 100644 index b82929d3f21..00000000000 --- a/testdata/project-v4-multigroup/api/foo/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Bar) DeepCopyInto(out *Bar) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Bar. -func (in *Bar) DeepCopy() *Bar { - if in == nil { - return nil - } - out := new(Bar) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Bar) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarList) DeepCopyInto(out *BarList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Bar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarList. -func (in *BarList) DeepCopy() *BarList { - if in == nil { - return nil - } - out := new(BarList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *BarList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarSpec) DeepCopyInto(out *BarSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarSpec. -func (in *BarSpec) DeepCopy() *BarSpec { - if in == nil { - return nil - } - out := new(BarSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BarStatus) DeepCopyInto(out *BarStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BarStatus. -func (in *BarStatus) DeepCopy() *BarStatus { - if in == nil { - return nil - } - out := new(BarStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/groupversion_info.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/groupversion_info.go deleted file mode 100644 index 89449b7966a..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1beta1 contains API Schema definitions for the sea-creatures v1beta1 API group. -// +kubebuilder:object:generate=true -// +groupName=sea-creatures.testproject.org -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "sea-creatures.testproject.org", Version: "v1beta1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/kraken_types.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/kraken_types.go deleted file mode 100644 index 3682748a3c3..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/kraken_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// KrakenSpec defines the desired state of Kraken. -type KrakenSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Kraken. Edit kraken_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// KrakenStatus defines the observed state of Kraken. -type KrakenStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Kraken is the Schema for the krakens API. -type Kraken struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec KrakenSpec `json:"spec,omitempty"` - Status KrakenStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// KrakenList contains a list of Kraken. -type KrakenList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Kraken `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Kraken{}, &KrakenList{}) -} diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index 25f64b3d2b5..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1beta1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Kraken) DeepCopyInto(out *Kraken) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Kraken. -func (in *Kraken) DeepCopy() *Kraken { - if in == nil { - return nil - } - out := new(Kraken) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Kraken) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KrakenList) DeepCopyInto(out *KrakenList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Kraken, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KrakenList. -func (in *KrakenList) DeepCopy() *KrakenList { - if in == nil { - return nil - } - out := new(KrakenList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *KrakenList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KrakenSpec) DeepCopyInto(out *KrakenSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KrakenSpec. -func (in *KrakenSpec) DeepCopy() *KrakenSpec { - if in == nil { - return nil - } - out := new(KrakenSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KrakenStatus) DeepCopyInto(out *KrakenStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KrakenStatus. -func (in *KrakenStatus) DeepCopy() *KrakenStatus { - if in == nil { - return nil - } - out := new(KrakenStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/groupversion_info.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/groupversion_info.go deleted file mode 100644 index eaee6464829..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1beta2 contains API Schema definitions for the sea-creatures v1beta2 API group. -// +kubebuilder:object:generate=true -// +groupName=sea-creatures.testproject.org -package v1beta2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "sea-creatures.testproject.org", Version: "v1beta2"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/leviathan_types.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/leviathan_types.go deleted file mode 100644 index 4726c79b1b1..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/leviathan_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// LeviathanSpec defines the desired state of Leviathan. -type LeviathanSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Leviathan. Edit leviathan_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// LeviathanStatus defines the observed state of Leviathan. -type LeviathanStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Leviathan is the Schema for the leviathans API. -type Leviathan struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec LeviathanSpec `json:"spec,omitempty"` - Status LeviathanStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// LeviathanList contains a list of Leviathan. -type LeviathanList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Leviathan `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Leviathan{}, &LeviathanList{}) -} diff --git a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/zz_generated.deepcopy.go deleted file mode 100644 index e9934a77f85..00000000000 --- a/testdata/project-v4-multigroup/api/sea-creatures/v1beta2/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1beta2 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Leviathan) DeepCopyInto(out *Leviathan) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Leviathan. -func (in *Leviathan) DeepCopy() *Leviathan { - if in == nil { - return nil - } - out := new(Leviathan) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Leviathan) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LeviathanList) DeepCopyInto(out *LeviathanList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Leviathan, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeviathanList. -func (in *LeviathanList) DeepCopy() *LeviathanList { - if in == nil { - return nil - } - out := new(LeviathanList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *LeviathanList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LeviathanSpec) DeepCopyInto(out *LeviathanSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeviathanSpec. -func (in *LeviathanSpec) DeepCopy() *LeviathanSpec { - if in == nil { - return nil - } - out := new(LeviathanSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LeviathanStatus) DeepCopyInto(out *LeviathanStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeviathanStatus. -func (in *LeviathanStatus) DeepCopy() *LeviathanStatus { - if in == nil { - return nil - } - out := new(LeviathanStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/ship/v1/destroyer_types.go b/testdata/project-v4-multigroup/api/ship/v1/destroyer_types.go deleted file mode 100644 index 11c5768f0ac..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/destroyer_types.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// DestroyerSpec defines the desired state of Destroyer. -type DestroyerSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Destroyer. Edit destroyer_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// DestroyerStatus defines the observed state of Destroyer. -type DestroyerStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:scope=Cluster - -// Destroyer is the Schema for the destroyers API. -type Destroyer struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DestroyerSpec `json:"spec,omitempty"` - Status DestroyerStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// DestroyerList contains a list of Destroyer. -type DestroyerList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Destroyer `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Destroyer{}, &DestroyerList{}) -} diff --git a/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook.go b/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook.go deleted file mode 100644 index 2fb48f63f06..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "fmt" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// nolint:unused -// log is for logging in this package. -var destroyerlog = logf.Log.WithName("destroyer-resource") - -// SetupWebhookWithManager will setup the manager to manage the webhooks. -func (r *Destroyer) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - WithDefaulter(&DestroyerCustomDefaulter{}). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -// +kubebuilder:webhook:path=/mutate-ship-testproject-org-v1-destroyer,mutating=true,failurePolicy=fail,sideEffects=None,groups=ship.testproject.org,resources=destroyers,verbs=create;update,versions=v1,name=mdestroyer.kb.io,admissionReviewVersions=v1 - -// +kubebuilder:object:generate=false -// DestroyerCustomDefaulter struct is responsible for setting default values on the custom resource of the -// Kind Destroyer when those are created or updated. -// -// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, -// as it is used only for temporary operations and does not need to be deeply copied. -type DestroyerCustomDefaulter struct { - // TODO(user): Add more fields as needed for defaulting -} - -var _ webhook.CustomDefaulter = &DestroyerCustomDefaulter{} - -// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind Destroyer. -func (d *DestroyerCustomDefaulter) Default(ctx context.Context, obj runtime.Object) error { - destroyer, ok := obj.(*Destroyer) - if !ok { - return fmt.Errorf("expected an Destroyer object but got %T", obj) - } - destroyerlog.Info("Defaulting for Destroyer", "name", destroyer.GetName()) - - // TODO(user): fill in your defaulting logic. - - return nil -} diff --git a/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook_test.go b/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook_test.go deleted file mode 100644 index 82f2eb33c09..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/destroyer_webhook_test.go +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - // TODO (user): Add any additional imports if needed -) - -var _ = Describe("Destroyer Webhook", func() { - var ( - obj *Destroyer - ) - - BeforeEach(func() { - obj = &Destroyer{} - Expect(obj).NotTo(BeNil(), "Expected obj to be initialized") - - // TODO (user): Add any setup logic common to all tests - }) - - AfterEach(func() { - // TODO (user): Add any teardown logic common to all tests - }) - - Context("When creating Destroyer under Defaulting Webhook", func() { - // TODO (user): Add logic for defaulting webhooks - // Example: - // It("Should apply defaults when a required field is empty", func() { - // By("simulating a scenario where defaults should be applied") - // obj.SomeFieldWithDefault = "" - // err := obj.Default(ctx) - // Expect(err).NotTo(HaveOccurred()) - // Expect(obj.SomeFieldWithDefault).To(Equal("default_value")) - // }) - }) - -}) diff --git a/testdata/project-v4-multigroup/api/ship/v1/groupversion_info.go b/testdata/project-v4-multigroup/api/ship/v1/groupversion_info.go deleted file mode 100644 index 7ede1ddfa92..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1 contains API Schema definitions for the ship v1 API group. -// +kubebuilder:object:generate=true -// +groupName=ship.testproject.org -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "ship.testproject.org", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go deleted file mode 100644 index 0236bede36b..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/webhook_suite_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "runtime" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - admissionv1 "k8s.io/api/admission/v1" - // +kubebuilder:scaffold:imports - apimachineryruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var ( - cancel context.CancelFunc - cfg *rest.Config - ctx context.Context - k8sClient client.Client - testEnv *envtest.Environment -) - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Webhook Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "..", "config", "webhook")}, - }, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := apimachineryruntime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager. - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - WebhookServer: webhook.NewServer(webhook.Options{ - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - }), - LeaderElection: false, - Metrics: metricsserver.Options{BindAddress: "0"}, - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&Destroyer{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:webhook - - go func() { - defer GinkgoRecover() - err = mgr.Start(ctx) - Expect(err).NotTo(HaveOccurred()) - }() - - // wait for the webhook server to get ready. - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - - return conn.Close() - }).Should(Succeed()) -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/api/ship/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/ship/v1/zz_generated.deepcopy.go deleted file mode 100644 index ca3974a1d81..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Destroyer) DeepCopyInto(out *Destroyer) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destroyer. -func (in *Destroyer) DeepCopy() *Destroyer { - if in == nil { - return nil - } - out := new(Destroyer) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Destroyer) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DestroyerList) DeepCopyInto(out *DestroyerList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Destroyer, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestroyerList. -func (in *DestroyerList) DeepCopy() *DestroyerList { - if in == nil { - return nil - } - out := new(DestroyerList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DestroyerList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DestroyerSpec) DeepCopyInto(out *DestroyerSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestroyerSpec. -func (in *DestroyerSpec) DeepCopy() *DestroyerSpec { - if in == nil { - return nil - } - out := new(DestroyerSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DestroyerStatus) DeepCopyInto(out *DestroyerStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestroyerStatus. -func (in *DestroyerStatus) DeepCopy() *DestroyerStatus { - if in == nil { - return nil - } - out := new(DestroyerStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_types.go b/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_types.go deleted file mode 100644 index 7cfb6b61593..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// FrigateSpec defines the desired state of Frigate. -type FrigateSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Frigate. Edit frigate_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// FrigateStatus defines the observed state of Frigate. -type FrigateStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Frigate is the Schema for the frigates API. -type Frigate struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FrigateSpec `json:"spec,omitempty"` - Status FrigateStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// FrigateList contains a list of Frigate. -type FrigateList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Frigate `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Frigate{}, &FrigateList{}) -} diff --git a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook.go b/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook.go deleted file mode 100644 index c699e518551..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" -) - -// nolint:unused -// log is for logging in this package. -var frigatelog = logf.Log.WithName("frigate-resource") - -// SetupWebhookWithManager will setup the manager to manage the webhooks. -func (r *Frigate) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! diff --git a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook_test.go b/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook_test.go deleted file mode 100644 index 30de9e39d27..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1beta1/frigate_webhook_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - // TODO (user): Add any additional imports if needed -) - -var _ = Describe("Frigate Webhook", func() { - var ( - obj *Frigate - ) - - BeforeEach(func() { - obj = &Frigate{} - Expect(obj).NotTo(BeNil(), "Expected obj to be initialized") - - // TODO (user): Add any setup logic common to all tests - }) - - AfterEach(func() { - // TODO (user): Add any teardown logic common to all tests - }) - - Context("When creating Frigate under Conversion Webhook", func() { - It("Should convert the object correctly", func() { - // TODO (user): Add logic to convert the object to the desired version and verify the conversion - // Example: - // convertedObj := &Frigate{} - // err := obj.ConvertTo(convertedObj) - // Expect(err).NotTo(HaveOccurred()) - // Expect(convertedObj).ToNot(BeNil()) - }) - }) - -}) diff --git a/testdata/project-v4-multigroup/api/ship/v1beta1/groupversion_info.go b/testdata/project-v4-multigroup/api/ship/v1beta1/groupversion_info.go deleted file mode 100644 index f226e342def..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1beta1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1beta1 contains API Schema definitions for the ship v1beta1 API group. -// +kubebuilder:object:generate=true -// +groupName=ship.testproject.org -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "ship.testproject.org", Version: "v1beta1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/ship/v1beta1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/ship/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index bfcdcf442ae..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1beta1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Frigate) DeepCopyInto(out *Frigate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Frigate. -func (in *Frigate) DeepCopy() *Frigate { - if in == nil { - return nil - } - out := new(Frigate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Frigate) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FrigateList) DeepCopyInto(out *FrigateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Frigate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrigateList. -func (in *FrigateList) DeepCopy() *FrigateList { - if in == nil { - return nil - } - out := new(FrigateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FrigateList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FrigateSpec) DeepCopyInto(out *FrigateSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrigateSpec. -func (in *FrigateSpec) DeepCopy() *FrigateSpec { - if in == nil { - return nil - } - out := new(FrigateSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FrigateStatus) DeepCopyInto(out *FrigateStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrigateStatus. -func (in *FrigateStatus) DeepCopy() *FrigateStatus { - if in == nil { - return nil - } - out := new(FrigateStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_types.go b/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_types.go deleted file mode 100644 index 938e1343c1b..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_types.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v2alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// CruiserSpec defines the desired state of Cruiser. -type CruiserSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Cruiser. Edit cruiser_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// CruiserStatus defines the observed state of Cruiser. -type CruiserStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:scope=Cluster - -// Cruiser is the Schema for the cruisers API. -type Cruiser struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec CruiserSpec `json:"spec,omitempty"` - Status CruiserStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// CruiserList contains a list of Cruiser. -type CruiserList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Cruiser `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Cruiser{}, &CruiserList{}) -} diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/groupversion_info.go b/testdata/project-v4-multigroup/api/ship/v2alpha1/groupversion_info.go deleted file mode 100644 index 29c5dd6871a..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v2alpha1 contains API Schema definitions for the ship v2alpha1 API group. -// +kubebuilder:object:generate=true -// +groupName=ship.testproject.org -package v2alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "ship.testproject.org", Version: "v2alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/ship/v2alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 8f391c1cf27..00000000000 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v2alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Cruiser) DeepCopyInto(out *Cruiser) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cruiser. -func (in *Cruiser) DeepCopy() *Cruiser { - if in == nil { - return nil - } - out := new(Cruiser) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Cruiser) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CruiserList) DeepCopyInto(out *CruiserList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Cruiser, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CruiserList. -func (in *CruiserList) DeepCopy() *CruiserList { - if in == nil { - return nil - } - out := new(CruiserList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *CruiserList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CruiserSpec) DeepCopyInto(out *CruiserSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CruiserSpec. -func (in *CruiserSpec) DeepCopy() *CruiserSpec { - if in == nil { - return nil - } - out := new(CruiserSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CruiserStatus) DeepCopyInto(out *CruiserStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CruiserStatus. -func (in *CruiserStatus) DeepCopy() *CruiserStatus { - if in == nil { - return nil - } - out := new(CruiserStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/api/v1/groupversion_info.go b/testdata/project-v4-multigroup/api/v1/groupversion_info.go deleted file mode 100644 index 8526131ddeb..00000000000 --- a/testdata/project-v4-multigroup/api/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1 contains API Schema definitions for the v1 API group. -// +kubebuilder:object:generate=true -// +groupName=testproject.org -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "testproject.org", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/testdata/project-v4-multigroup/api/v1/lakers_types.go b/testdata/project-v4-multigroup/api/v1/lakers_types.go deleted file mode 100644 index a148268c765..00000000000 --- a/testdata/project-v4-multigroup/api/v1/lakers_types.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// LakersSpec defines the desired state of Lakers. -type LakersSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Foo is an example field of Lakers. Edit lakers_types.go to remove/update - Foo string `json:"foo,omitempty"` -} - -// LakersStatus defines the observed state of Lakers. -type LakersStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status - -// Lakers is the Schema for the lakers API. -type Lakers struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec LakersSpec `json:"spec,omitempty"` - Status LakersStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// LakersList contains a list of Lakers. -type LakersList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Lakers `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Lakers{}, &LakersList{}) -} diff --git a/testdata/project-v4-multigroup/api/v1/lakers_webhook.go b/testdata/project-v4-multigroup/api/v1/lakers_webhook.go deleted file mode 100644 index 0f1ac5df964..00000000000 --- a/testdata/project-v4-multigroup/api/v1/lakers_webhook.go +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "fmt" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" -) - -// nolint:unused -// log is for logging in this package. -var lakerslog = logf.Log.WithName("lakers-resource") - -// SetupWebhookWithManager will setup the manager to manage the webhooks. -func (r *Lakers) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - WithValidator(&LakersCustomValidator{}). - WithDefaulter(&LakersCustomDefaulter{}). - Complete() -} - -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - -// +kubebuilder:webhook:path=/mutate-testproject-org-v1-lakers,mutating=true,failurePolicy=fail,sideEffects=None,groups=testproject.org,resources=lakers,verbs=create;update,versions=v1,name=mlakers.kb.io,admissionReviewVersions=v1 - -// +kubebuilder:object:generate=false -// LakersCustomDefaulter struct is responsible for setting default values on the custom resource of the -// Kind Lakers when those are created or updated. -// -// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, -// as it is used only for temporary operations and does not need to be deeply copied. -type LakersCustomDefaulter struct { - // TODO(user): Add more fields as needed for defaulting -} - -var _ webhook.CustomDefaulter = &LakersCustomDefaulter{} - -// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind Lakers. -func (d *LakersCustomDefaulter) Default(ctx context.Context, obj runtime.Object) error { - lakers, ok := obj.(*Lakers) - if !ok { - return fmt.Errorf("expected an Lakers object but got %T", obj) - } - lakerslog.Info("Defaulting for Lakers", "name", lakers.GetName()) - - // TODO(user): fill in your defaulting logic. - - return nil -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here. -// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook. -// +kubebuilder:webhook:path=/validate-testproject-org-v1-lakers,mutating=false,failurePolicy=fail,sideEffects=None,groups=testproject.org,resources=lakers,verbs=create;update,versions=v1,name=vlakers.kb.io,admissionReviewVersions=v1 - -// +kubebuilder:object:generate=false -// LakersCustomValidator struct is responsible for validating the Lakers resource -// when it is created, updated, or deleted. -// -// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, -// as this struct is used only for temporary operations and does not need to be deeply copied. -type LakersCustomValidator struct { - //TODO(user): Add more fields as needed for validation -} - -var _ webhook.CustomValidator = &LakersCustomValidator{} - -// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Lakers. -func (v *LakersCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - lakers, ok := obj.(*Lakers) - if !ok { - return nil, fmt.Errorf("expected a Lakers object but got %T", obj) - } - lakerslog.Info("Validation for Lakers upon creation", "name", lakers.GetName()) - - // TODO(user): fill in your validation logic upon object creation. - - return nil, nil -} - -// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Lakers. -func (v *LakersCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - lakers, ok := newObj.(*Lakers) - if !ok { - return nil, fmt.Errorf("expected a Lakers object but got %T", newObj) - } - lakerslog.Info("Validation for Lakers upon update", "name", lakers.GetName()) - - // TODO(user): fill in your validation logic upon object update. - - return nil, nil -} - -// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Lakers. -func (v *LakersCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - lakers, ok := obj.(*Lakers) - if !ok { - return nil, fmt.Errorf("expected a Lakers object but got %T", obj) - } - lakerslog.Info("Validation for Lakers upon deletion", "name", lakers.GetName()) - - // TODO(user): fill in your validation logic upon object deletion. - - return nil, nil -} diff --git a/testdata/project-v4-multigroup/api/v1/lakers_webhook_test.go b/testdata/project-v4-multigroup/api/v1/lakers_webhook_test.go deleted file mode 100644 index f8c5018a91f..00000000000 --- a/testdata/project-v4-multigroup/api/v1/lakers_webhook_test.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - // TODO (user): Add any additional imports if needed -) - -var _ = Describe("Lakers Webhook", func() { - var ( - obj *Lakers - ) - - BeforeEach(func() { - obj = &Lakers{} - Expect(obj).NotTo(BeNil(), "Expected obj to be initialized") - - // TODO (user): Add any setup logic common to all tests - }) - - AfterEach(func() { - // TODO (user): Add any teardown logic common to all tests - }) - - Context("When creating Lakers under Defaulting Webhook", func() { - // TODO (user): Add logic for defaulting webhooks - // Example: - // It("Should apply defaults when a required field is empty", func() { - // By("simulating a scenario where defaults should be applied") - // obj.SomeFieldWithDefault = "" - // err := obj.Default(ctx) - // Expect(err).NotTo(HaveOccurred()) - // Expect(obj.SomeFieldWithDefault).To(Equal("default_value")) - // }) - }) - - Context("When creating or updating Lakers under Validating Webhook", func() { - // TODO (user): Add logic for validating webhooks - // Example: - // It("Should deny creation if a required field is missing", func() { - // By("simulating an invalid creation scenario") - // obj.SomeRequiredField = "" - // warnings, err := obj.ValidateCreate(ctx) - // Expect(err).To(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - // - // It("Should admit creation if all required fields are present", func() { - // By("simulating an invalid creation scenario") - // obj.SomeRequiredField = "valid_value" - // warnings, err := obj.ValidateCreate(ctx) - // Expect(err).NotTo(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - // - // It("Should validate updates correctly", func() { - // By("simulating a valid update scenario") - // oldObj := &Captain{SomeRequiredField: "valid_value"} - // obj.SomeRequiredField = "updated_value" - // warnings, err := obj.ValidateUpdate(ctx, oldObj) - // Expect(err).NotTo(HaveOccurred()) - // Expect(warnings).To(BeNil()) - // }) - }) - -}) diff --git a/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go b/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go deleted file mode 100644 index d7ad1aa1c95..00000000000 --- a/testdata/project-v4-multigroup/api/v1/webhook_suite_test.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1 - -import ( - "context" - "crypto/tls" - "fmt" - "net" - "path/filepath" - "runtime" - "testing" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - admissionv1 "k8s.io/api/admission/v1" - // +kubebuilder:scaffold:imports - apimachineryruntime "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var ( - cancel context.CancelFunc - cfg *rest.Config - ctx context.Context - k8sClient client.Client - testEnv *envtest.Environment -) - -func TestAPIs(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Webhook Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - - WebhookInstallOptions: envtest.WebhookInstallOptions{ - Paths: []string{filepath.Join("..", "..", "config", "webhook")}, - }, - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - scheme := apimachineryruntime.NewScheme() - err = AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - err = admissionv1.AddToScheme(scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - - // start webhook server using Manager. - webhookInstallOptions := &testEnv.WebhookInstallOptions - mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - WebhookServer: webhook.NewServer(webhook.Options{ - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - }), - LeaderElection: false, - Metrics: metricsserver.Options{BindAddress: "0"}, - }) - Expect(err).NotTo(HaveOccurred()) - - err = (&Lakers{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:webhook - - go func() { - defer GinkgoRecover() - err = mgr.Start(ctx) - Expect(err).NotTo(HaveOccurred()) - }() - - // wait for the webhook server to get ready. - dialer := &net.Dialer{Timeout: time.Second} - addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort) - Eventually(func() error { - conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return err - } - - return conn.Close() - }).Should(Succeed()) -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/api/v1/zz_generated.deepcopy.go b/testdata/project-v4-multigroup/api/v1/zz_generated.deepcopy.go deleted file mode 100644 index 64e471813a8..00000000000 --- a/testdata/project-v4-multigroup/api/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by controller-gen. DO NOT EDIT. - -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Lakers) DeepCopyInto(out *Lakers) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Lakers. -func (in *Lakers) DeepCopy() *Lakers { - if in == nil { - return nil - } - out := new(Lakers) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Lakers) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LakersList) DeepCopyInto(out *LakersList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Lakers, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LakersList. -func (in *LakersList) DeepCopy() *LakersList { - if in == nil { - return nil - } - out := new(LakersList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *LakersList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LakersSpec) DeepCopyInto(out *LakersSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LakersSpec. -func (in *LakersSpec) DeepCopy() *LakersSpec { - if in == nil { - return nil - } - out := new(LakersSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LakersStatus) DeepCopyInto(out *LakersStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LakersStatus. -func (in *LakersStatus) DeepCopy() *LakersStatus { - if in == nil { - return nil - } - out := new(LakersStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-multigroup/cmd/main.go b/testdata/project-v4-multigroup/cmd/main.go deleted file mode 100644 index 2057d6eaef1..00000000000 --- a/testdata/project-v4-multigroup/cmd/main.go +++ /dev/null @@ -1,300 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "crypto/tls" - "flag" - "os" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/healthz" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/controller-runtime/pkg/metrics/filters" - metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "sigs.k8s.io/controller-runtime/pkg/webhook" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/crew/v1" - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/fiz/v1" - foopolicyv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo.policy/v1" - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo/v1" - seacreaturesv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta1" - seacreaturesv1beta2 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/sea-creatures/v1beta2" - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1beta1" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v2alpha1" - testprojectorgv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/v1" - "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller" - appscontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/apps" - crewcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/crew" - fizcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/fiz" - foocontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/foo" - foopolicycontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/foo.policy" - seacreaturescontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/sea-creatures" - shipcontroller "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/internal/controller/ship" - // +kubebuilder:scaffold:imports -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - - utilruntime.Must(crewv1.AddToScheme(scheme)) - utilruntime.Must(shipv1beta1.AddToScheme(scheme)) - utilruntime.Must(shipv1.AddToScheme(scheme)) - utilruntime.Must(shipv2alpha1.AddToScheme(scheme)) - utilruntime.Must(seacreaturesv1beta1.AddToScheme(scheme)) - utilruntime.Must(seacreaturesv1beta2.AddToScheme(scheme)) - utilruntime.Must(foopolicyv1.AddToScheme(scheme)) - utilruntime.Must(foov1.AddToScheme(scheme)) - utilruntime.Must(fizv1.AddToScheme(scheme)) - utilruntime.Must(testprojectorgv1.AddToScheme(scheme)) - // +kubebuilder:scaffold:scheme -} - -func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - var secureMetrics bool - var enableHTTP2 bool - var tlsOpts []func(*tls.Config) - flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+ - "Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.") - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.BoolVar(&enableLeaderElection, "leader-elect", false, - "Enable leader election for controller manager. "+ - "Enabling this will ensure there is only one active controller manager.") - flag.BoolVar(&secureMetrics, "metrics-secure", true, - "If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.") - flag.BoolVar(&enableHTTP2, "enable-http2", false, - "If set, HTTP/2 will be enabled for the metrics and webhook servers") - opts := zap.Options{ - Development: true, - } - opts.BindFlags(flag.CommandLine) - flag.Parse() - - ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - - // if the enable-http2 flag is false (the default), http/2 should be disabled - // due to its vulnerabilities. More specifically, disabling http/2 will - // prevent from being vulnerable to the HTTP/2 Stream Cancellation and - // Rapid Reset CVEs. For more information see: - // - https://github.com/advisories/GHSA-qppj-fm5r-hxr3 - // - https://github.com/advisories/GHSA-4374-p667-p6c8 - disableHTTP2 := func(c *tls.Config) { - setupLog.Info("disabling http/2") - c.NextProtos = []string{"http/1.1"} - } - - if !enableHTTP2 { - tlsOpts = append(tlsOpts, disableHTTP2) - } - - webhookServer := webhook.NewServer(webhook.Options{ - TLSOpts: tlsOpts, - }) - - // Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server. - // More info: - // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/metrics/server - // - https://book.kubebuilder.io/reference/metrics.html - metricsServerOptions := metricsserver.Options{ - BindAddress: metricsAddr, - SecureServing: secureMetrics, - // TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are - // not provided, self-signed certificates will be generated by default. This option is not recommended for - // production environments as self-signed certificates do not offer the same level of trust and security - // as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing - // unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName - // to provide certificates, ensuring the server communicates using trusted and secure certificates. - TLSOpts: tlsOpts, - } - - if secureMetrics { - // FilterProvider is used to protect the metrics endpoint with authn/authz. - // These configurations ensure that only authorized users and service accounts - // can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info: - // https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/metrics/filters#WithAuthenticationAndAuthorization - metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - Metrics: metricsServerOptions, - WebhookServer: webhookServer, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "3e9f67a9.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) - if err != nil { - setupLog.Error(err, "unable to start manager") - os.Exit(1) - } - - if err = (&crewcontroller.CaptainReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Captain") - os.Exit(1) - } - // nolint:goconst - if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Captain") - os.Exit(1) - } - } - if err = (&shipcontroller.FrigateReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Frigate") - os.Exit(1) - } - // nolint:goconst - if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&shipv1beta1.Frigate{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Frigate") - os.Exit(1) - } - } - if err = (&shipcontroller.DestroyerReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Destroyer") - os.Exit(1) - } - // nolint:goconst - if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&shipv1.Destroyer{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Destroyer") - os.Exit(1) - } - } - if err = (&shipcontroller.CruiserReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Cruiser") - os.Exit(1) - } - // nolint:goconst - if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&shipv2alpha1.Cruiser{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Cruiser") - os.Exit(1) - } - } - if err = (&seacreaturescontroller.KrakenReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Kraken") - os.Exit(1) - } - if err = (&seacreaturescontroller.LeviathanReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Leviathan") - os.Exit(1) - } - if err = (&foopolicycontroller.HealthCheckPolicyReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "HealthCheckPolicy") - os.Exit(1) - } - if err = (&appscontroller.DeploymentReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Deployment") - os.Exit(1) - } - if err = (&foocontroller.BarReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Bar") - os.Exit(1) - } - if err = (&fizcontroller.BarReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Bar") - os.Exit(1) - } - if err = (&controller.LakersReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Lakers") - os.Exit(1) - } - // nolint:goconst - if os.Getenv("ENABLE_WEBHOOKS") != "false" { - if err = (&testprojectorgv1.Lakers{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "Lakers") - os.Exit(1) - } - } - // +kubebuilder:scaffold:builder - - if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up health check") - os.Exit(1) - } - if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up ready check") - os.Exit(1) - } - - setupLog.Info("starting manager") - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { - setupLog.Error(err, "problem running manager") - os.Exit(1) - } -} diff --git a/testdata/project-v4-multigroup/config/crd/bases/crew.testproject.org_captains.yaml b/testdata/project-v4-multigroup/config/crd/bases/crew.testproject.org_captains.yaml deleted file mode 100644 index 5499f347d11..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/crew.testproject.org_captains.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: captains.crew.testproject.org -spec: - group: crew.testproject.org - names: - kind: Captain - listKind: CaptainList - plural: captains - singular: captain - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Captain is the Schema for the captains API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: CaptainSpec defines the desired state of Captain. - properties: - foo: - description: Foo is an example field of Captain. Edit captain_types.go - to remove/update - type: string - type: object - status: - description: CaptainStatus defines the observed state of Captain. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/fiz.testproject.org_bars.yaml b/testdata/project-v4-multigroup/config/crd/bases/fiz.testproject.org_bars.yaml deleted file mode 100644 index 1971d64f436..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/fiz.testproject.org_bars.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: bars.fiz.testproject.org -spec: - group: fiz.testproject.org - names: - kind: Bar - listKind: BarList - plural: bars - singular: bar - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Bar is the Schema for the bars API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: BarSpec defines the desired state of Bar. - properties: - foo: - description: Foo is an example field of Bar. Edit bar_types.go to - remove/update - type: string - type: object - status: - description: BarStatus defines the observed state of Bar. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml b/testdata/project-v4-multigroup/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml deleted file mode 100644 index 7088c3ab741..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/foo.policy.testproject.org_healthcheckpolicies.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: healthcheckpolicies.foo.policy.testproject.org -spec: - group: foo.policy.testproject.org - names: - kind: HealthCheckPolicy - listKind: HealthCheckPolicyList - plural: healthcheckpolicies - singular: healthcheckpolicy - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: HealthCheckPolicy is the Schema for the healthcheckpolicies API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: HealthCheckPolicySpec defines the desired state of HealthCheckPolicy. - properties: - foo: - description: Foo is an example field of HealthCheckPolicy. Edit healthcheckpolicy_types.go - to remove/update - type: string - type: object - status: - description: HealthCheckPolicyStatus defines the observed state of HealthCheckPolicy. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/foo.testproject.org_bars.yaml b/testdata/project-v4-multigroup/config/crd/bases/foo.testproject.org_bars.yaml deleted file mode 100644 index 32ffdd88d12..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/foo.testproject.org_bars.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: bars.foo.testproject.org -spec: - group: foo.testproject.org - names: - kind: Bar - listKind: BarList - plural: bars - singular: bar - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Bar is the Schema for the bars API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: BarSpec defines the desired state of Bar. - properties: - foo: - description: Foo is an example field of Bar. Edit bar_types.go to - remove/update - type: string - type: object - status: - description: BarStatus defines the observed state of Bar. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_krakens.yaml b/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_krakens.yaml deleted file mode 100644 index 08aab1b3257..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_krakens.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: krakens.sea-creatures.testproject.org -spec: - group: sea-creatures.testproject.org - names: - kind: Kraken - listKind: KrakenList - plural: krakens - singular: kraken - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: Kraken is the Schema for the krakens API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: KrakenSpec defines the desired state of Kraken. - properties: - foo: - description: Foo is an example field of Kraken. Edit kraken_types.go - to remove/update - type: string - type: object - status: - description: KrakenStatus defines the observed state of Kraken. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml b/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml deleted file mode 100644 index 8b37bcfe0e7..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/sea-creatures.testproject.org_leviathans.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: leviathans.sea-creatures.testproject.org -spec: - group: sea-creatures.testproject.org - names: - kind: Leviathan - listKind: LeviathanList - plural: leviathans - singular: leviathan - scope: Namespaced - versions: - - name: v1beta2 - schema: - openAPIV3Schema: - description: Leviathan is the Schema for the leviathans API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: LeviathanSpec defines the desired state of Leviathan. - properties: - foo: - description: Foo is an example field of Leviathan. Edit leviathan_types.go - to remove/update - type: string - type: object - status: - description: LeviathanStatus defines the observed state of Leviathan. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_cruisers.yaml b/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_cruisers.yaml deleted file mode 100644 index e107bf28de5..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_cruisers.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: cruisers.ship.testproject.org -spec: - group: ship.testproject.org - names: - kind: Cruiser - listKind: CruiserList - plural: cruisers - singular: cruiser - scope: Cluster - versions: - - name: v2alpha1 - schema: - openAPIV3Schema: - description: Cruiser is the Schema for the cruisers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: CruiserSpec defines the desired state of Cruiser. - properties: - foo: - description: Foo is an example field of Cruiser. Edit cruiser_types.go - to remove/update - type: string - type: object - status: - description: CruiserStatus defines the observed state of Cruiser. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_destroyers.yaml b/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_destroyers.yaml deleted file mode 100644 index 44eee9402b5..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_destroyers.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: destroyers.ship.testproject.org -spec: - group: ship.testproject.org - names: - kind: Destroyer - listKind: DestroyerList - plural: destroyers - singular: destroyer - scope: Cluster - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Destroyer is the Schema for the destroyers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: DestroyerSpec defines the desired state of Destroyer. - properties: - foo: - description: Foo is an example field of Destroyer. Edit destroyer_types.go - to remove/update - type: string - type: object - status: - description: DestroyerStatus defines the observed state of Destroyer. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_frigates.yaml b/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_frigates.yaml deleted file mode 100644 index 9b59c549943..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/ship.testproject.org_frigates.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: frigates.ship.testproject.org -spec: - group: ship.testproject.org - names: - kind: Frigate - listKind: FrigateList - plural: frigates - singular: frigate - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: Frigate is the Schema for the frigates API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: FrigateSpec defines the desired state of Frigate. - properties: - foo: - description: Foo is an example field of Frigate. Edit frigate_types.go - to remove/update - type: string - type: object - status: - description: FrigateStatus defines the observed state of Frigate. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/bases/testproject.org_lakers.yaml b/testdata/project-v4-multigroup/config/crd/bases/testproject.org_lakers.yaml deleted file mode 100644 index 5650de192d7..00000000000 --- a/testdata/project-v4-multigroup/config/crd/bases/testproject.org_lakers.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: lakers.testproject.org -spec: - group: testproject.org - names: - kind: Lakers - listKind: LakersList - plural: lakers - singular: lakers - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Lakers is the Schema for the lakers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: LakersSpec defines the desired state of Lakers. - properties: - foo: - description: Foo is an example field of Lakers. Edit lakers_types.go - to remove/update - type: string - type: object - status: - description: LakersStatus defines the observed state of Lakers. - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-multigroup/config/crd/kustomization.yaml b/testdata/project-v4-multigroup/config/crd/kustomization.yaml deleted file mode 100644 index c9e3a747c5e..00000000000 --- a/testdata/project-v4-multigroup/config/crd/kustomization.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# This kustomization.yaml is not intended to be run by itself, -# since it depends on service name and namespace that are out of this kustomize package. -# It should be run by config/default -resources: -- bases/crew.testproject.org_captains.yaml -- bases/ship.testproject.org_frigates.yaml -- bases/ship.testproject.org_destroyers.yaml -- bases/ship.testproject.org_cruisers.yaml -- bases/sea-creatures.testproject.org_krakens.yaml -- bases/sea-creatures.testproject.org_leviathans.yaml -- bases/foo.policy.testproject.org_healthcheckpolicies.yaml -- bases/foo.testproject.org_bars.yaml -- bases/fiz.testproject.org_bars.yaml -- bases/testproject.org_lakers.yaml -# +kubebuilder:scaffold:crdkustomizeresource - -patches: -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. -# patches here are for enabling the conversion webhook for each CRD -- path: patches/webhook_in_crew_captains.yaml -- path: patches/webhook_in_ship_frigates.yaml -- path: patches/webhook_in_ship_destroyers.yaml -- path: patches/webhook_in_ship_cruisers.yaml -- path: patches/webhook_in_lakers.yaml -# +kubebuilder:scaffold:crdkustomizewebhookpatch - -# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. -# patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_crew_captains.yaml -#- path: patches/cainjection_in_ship_frigates.yaml -#- path: patches/cainjection_in_ship_destroyers.yaml -#- path: patches/cainjection_in_ship_cruisers.yaml -#- path: patches/cainjection_in_sea-creatures_krakens.yaml -#- path: patches/cainjection_in_sea-creatures_leviathans.yaml -#- path: patches/cainjection_in_foo.policy_healthcheckpolicies.yaml -#- path: patches/cainjection_in_foo_bars.yaml -#- path: patches/cainjection_in_fiz_bars.yaml -#- path: patches/cainjection_in_lakers.yaml -# +kubebuilder:scaffold:crdkustomizecainjectionpatch - -# [WEBHOOK] To enable webhook, uncomment the following section -# the following config is for teaching kustomize how to do kustomization for CRDs. - -configurations: -- kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_lakers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_lakers.yaml deleted file mode 100644 index 90be9dfc598..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_lakers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: lakers.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml deleted file mode 100644 index 0d31cb0b8af..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_cruisers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: cruisers.ship.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml deleted file mode 100644 index 865395574ff..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_destroyers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: destroyers.ship.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_frigates.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_frigates.yaml deleted file mode 100644 index d4acb9d24c1..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_ship_frigates.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: frigates.ship.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_lakers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_lakers.yaml deleted file mode 100644 index 58df2264dde..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_lakers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: lakers.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml deleted file mode 100644 index 99b6b6741b6..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_cruisers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: cruisers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml deleted file mode 100644 index 0e0095cb3a6..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_destroyers.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: destroyers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_frigates.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_frigates.yaml deleted file mode 100644 index cdc5078ae71..00000000000 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_ship_frigates.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: frigates.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-multigroup/config/default/metrics_service.yaml b/testdata/project-v4-multigroup/config/default/metrics_service.yaml deleted file mode 100644 index afd67bb43af..00000000000 --- a/testdata/project-v4-multigroup/config/default/metrics_service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-service - namespace: system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: 8443 - selector: - control-plane: controller-manager diff --git a/testdata/project-v4-multigroup/config/manager/manager.yaml b/testdata/project-v4-multigroup/config/manager/manager.yaml deleted file mode 100644 index 3691f15c77e..00000000000 --- a/testdata/project-v4-multigroup/config/manager/manager.yaml +++ /dev/null @@ -1,95 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup - app.kubernetes.io/managed-by: kustomize - name: system ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup - app.kubernetes.io/managed-by: kustomize -spec: - selector: - matchLabels: - control-plane: controller-manager - replicas: 1 - template: - metadata: - annotations: - kubectl.kubernetes.io/default-container: manager - labels: - control-plane: controller-manager - spec: - # TODO(user): Uncomment the following code to configure the nodeAffinity expression - # according to the platforms which are supported by your solution. - # It is considered best practice to support multiple architectures. You can - # build your manager image using the makefile target docker-buildx. - # affinity: - # nodeAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # nodeSelectorTerms: - # - matchExpressions: - # - key: kubernetes.io/arch - # operator: In - # values: - # - amd64 - # - arm64 - # - ppc64le - # - s390x - # - key: kubernetes.io/os - # operator: In - # values: - # - linux - securityContext: - runAsNonRoot: true - # TODO(user): For common cases that do not require escalating privileges - # it is recommended to ensure that all your Pods/Containers are restrictive. - # More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted - # Please uncomment the following code if your project does NOT have to work on old Kubernetes - # versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ). - # seccompProfile: - # type: RuntimeDefault - containers: - - command: - - /manager - args: - - --leader-elect - - --health-probe-bind-address=:8081 - image: controller:latest - name: manager - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - "ALL" - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - # TODO(user): Configure the resources accordingly based on the project requirements. - # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 10m - memory: 64Mi - serviceAccountName: controller-manager - terminationGracePeriodSeconds: 10 diff --git a/testdata/project-v4-multigroup/config/rbac/kustomization.yaml b/testdata/project-v4-multigroup/config/rbac/kustomization.yaml deleted file mode 100644 index 5bdd66e47ff..00000000000 --- a/testdata/project-v4-multigroup/config/rbac/kustomization.yaml +++ /dev/null @@ -1,45 +0,0 @@ -resources: -# All RBAC will be applied under this service account in -# the deployment namespace. You may comment out this resource -# if your manager will use a service account that exists at -# runtime. Be sure to update RoleBinding and ClusterRoleBinding -# subjects if changing service account names. -- service_account.yaml -- role.yaml -- role_binding.yaml -- leader_election_role.yaml -- leader_election_role_binding.yaml -# The following RBAC configurations are used to protect -# the metrics endpoint with authn/authz. These configurations -# ensure that only authorized users and service accounts -# can access the metrics endpoint. Comment the following -# permissions if you want to disable this protection. -# More info: https://book.kubebuilder.io/reference/metrics.html -- metrics_auth_role.yaml -- metrics_auth_role_binding.yaml -- metrics_reader_role.yaml -# For each CRD, "Editor" and "Viewer" roles are scaffolded by -# default, aiding admins in cluster management. Those roles are -# not used by the Project itself. You can comment the following lines -# if you do not want those helpers be installed with your Project. -- lakers_editor_role.yaml -- lakers_viewer_role.yaml -- fiz_bar_editor_role.yaml -- fiz_bar_viewer_role.yaml -- foo_bar_editor_role.yaml -- foo_bar_viewer_role.yaml -- foo.policy_healthcheckpolicy_editor_role.yaml -- foo.policy_healthcheckpolicy_viewer_role.yaml -- sea-creatures_leviathan_editor_role.yaml -- sea-creatures_leviathan_viewer_role.yaml -- sea-creatures_kraken_editor_role.yaml -- sea-creatures_kraken_viewer_role.yaml -- ship_cruiser_editor_role.yaml -- ship_cruiser_viewer_role.yaml -- ship_destroyer_editor_role.yaml -- ship_destroyer_viewer_role.yaml -- ship_frigate_editor_role.yaml -- ship_frigate_viewer_role.yaml -- crew_captain_editor_role.yaml -- crew_captain_viewer_role.yaml - diff --git a/testdata/project-v4-multigroup/config/rbac/role.yaml b/testdata/project-v4-multigroup/config/rbac/role.yaml deleted file mode 100644 index b3e54a59959..00000000000 --- a/testdata/project-v4-multigroup/config/rbac/role.yaml +++ /dev/null @@ -1,200 +0,0 @@ ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: manager-role -rules: -- apiGroups: - - apps - resources: - - deployments - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps - resources: - - deployments/finalizers - verbs: - - update -- apiGroups: - - apps - resources: - - deployments/status - verbs: - - get - - patch - - update -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/finalizers - verbs: - - update -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get - - patch - - update -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars/finalizers - verbs: - - update -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars/status - verbs: - - get - - patch - - update -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/finalizers - verbs: - - update -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get - - patch - - update -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - - leviathans - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/finalizers - - leviathans/finalizers - verbs: - - update -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - - leviathans/status - verbs: - - get - - patch - - update -- apiGroups: - - ship.testproject.org - resources: - - cruisers - - destroyers - - frigates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/finalizers - - destroyers/finalizers - - frigates/finalizers - verbs: - - update -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - - destroyers/status - - frigates/status - verbs: - - get - - patch - - update -- apiGroups: - - testproject.org - resources: - - lakers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - testproject.org - resources: - - lakers/finalizers - verbs: - - update -- apiGroups: - - testproject.org - resources: - - lakers/status - verbs: - - get - - patch - - update diff --git a/testdata/project-v4-multigroup/config/rbac/role_binding.yaml b/testdata/project-v4-multigroup/config/rbac/role_binding.yaml deleted file mode 100644 index ae53b6529da..00000000000 --- a/testdata/project-v4-multigroup/config/rbac/role_binding.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: project-v4-multigroup - app.kubernetes.io/managed-by: kustomize - name: manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: manager-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-multigroup/config/webhook/manifests.yaml b/testdata/project-v4-multigroup/config/webhook/manifests.yaml deleted file mode 100644 index 62374002227..00000000000 --- a/testdata/project-v4-multigroup/config/webhook/manifests.yaml +++ /dev/null @@ -1,132 +0,0 @@ ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: MutatingWebhookConfiguration -metadata: - name: mutating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /mutate-crew-testproject-org-v1-captain - failurePolicy: Fail - name: mcaptain.kb.io - rules: - - apiGroups: - - crew.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - captains - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /mutate-ship-testproject-org-v1-destroyer - failurePolicy: Fail - name: mdestroyer.kb.io - rules: - - apiGroups: - - ship.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - destroyers - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /mutate-testproject-org-v1-lakers - failurePolicy: Fail - name: mlakers.kb.io - rules: - - apiGroups: - - testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - lakers - sideEffects: None ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - name: validating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-crew-testproject-org-v1-captain - failurePolicy: Fail - name: vcaptain.kb.io - rules: - - apiGroups: - - crew.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - captains - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-ship-testproject-org-v2alpha1-cruiser - failurePolicy: Fail - name: vcruiser.kb.io - rules: - - apiGroups: - - ship.testproject.org - apiVersions: - - v2alpha1 - operations: - - CREATE - - UPDATE - resources: - - cruisers - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-testproject-org-v1-lakers - failurePolicy: Fail - name: vlakers.kb.io - rules: - - apiGroups: - - testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - lakers - sideEffects: None diff --git a/testdata/project-v4-multigroup/dist/install.yaml b/testdata/project-v4-multigroup/dist/install.yaml deleted file mode 100644 index c36d223d3ec..00000000000 --- a/testdata/project-v4-multigroup/dist/install.yaml +++ /dev/null @@ -1,1660 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - control-plane: controller-manager - name: project-v4-multigroup-system ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: bars.fiz.testproject.org -spec: - group: fiz.testproject.org - names: - kind: Bar - listKind: BarList - plural: bars - singular: bar - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Bar is the Schema for the bars API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: BarSpec defines the desired state of Bar. - properties: - foo: - description: Foo is an example field of Bar. Edit bar_types.go to - remove/update - type: string - type: object - status: - description: BarStatus defines the observed state of Bar. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: bars.foo.testproject.org -spec: - group: foo.testproject.org - names: - kind: Bar - listKind: BarList - plural: bars - singular: bar - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Bar is the Schema for the bars API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: BarSpec defines the desired state of Bar. - properties: - foo: - description: Foo is an example field of Bar. Edit bar_types.go to - remove/update - type: string - type: object - status: - description: BarStatus defines the observed state of Bar. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: captains.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 - group: crew.testproject.org - names: - kind: Captain - listKind: CaptainList - plural: captains - singular: captain - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Captain is the Schema for the captains API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: CaptainSpec defines the desired state of Captain. - properties: - foo: - description: Foo is an example field of Captain. Edit captain_types.go - to remove/update - type: string - type: object - status: - description: CaptainStatus defines the observed state of Captain. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: cruisers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 - group: ship.testproject.org - names: - kind: Cruiser - listKind: CruiserList - plural: cruisers - singular: cruiser - scope: Cluster - versions: - - name: v2alpha1 - schema: - openAPIV3Schema: - description: Cruiser is the Schema for the cruisers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: CruiserSpec defines the desired state of Cruiser. - properties: - foo: - description: Foo is an example field of Cruiser. Edit cruiser_types.go - to remove/update - type: string - type: object - status: - description: CruiserStatus defines the observed state of Cruiser. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: destroyers.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 - group: ship.testproject.org - names: - kind: Destroyer - listKind: DestroyerList - plural: destroyers - singular: destroyer - scope: Cluster - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Destroyer is the Schema for the destroyers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: DestroyerSpec defines the desired state of Destroyer. - properties: - foo: - description: Foo is an example field of Destroyer. Edit destroyer_types.go - to remove/update - type: string - type: object - status: - description: DestroyerStatus defines the observed state of Destroyer. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: frigates.ship.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 - group: ship.testproject.org - names: - kind: Frigate - listKind: FrigateList - plural: frigates - singular: frigate - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: Frigate is the Schema for the frigates API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: FrigateSpec defines the desired state of Frigate. - properties: - foo: - description: Foo is an example field of Frigate. Edit frigate_types.go - to remove/update - type: string - type: object - status: - description: FrigateStatus defines the observed state of Frigate. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: healthcheckpolicies.foo.policy.testproject.org -spec: - group: foo.policy.testproject.org - names: - kind: HealthCheckPolicy - listKind: HealthCheckPolicyList - plural: healthcheckpolicies - singular: healthcheckpolicy - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: HealthCheckPolicy is the Schema for the healthcheckpolicies API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: HealthCheckPolicySpec defines the desired state of HealthCheckPolicy. - properties: - foo: - description: Foo is an example field of HealthCheckPolicy. Edit healthcheckpolicy_types.go - to remove/update - type: string - type: object - status: - description: HealthCheckPolicyStatus defines the observed state of HealthCheckPolicy. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: krakens.sea-creatures.testproject.org -spec: - group: sea-creatures.testproject.org - names: - kind: Kraken - listKind: KrakenList - plural: krakens - singular: kraken - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: Kraken is the Schema for the krakens API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: KrakenSpec defines the desired state of Kraken. - properties: - foo: - description: Foo is an example field of Kraken. Edit kraken_types.go - to remove/update - type: string - type: object - status: - description: KrakenStatus defines the observed state of Kraken. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: lakers.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /convert - conversionReviewVersions: - - v1 - group: testproject.org - names: - kind: Lakers - listKind: LakersList - plural: lakers - singular: lakers - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Lakers is the Schema for the lakers API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: LakersSpec defines the desired state of Lakers. - properties: - foo: - description: Foo is an example field of Lakers. Edit lakers_types.go - to remove/update - type: string - type: object - status: - description: LakersStatus defines the observed state of Lakers. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.1 - name: leviathans.sea-creatures.testproject.org -spec: - group: sea-creatures.testproject.org - names: - kind: Leviathan - listKind: LeviathanList - plural: leviathans - singular: leviathan - scope: Namespaced - versions: - - name: v1beta2 - schema: - openAPIV3Schema: - description: Leviathan is the Schema for the leviathans API. - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - description: LeviathanSpec defines the desired state of Leviathan. - properties: - foo: - description: Foo is an example field of Leviathan. Edit leviathan_types.go - to remove/update - type: string - type: object - status: - description: LeviathanStatus defines the observed state of Leviathan. - type: object - type: object - served: true - storage: true - subresources: - status: {} ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-controller-manager - namespace: project-v4-multigroup-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-leader-election-role - namespace: project-v4-multigroup-system -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-crew-captain-editor-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-crew-captain-viewer-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - get - - list - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-fiz-bar-editor-role -rules: -- apiGroups: - - fiz.testproject.org - resources: - - bars - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - fiz.testproject.org - resources: - - bars/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-fiz-bar-viewer-role -rules: -- apiGroups: - - fiz.testproject.org - resources: - - bars - verbs: - - get - - list - - watch -- apiGroups: - - fiz.testproject.org - resources: - - bars/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-foo-bar-editor-role -rules: -- apiGroups: - - foo.testproject.org - resources: - - bars - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.testproject.org - resources: - - bars/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-foo-bar-viewer-role -rules: -- apiGroups: - - foo.testproject.org - resources: - - bars - verbs: - - get - - list - - watch -- apiGroups: - - foo.testproject.org - resources: - - bars/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-foo.policy-healthcheckpolicy-editor-role -rules: -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-foo.policy-healthcheckpolicy-viewer-role -rules: -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - get - - list - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-lakers-editor-role -rules: -- apiGroups: - - testproject.org - resources: - - lakers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - testproject.org - resources: - - lakers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-lakers-viewer-role -rules: -- apiGroups: - - testproject.org - resources: - - lakers - verbs: - - get - - list - - watch -- apiGroups: - - testproject.org - resources: - - lakers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: project-v4-multigroup-manager-role -rules: -- apiGroups: - - apps - resources: - - deployments - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - apps - resources: - - deployments/finalizers - verbs: - - update -- apiGroups: - - apps - resources: - - deployments/status - verbs: - - get - - patch - - update -- apiGroups: - - crew.testproject.org - resources: - - captains - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - captains/finalizers - verbs: - - update -- apiGroups: - - crew.testproject.org - resources: - - captains/status - verbs: - - get - - patch - - update -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars/finalizers - verbs: - - update -- apiGroups: - - fiz.testproject.org - - foo.testproject.org - resources: - - bars/status - verbs: - - get - - patch - - update -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/finalizers - verbs: - - update -- apiGroups: - - foo.policy.testproject.org - resources: - - healthcheckpolicies/status - verbs: - - get - - patch - - update -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - - leviathans - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/finalizers - - leviathans/finalizers - verbs: - - update -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - - leviathans/status - verbs: - - get - - patch - - update -- apiGroups: - - ship.testproject.org - resources: - - cruisers - - destroyers - - frigates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/finalizers - - destroyers/finalizers - - frigates/finalizers - verbs: - - update -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - - destroyers/status - - frigates/status - verbs: - - get - - patch - - update -- apiGroups: - - testproject.org - resources: - - lakers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - testproject.org - resources: - - lakers/finalizers - verbs: - - update -- apiGroups: - - testproject.org - resources: - - lakers/status - verbs: - - get - - patch - - update ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: project-v4-multigroup-metrics-auth-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: project-v4-multigroup-metrics-reader -rules: -- nonResourceURLs: - - /metrics - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-sea-creatures-kraken-editor-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-sea-creatures-kraken-viewer-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens - verbs: - - get - - list - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - krakens/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-sea-creatures-leviathan-editor-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-sea-creatures-leviathan-viewer-role -rules: -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans - verbs: - - get - - list - - watch -- apiGroups: - - sea-creatures.testproject.org - resources: - - leviathans/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-cruiser-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - cruisers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-cruiser-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - cruisers - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - cruisers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-destroyer-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - destroyers - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - destroyers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-destroyer-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - destroyers - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - destroyers/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-frigate-editor-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - frigates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - ship.testproject.org - resources: - - frigates/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-ship-frigate-viewer-role -rules: -- apiGroups: - - ship.testproject.org - resources: - - frigates - verbs: - - get - - list - - watch -- apiGroups: - - ship.testproject.org - resources: - - frigates/status - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-leader-election-rolebinding - namespace: project-v4-multigroup-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: project-v4-multigroup-leader-election-role -subjects: -- kind: ServiceAccount - name: project-v4-multigroup-controller-manager - namespace: project-v4-multigroup-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: project-v4-multigroup-manager-role -subjects: -- kind: ServiceAccount - name: project-v4-multigroup-controller-manager - namespace: project-v4-multigroup-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: project-v4-multigroup-metrics-auth-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: project-v4-multigroup-metrics-auth-role -subjects: -- kind: ServiceAccount - name: project-v4-multigroup-controller-manager - namespace: project-v4-multigroup-system ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - control-plane: controller-manager - name: project-v4-multigroup-controller-manager-metrics-service - namespace: project-v4-multigroup-system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: 8443 - selector: - control-plane: controller-manager ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system -spec: - ports: - - port: 443 - protocol: TCP - targetPort: 9443 - selector: - control-plane: controller-manager ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-multigroup - control-plane: controller-manager - name: project-v4-multigroup-controller-manager - namespace: project-v4-multigroup-system -spec: - replicas: 1 - selector: - matchLabels: - control-plane: controller-manager - template: - metadata: - annotations: - kubectl.kubernetes.io/default-container: manager - labels: - control-plane: controller-manager - spec: - containers: - - args: - - --metrics-bind-address=:8443 - - --leader-elect - - --health-probe-bind-address=:8081 - command: - - /manager - image: controller:latest - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - name: manager - ports: - - containerPort: 9443 - name: webhook-server - protocol: TCP - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 10m - memory: 64Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - volumeMounts: - - mountPath: /tmp/k8s-webhook-server/serving-certs - name: cert - readOnly: true - securityContext: - runAsNonRoot: true - serviceAccountName: project-v4-multigroup-controller-manager - terminationGracePeriodSeconds: 10 - volumes: - - name: cert - secret: - defaultMode: 420 - secretName: webhook-server-cert ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: MutatingWebhookConfiguration -metadata: - name: project-v4-multigroup-mutating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /mutate-crew-testproject-org-v1-captain - failurePolicy: Fail - name: mcaptain.kb.io - rules: - - apiGroups: - - crew.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - captains - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /mutate-ship-testproject-org-v1-destroyer - failurePolicy: Fail - name: mdestroyer.kb.io - rules: - - apiGroups: - - ship.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - destroyers - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /mutate-testproject-org-v1-lakers - failurePolicy: Fail - name: mlakers.kb.io - rules: - - apiGroups: - - testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - lakers - sideEffects: None ---- -apiVersion: admissionregistration.k8s.io/v1 -kind: ValidatingWebhookConfiguration -metadata: - name: project-v4-multigroup-validating-webhook-configuration -webhooks: -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /validate-crew-testproject-org-v1-captain - failurePolicy: Fail - name: vcaptain.kb.io - rules: - - apiGroups: - - crew.testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - captains - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /validate-ship-testproject-org-v2alpha1-cruiser - failurePolicy: Fail - name: vcruiser.kb.io - rules: - - apiGroups: - - ship.testproject.org - apiVersions: - - v2alpha1 - operations: - - CREATE - - UPDATE - resources: - - cruisers - sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: project-v4-multigroup-webhook-service - namespace: project-v4-multigroup-system - path: /validate-testproject-org-v1-lakers - failurePolicy: Fail - name: vlakers.kb.io - rules: - - apiGroups: - - testproject.org - apiVersions: - - v1 - operations: - - CREATE - - UPDATE - resources: - - lakers - sideEffects: None diff --git a/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller.go b/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller.go deleted file mode 100644 index 454ea50391f..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apps - -import ( - "context" - - appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" -) - -// DeploymentReconciler reconciles a Deployment object -type DeploymentReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=apps,resources=deployments/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Deployment object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *DeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *DeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&appsv1.Deployment{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller_test.go b/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller_test.go deleted file mode 100644 index 339a1532026..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/apps/deployment_controller_test.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apps - -import ( - . "github.com/onsi/ginkgo/v2" -) - -var _ = Describe("Deployment Controller", func() { - Context("When reconciling a resource", func() { - - It("should successfully reconcile the resource", func() { - - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go b/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go deleted file mode 100644 index 8d7a448f9e8..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/apps/suite_test.go +++ /dev/null @@ -1,95 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package apps - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - appsv1 "k8s.io/api/apps/v1" - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: false, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = appsv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/crew/captain_controller.go b/testdata/project-v4-multigroup/internal/controller/crew/captain_controller.go deleted file mode 100644 index 5ec22b30eef..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/crew/captain_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package crew - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/crew/v1" -) - -// CaptainReconciler reconciles a Captain object -type CaptainReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=crew.testproject.org,resources=captains,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Captain object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *CaptainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&crewv1.Captain{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup/internal/controller/crew/captain_controller_test.go b/testdata/project-v4-multigroup/internal/controller/crew/captain_controller_test.go deleted file mode 100644 index c2495aee47c..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/crew/captain_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package crew - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/crew/v1" -) - -var _ = Describe("Captain Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - captain := &crewv1.Captain{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Captain") - err := k8sClient.Get(ctx, typeNamespacedName, captain) - if err != nil && errors.IsNotFound(err) { - resource := &crewv1.Captain{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &crewv1.Captain{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Captain") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &CaptainReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go b/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go deleted file mode 100644 index 840accd8f8a..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/crew/suite_test.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package crew - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/crew/v1" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = crewv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller.go b/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller.go deleted file mode 100644 index 675cca0d946..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fiz - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/fiz/v1" -) - -// BarReconciler reconciles a Bar object -type BarReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=fiz.testproject.org,resources=bars,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=fiz.testproject.org,resources=bars/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=fiz.testproject.org,resources=bars/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Bar object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *BarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *BarReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&fizv1.Bar{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller_test.go b/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller_test.go deleted file mode 100644 index c9dca3f1172..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/fiz/bar_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fiz - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/fiz/v1" -) - -var _ = Describe("Bar Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - bar := &fizv1.Bar{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Bar") - err := k8sClient.Get(ctx, typeNamespacedName, bar) - if err != nil && errors.IsNotFound(err) { - resource := &fizv1.Bar{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &fizv1.Bar{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Bar") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &BarReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go b/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go deleted file mode 100644 index 1ef21f902da..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/fiz/suite_test.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package fiz - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - fizv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/fiz/v1" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = fizv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/foo/bar_controller.go b/testdata/project-v4-multigroup/internal/controller/foo/bar_controller.go deleted file mode 100644 index 7917e5dda78..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/foo/bar_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package foo - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo/v1" -) - -// BarReconciler reconciles a Bar object -type BarReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=foo.testproject.org,resources=bars,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=foo.testproject.org,resources=bars/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=foo.testproject.org,resources=bars/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Bar object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *BarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *BarReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&foov1.Bar{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup/internal/controller/foo/bar_controller_test.go b/testdata/project-v4-multigroup/internal/controller/foo/bar_controller_test.go deleted file mode 100644 index 12193854c79..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/foo/bar_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package foo - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo/v1" -) - -var _ = Describe("Bar Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - bar := &foov1.Bar{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Bar") - err := k8sClient.Get(ctx, typeNamespacedName, bar) - if err != nil && errors.IsNotFound(err) { - resource := &foov1.Bar{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &foov1.Bar{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Bar") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &BarReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go b/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go deleted file mode 100644 index a04113931ba..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/foo/suite_test.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package foo - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - foov1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/foo/v1" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = foov1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller.go b/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller.go deleted file mode 100644 index fb4333bd68e..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1" -) - -// DestroyerReconciler reconciles a Destroyer object -type DestroyerReconciler struct { - client.Client - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the Destroyer object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile -func (r *DestroyerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) - - // TODO(user): your logic here - - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *DestroyerReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&shipv1.Destroyer{}). - Complete(r) -} diff --git a/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller_test.go b/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller_test.go deleted file mode 100644 index c1de1afb8b6..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/ship/destroyer_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1" -) - -var _ = Describe("Destroyer Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - destroyer := &shipv1.Destroyer{} - - BeforeEach(func() { - By("creating the custom resource for the Kind Destroyer") - err := k8sClient.Get(ctx, typeNamespacedName, destroyer) - if err != nil && errors.IsNotFound(err) { - resource := &shipv1.Destroyer{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &shipv1.Destroyer{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance Destroyer") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &DestroyerReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go b/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go deleted file mode 100644 index a38370a4f56..00000000000 --- a/testdata/project-v4-multigroup/internal/controller/ship/suite_test.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package ship - -import ( - "context" - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - shipv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1" - shipv1beta1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v1beta1" - shipv2alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup/api/ship/v2alpha1" - // +kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var ctx context.Context -var cancel context.CancelFunc - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - ctx, cancel = context.WithCancel(context.TODO()) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.31.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = shipv1beta1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = shipv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - err = shipv2alpha1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - // +kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - cancel() - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/testdata/project-v4-with-deploy-image/.devcontainer/devcontainer.json b/testdata/project-v4-with-deploy-image/.devcontainer/devcontainer.json deleted file mode 100644 index e2cdc09c96c..00000000000 --- a/testdata/project-v4-with-deploy-image/.devcontainer/devcontainer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "Kubebuilder DevContainer", - "image": "golang:1.22", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/git:1": {} - }, - - "runArgs": ["--network=host"], - - "customizations": { - "vscode": { - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-kubernetes-tools.vscode-kubernetes-tools", - "ms-azuretools.vscode-docker" - ] - } - }, - - "onCreateCommand": "bash .devcontainer/post-install.sh" -} - diff --git a/testdata/project-v4-with-deploy-image/.devcontainer/post-install.sh b/testdata/project-v4-with-deploy-image/.devcontainer/post-install.sh deleted file mode 100644 index 265c43ee8d3..00000000000 --- a/testdata/project-v4-with-deploy-image/.devcontainer/post-install.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -x - -curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 -chmod +x ./kind -mv ./kind /usr/local/bin/kind - -curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 -chmod +x kubebuilder -mv kubebuilder /usr/local/bin/ - -KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) -curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl" -chmod +x kubectl -mv kubectl /usr/local/bin/kubectl - -docker network create -d=bridge --subnet=172.19.0.0/24 kind - -kind version -kubebuilder version -docker --version -go version -kubectl version --client diff --git a/testdata/project-v4-with-deploy-image/.dockerignore b/testdata/project-v4-with-deploy-image/.dockerignore deleted file mode 100644 index a3aab7af70c..00000000000 --- a/testdata/project-v4-with-deploy-image/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file -# Ignore build and test binaries. -bin/ diff --git a/testdata/project-v4-with-deploy-image/.gitignore b/testdata/project-v4-with-deploy-image/.gitignore deleted file mode 100644 index ada68ff086c..00000000000 --- a/testdata/project-v4-with-deploy-image/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib -bin/* -Dockerfile.cross - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Go workspace file -go.work - -# Kubernetes Generated files - skip generated files, except for vendored files -!vendor/**/zz_generated.* - -# editor and IDE paraphernalia -.idea -.vscode -*.swp -*.swo -*~ diff --git a/testdata/project-v4-with-deploy-image/.golangci.yml b/testdata/project-v4-with-deploy-image/.golangci.yml deleted file mode 100644 index aac8a13f928..00000000000 --- a/testdata/project-v4-with-deploy-image/.golangci.yml +++ /dev/null @@ -1,47 +0,0 @@ -run: - timeout: 5m - allow-parallel-runners: true - -issues: - # don't skip warning about doc comments - # don't exclude the default set of lint - exclude-use-default: false - # restore some of the defaults - # (fill in the rest as needed) - exclude-rules: - - path: "api/*" - linters: - - lll - - path: "internal/*" - linters: - - dupl - - lll -linters: - disable-all: true - enable: - - dupl - - errcheck - - exportloopref - - ginkgolinter - - goconst - - gocyclo - - gofmt - - goimports - - gosimple - - govet - - ineffassign - - lll - - misspell - - nakedret - - prealloc - - revive - - staticcheck - - typecheck - - unconvert - - unparam - - unused - -linters-settings: - revive: - rules: - - name: comment-spacings diff --git a/testdata/project-v4-with-deploy-image/Dockerfile b/testdata/project-v4-with-deploy-image/Dockerfile deleted file mode 100644 index a48973ee7f3..00000000000 --- a/testdata/project-v4-with-deploy-image/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Build the manager binary -FROM golang:1.22 AS builder -ARG TARGETOS -ARG TARGETARCH - -WORKDIR /workspace -# Copy the Go Modules manifests -COPY go.mod go.mod -COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer -RUN go mod download - -# Copy the go source -COPY cmd/main.go cmd/main.go -COPY api/ api/ -COPY internal/controller/ internal/controller/ - -# Build -# the GOARCH has not a default value to allow the binary be built according to the host where the command -# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO -# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, -# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go - -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot -WORKDIR / -COPY --from=builder /workspace/manager . -USER 65532:65532 - -ENTRYPOINT ["/manager"] diff --git a/testdata/project-v4-with-deploy-image/Makefile b/testdata/project-v4-with-deploy-image/Makefile deleted file mode 100644 index 93640d0ea39..00000000000 --- a/testdata/project-v4-with-deploy-image/Makefile +++ /dev/null @@ -1,212 +0,0 @@ -# Image URL to use all building/pushing image targets -IMG ?= controller:latest -# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.31.0 - -# 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 - -# CONTAINER_TOOL defines the container tool to be used for building images. -# Be aware that the target commands are only tested with Docker which is -# scaffolded by default. However, you might want to replace it to use other -# tools. (i.e. podman) -CONTAINER_TOOL ?= docker - -# Setting SHELL to bash allows bash commands to be executed by recipes. -# Options are set to exit when a recipe line exits non-zero or a piped command fails. -SHELL = /usr/bin/env bash -o pipefail -.SHELLFLAGS = -ec - -.PHONY: all -all: build - -##@ General - -# The help target prints out all targets with their descriptions organized -# beneath their categories. The categories are represented by '##@' and the -# target descriptions by '##'. The awk command is responsible for reading the -# entire set of makefiles included in this invocation, looking for lines of the -# file as xyz: ## something, and then pretty-format the target and help. Then, -# if there's a line with ##@ something, that gets pretty-printed as a category. -# More info on the usage of ANSI control characters for terminal formatting: -# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters -# 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\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 crd webhook 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 -test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out - -# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'. -# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally. -# Prometheus and CertManager are installed by default; skip with: -# - PROMETHEUS_INSTALL_SKIP=true -# - CERT_MANAGER_INSTALL_SKIP=true -.PHONY: test-e2e -test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind. - @command -v kind >/dev/null 2>&1 || { \ - echo "Kind is not installed. Please install Kind manually."; \ - exit 1; \ - } - @kind get clusters | grep -q 'kind' || { \ - echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \ - exit 1; \ - } - go test ./test/e2e/ -v -ginkgo.v - -.PHONY: lint -lint: golangci-lint ## Run golangci-lint linter - $(GOLANGCI_LINT) run - -.PHONY: lint-fix -lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes - $(GOLANGCI_LINT) run --fix - -##@ Build - -.PHONY: build -build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager cmd/main.go - -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. - go run ./cmd/main.go - -# If you wish to build the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it. -# More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -.PHONY: docker-build -docker-build: ## Build docker image with the manager. - $(CONTAINER_TOOL) build -t ${IMG} . - -.PHONY: docker-push -docker-push: ## Push docker image with the manager. - $(CONTAINER_TOOL) push ${IMG} - -# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple -# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: -# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/ -# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=> then the export will fail) -# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option. -PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le -.PHONY: docker-buildx -docker-buildx: ## Build and push docker image for the manager for cross-platform support - # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile - sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - - $(CONTAINER_TOOL) buildx create --name project-v4-with-deploy-image-builder - $(CONTAINER_TOOL) buildx use project-v4-with-deploy-image-builder - - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . - - $(CONTAINER_TOOL) buildx rm project-v4-with-deploy-image-builder - rm Dockerfile.cross - -.PHONY: build-installer -build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. - mkdir -p dist - cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} - $(KUSTOMIZE) build config/default > dist/install.yaml - -##@ Deployment - -ifndef ignore-not-found - ignore-not-found = false -endif - -.PHONY: install -install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. - $(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f - - -.PHONY: uninstall -uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -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 -f - - -.PHONY: undeploy -undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. - $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - - -##@ Dependencies - -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -KUBECTL ?= kubectl -KUSTOMIZE ?= $(LOCALBIN)/kustomize -CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen -ENVTEST ?= $(LOCALBIN)/setup-envtest -GOLANGCI_LINT = $(LOCALBIN)/golangci-lint - -## Tool Versions -KUSTOMIZE_VERSION ?= v5.4.3 -CONTROLLER_TOOLS_VERSION ?= v0.16.1 -ENVTEST_VERSION ?= release-0.19 -GOLANGCI_LINT_VERSION ?= v1.59.1 - -.PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. -$(KUSTOMIZE): $(LOCALBIN) - $(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION)) - -.PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. -$(CONTROLLER_GEN): $(LOCALBIN) - $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) - -.PHONY: envtest -envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. -$(ENVTEST): $(LOCALBIN) - $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION)) - -.PHONY: golangci-lint -golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. -$(GOLANGCI_LINT): $(LOCALBIN) - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) - -# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist -# $1 - target path with name of binary -# $2 - package url which can be installed -# $3 - specific version of package -define go-install-tool -@[ -f "$(1)-$(3)" ] || { \ -set -e; \ -package=$(2)@$(3) ;\ -echo "Downloading $${package}" ;\ -rm -f $(1) || true ;\ -GOBIN=$(LOCALBIN) go install $${package} ;\ -mv $(1) $(1)-$(3) ;\ -} ;\ -ln -sf $(1)-$(3) $(1) -endef diff --git a/testdata/project-v4-with-deploy-image/README.md b/testdata/project-v4-with-deploy-image/README.md deleted file mode 100644 index 8330cb56044..00000000000 --- a/testdata/project-v4-with-deploy-image/README.md +++ /dev/null @@ -1,114 +0,0 @@ -# project-v4-with-deploy-image -// TODO(user): Add simple overview of use/purpose - -## Description -// TODO(user): An in-depth paragraph about your project and overview of use - -## Getting Started - -### Prerequisites -- go version v1.22.0+ -- docker version 17.03+. -- kubectl version v1.11.3+. -- Access to a Kubernetes v1.11.3+ cluster. - -### To Deploy on the cluster -**Build and push your image to the location specified by `IMG`:** - -```sh -make docker-build docker-push IMG=/project-v4-with-deploy-image:tag -``` - -**NOTE:** This image ought to be published in the personal registry you specified. -And it is required to have access to pull the image from the working environment. -Make sure you have the proper permission to the registry if the above commands don’t work. - -**Install the CRDs into the cluster:** - -```sh -make install -``` - -**Deploy the Manager to the cluster with the image specified by `IMG`:** - -```sh -make deploy IMG=/project-v4-with-deploy-image:tag -``` - -> **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin -privileges or be logged in as admin. - -**Create instances of your solution** -You can apply the samples (examples) from the config/sample: - -```sh -kubectl apply -k config/samples/ -``` - ->**NOTE**: Ensure that the samples has default values to test it out. - -### To Uninstall -**Delete the instances (CRs) from the cluster:** - -```sh -kubectl delete -k config/samples/ -``` - -**Delete the APIs(CRDs) from the cluster:** - -```sh -make uninstall -``` - -**UnDeploy the controller from the cluster:** - -```sh -make undeploy -``` - -## Project Distribution - -Following are the steps to build the installer and distribute this project to users. - -1. Build the installer for the image built and published in the registry: - -```sh -make build-installer IMG=/project-v4-with-deploy-image:tag -``` - -NOTE: The makefile target mentioned above generates an 'install.yaml' -file in the dist directory. This file contains all the resources built -with Kustomize, which are necessary to install this project without -its dependencies. - -2. Using the installer - -Users can just run kubectl apply -f to install the project, i.e.: - -```sh -kubectl apply -f https://raw.githubusercontent.com//project-v4-with-deploy-image//dist/install.yaml -``` - -## Contributing -// TODO(user): Add detailed information on how you would like others to contribute to this project - -**NOTE:** Run `make help` for more information on all potential `make` targets - -More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html) - -## License - -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - diff --git a/testdata/project-v4-with-deploy-image/config/certmanager/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/certmanager/kustomization.yaml deleted file mode 100644 index bebea5a595e..00000000000 --- a/testdata/project-v4-with-deploy-image/config/certmanager/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resources: -- certificate.yaml - -configurations: -- kustomizeconfig.yaml diff --git a/testdata/project-v4-with-deploy-image/config/certmanager/kustomizeconfig.yaml b/testdata/project-v4-with-deploy-image/config/certmanager/kustomizeconfig.yaml deleted file mode 100644 index cf6f89e8892..00000000000 --- a/testdata/project-v4-with-deploy-image/config/certmanager/kustomizeconfig.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# This configuration is for teaching kustomize how to update name ref substitution -nameReference: -- kind: Issuer - group: cert-manager.io - fieldSpecs: - - kind: Certificate - group: cert-manager.io - path: spec/issuerRef/name diff --git a/testdata/project-v4-with-deploy-image/config/crd/kustomizeconfig.yaml b/testdata/project-v4-with-deploy-image/config/crd/kustomizeconfig.yaml deleted file mode 100644 index ec5c150a9df..00000000000 --- a/testdata/project-v4-with-deploy-image/config/crd/kustomizeconfig.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is for teaching kustomize how to substitute name and namespace reference in CRD -nameReference: -- kind: Service - version: v1 - fieldSpecs: - - kind: CustomResourceDefinition - version: v1 - group: apiextensions.k8s.io - path: spec/conversion/webhook/clientConfig/service/name - -namespace: -- kind: CustomResourceDefinition - version: v1 - group: apiextensions.k8s.io - path: spec/conversion/webhook/clientConfig/service/namespace - create: false - -varReference: -- path: metadata/annotations diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml b/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml deleted file mode 100644 index 2aaef6536f4..00000000000 --- a/testdata/project-v4-with-deploy-image/config/default/manager_metrics_patch.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# This patch adds the args to allow exposing the metrics endpoint using HTTPS -- op: add - path: /spec/template/spec/containers/0/args/0 - value: --metrics-bind-address=:8443 diff --git a/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml deleted file mode 100644 index ad13e96b3fc..00000000000 --- a/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -resources: -- manager.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: controller - newTag: latest diff --git a/testdata/project-v4-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml b/testdata/project-v4-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml deleted file mode 100644 index 5597fb43197..00000000000 --- a/testdata/project-v4-with-deploy-image/config/network-policy/allow-metrics-traffic.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# This NetworkPolicy allows ingress traffic -# with Pods running on namespaces labeled with 'metrics: enabled'. Only Pods on those -# namespaces are able to gathering data from the metrics endpoint. -apiVersion: networking.k8s.io/v1 -kind: NetworkPolicy -metadata: - labels: - app.kubernetes.io/name: project-v4-with-deploy-image - app.kubernetes.io/managed-by: kustomize - name: allow-metrics-traffic - namespace: system -spec: - podSelector: - matchLabels: - control-plane: controller-manager - policyTypes: - - Ingress - ingress: - # This allows ingress traffic from any namespace with the label metrics: enabled - - from: - - namespaceSelector: - matchLabels: - metrics: enabled # Only from namespaces with this label - ports: - - port: 8443 - protocol: TCP diff --git a/testdata/project-v4-with-deploy-image/config/network-policy/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/network-policy/kustomization.yaml deleted file mode 100644 index 0872bee124c..00000000000 --- a/testdata/project-v4-with-deploy-image/config/network-policy/kustomization.yaml +++ /dev/null @@ -1,3 +0,0 @@ -resources: -- allow-webhook-traffic.yaml -- allow-metrics-traffic.yaml diff --git a/testdata/project-v4-with-deploy-image/config/prometheus/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/prometheus/kustomization.yaml deleted file mode 100644 index ed137168a1d..00000000000 --- a/testdata/project-v4-with-deploy-image/config/prometheus/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: -- monitor.yaml diff --git a/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role.yaml b/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role.yaml deleted file mode 100644 index 32d2e4ec6b0..00000000000 --- a/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: metrics-auth-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create diff --git a/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role_binding.yaml b/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role_binding.yaml deleted file mode 100644 index e775d67ff08..00000000000 --- a/testdata/project-v4-with-deploy-image/config/rbac/metrics_auth_role_binding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: metrics-auth-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: metrics-auth-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-with-deploy-image/config/rbac/metrics_reader_role.yaml b/testdata/project-v4-with-deploy-image/config/rbac/metrics_reader_role.yaml deleted file mode 100644 index 51a75db47a5..00000000000 --- a/testdata/project-v4-with-deploy-image/config/rbac/metrics_reader_role.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: metrics-reader -rules: -- nonResourceURLs: - - "/metrics" - verbs: - - get diff --git a/testdata/project-v4-with-deploy-image/config/webhook/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/webhook/kustomization.yaml deleted file mode 100644 index 9cf26134e4d..00000000000 --- a/testdata/project-v4-with-deploy-image/config/webhook/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ -resources: -- manifests.yaml -- service.yaml - -configurations: -- kustomizeconfig.yaml diff --git a/testdata/project-v4-with-deploy-image/config/webhook/kustomizeconfig.yaml b/testdata/project-v4-with-deploy-image/config/webhook/kustomizeconfig.yaml deleted file mode 100644 index 206316e54ff..00000000000 --- a/testdata/project-v4-with-deploy-image/config/webhook/kustomizeconfig.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# the following config is for teaching kustomize where to look at when substituting nameReference. -# It requires kustomize v2.1.0 or newer to work properly. -nameReference: -- kind: Service - version: v1 - fieldSpecs: - - kind: MutatingWebhookConfiguration - group: admissionregistration.k8s.io - path: webhooks/clientConfig/service/name - - kind: ValidatingWebhookConfiguration - group: admissionregistration.k8s.io - path: webhooks/clientConfig/service/name - -namespace: -- kind: MutatingWebhookConfiguration - group: admissionregistration.k8s.io - path: webhooks/clientConfig/service/namespace - create: true -- kind: ValidatingWebhookConfiguration - group: admissionregistration.k8s.io - path: webhooks/clientConfig/service/namespace - create: true diff --git a/testdata/project-v4-with-deploy-image/go.mod b/testdata/project-v4-with-deploy-image/go.mod deleted file mode 100644 index 9f0641b96c2..00000000000 --- a/testdata/project-v4-with-deploy-image/go.mod +++ /dev/null @@ -1,98 +0,0 @@ -module sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image - -go 1.22.0 - -require ( - github.com/onsi/ginkgo/v2 v2.19.0 - github.com/onsi/gomega v1.33.1 - k8s.io/api v0.31.0 - k8s.io/apimachinery v0.31.0 - k8s.io/client-go v0.31.0 - sigs.k8s.io/controller-runtime v0.19.0 -) - -require ( - github.com/antlr4-go/antlr/v4 v4.13.0 // indirect - github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-logr/zapr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.4 // indirect - github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/cel-go v0.20.1 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect - github.com/imdario/mergo v0.3.6 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.19.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/spf13/cobra v1.8.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/stoewer/go-strcase v1.2.0 // indirect - github.com/x448/float16 v0.8.4 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/grpc v1.65.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.31.0 // indirect - k8s.io/apiserver v0.31.0 // indirect - k8s.io/component-base v0.31.0 // indirect - k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect -) diff --git a/testdata/project-v4-with-deploy-image/hack/boilerplate.go.txt b/testdata/project-v4-with-deploy-image/hack/boilerplate.go.txt deleted file mode 100644 index 0d32012672a..00000000000 --- a/testdata/project-v4-with-deploy-image/hack/boilerplate.go.txt +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ \ No newline at end of file diff --git a/testdata/project-v4-with-deploy-image/test/e2e/e2e_suite_test.go b/testdata/project-v4-with-deploy-image/test/e2e/e2e_suite_test.go deleted file mode 100644 index c2020988060..00000000000 --- a/testdata/project-v4-with-deploy-image/test/e2e/e2e_suite_test.go +++ /dev/null @@ -1,120 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e - -import ( - "fmt" - "os" - "os/exec" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/test/utils" -) - -var ( - // Optional Environment Variables: - // - PROMETHEUS_INSTALL_SKIP=true: Skips Prometheus Operator installation during test setup. - // - CERT_MANAGER_INSTALL_SKIP=true: Skips CertManager installation during test setup. - // These variables are useful if Prometheus or CertManager is already installed, avoiding - // re-installation and conflicts. - skipPrometheusInstall = os.Getenv("PROMETHEUS_INSTALL_SKIP") == "true" - skipCertManagerInstall = os.Getenv("CERT_MANAGER_INSTALL_SKIP") == "true" - // isPrometheusOperatorAlreadyInstalled will be set true when prometheus CRDs be found on the cluster - isPrometheusOperatorAlreadyInstalled = false - // isCertManagerAlreadyInstalled will be set true when CertManager CRDs be found on the cluster - isCertManagerAlreadyInstalled = false - - // projectImage is the name of the image which will be build and loaded - // with the code source changes to be tested. - projectImage = "example.com/project-v4-with-deploy-image:v0.0.1" -) - -// TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated, -// temporary environment to validate project changes with the the purposed to be used in CI jobs. -// The default setup requires Kind, builds/loads the Manager Docker image locally, and installs -// CertManager and Prometheus. -func TestE2E(t *testing.T) { - RegisterFailHandler(Fail) - _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-with-deploy-image integration test suite\n") - RunSpecs(t, "e2e suite") -} - -var _ = BeforeSuite(func() { - By("Ensure that Prometheus is enabled") - _ = utils.UncommentCode("config/default/kustomization.yaml", "#- ../prometheus", "#") - - By("generating files") - cmd := exec.Command("make", "generate") - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to run make generate") - - By("generating manifests") - cmd = exec.Command("make", "manifests") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to run make manifests") - - By("building the manager(Operator) image") - cmd = exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the manager(Operator) image") - - // TODO(user): If you want to change the e2e test vendor from Kind, ensure the image is - // built and available before running the tests. Also, remove the following block. - By("loading the manager(Operator) image on Kind") - err = utils.LoadImageToKindClusterWithName(projectImage) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the manager(Operator) image into Kind") - - // The tests-e2e are intended to run on a temporary cluster that is created and destroyed for testing. - // To prevent errors when tests run in environments with Prometheus or CertManager already installed, - // we check for their presence before execution. - // Setup Prometheus and CertManager before the suite if not skipped and if not already installed - if !skipPrometheusInstall { - By("checking if prometheus is installed already") - isPrometheusOperatorAlreadyInstalled = utils.IsPrometheusCRDsInstalled() - if !isPrometheusOperatorAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Installing Prometheus Operator...\n") - Expect(utils.InstallPrometheusOperator()).To(Succeed(), "Failed to install Prometheus Operator") - } else { - _, _ = fmt.Fprintf(GinkgoWriter, "WARNING: Prometheus Operator is already installed. Skipping installation...\n") - } - } - if !skipCertManagerInstall { - By("checking if cert manager is installed already") - isCertManagerAlreadyInstalled = utils.IsCertManagerCRDsInstalled() - if !isCertManagerAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Installing CertManager...\n") - Expect(utils.InstallCertManager()).To(Succeed(), "Failed to install CertManager") - } else { - _, _ = fmt.Fprintf(GinkgoWriter, "WARNING: CertManager is already installed. Skipping installation...\n") - } - } -}) - -var _ = AfterSuite(func() { - // Teardown Prometheus and CertManager after the suite if not skipped and if they were not already installed - if !skipPrometheusInstall && !isPrometheusOperatorAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling Prometheus Operator...\n") - utils.UninstallPrometheusOperator() - } - if !skipCertManagerInstall && !isCertManagerAlreadyInstalled { - _, _ = fmt.Fprintf(GinkgoWriter, "Uninstalling CertManager...\n") - utils.UninstallCertManager() - } -}) diff --git a/testdata/project-v4-with-deploy-image/test/utils/utils.go b/testdata/project-v4-with-deploy-image/test/utils/utils.go deleted file mode 100644 index db4ad3f02f6..00000000000 --- a/testdata/project-v4-with-deploy-image/test/utils/utils.go +++ /dev/null @@ -1,251 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package utils - -import ( - "bufio" - "bytes" - "fmt" - "os" - "os/exec" - "strings" - - . "github.com/onsi/ginkgo/v2" //nolint:golint,revive -) - -const ( - prometheusOperatorVersion = "v0.72.0" - prometheusOperatorURL = "https://github.com/prometheus-operator/prometheus-operator/" + - "releases/download/%s/bundle.yaml" - - certmanagerVersion = "v1.14.4" - certmanagerURLTmpl = "https://github.com/jetstack/cert-manager/releases/download/%s/cert-manager.yaml" -) - -func warnError(err error) { - _, _ = fmt.Fprintf(GinkgoWriter, "warning: %v\n", err) -} - -// Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { - dir, _ := GetProjectDir() - cmd.Dir = dir - - if err := os.Chdir(cmd.Dir); err != nil { - _, _ = fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err) - } - - cmd.Env = append(os.Environ(), "GO111MODULE=on") - command := strings.Join(cmd.Args, " ") - _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) - output, err := cmd.CombinedOutput() - if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) - } - - return output, nil -} - -// InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. -func InstallPrometheusOperator() error { - url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) - cmd := exec.Command("kubectl", "create", "-f", url) - _, err := Run(cmd) - return err -} - -// UninstallPrometheusOperator uninstalls the prometheus -func UninstallPrometheusOperator() { - url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) - cmd := exec.Command("kubectl", "delete", "-f", url) - if _, err := Run(cmd); err != nil { - warnError(err) - } -} - -// IsPrometheusCRDsInstalled checks if any Prometheus CRDs are installed -// by verifying the existence of key CRDs related to Prometheus. -func IsPrometheusCRDsInstalled() bool { - // List of common Prometheus CRDs - prometheusCRDs := []string{ - "prometheuses.monitoring.coreos.com", - "prometheusrules.monitoring.coreos.com", - "prometheusagents.monitoring.coreos.com", - } - - cmd := exec.Command("kubectl", "get", "crds", "-o", "custom-columns=NAME:.metadata.name") - output, err := Run(cmd) - if err != nil { - return false - } - crdList := GetNonEmptyLines(string(output)) - for _, crd := range prometheusCRDs { - for _, line := range crdList { - if strings.Contains(line, crd) { - return true - } - } - } - - return false -} - -// UninstallCertManager uninstalls the cert manager -func UninstallCertManager() { - url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) - cmd := exec.Command("kubectl", "delete", "-f", url) - if _, err := Run(cmd); err != nil { - warnError(err) - } -} - -// InstallCertManager installs the cert manager bundle. -func InstallCertManager() error { - url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) - cmd := exec.Command("kubectl", "apply", "-f", url) - if _, err := Run(cmd); err != nil { - return err - } - // Wait for cert-manager-webhook to be ready, which can take time if cert-manager - // was re-installed after uninstalling on a cluster. - cmd = exec.Command("kubectl", "wait", "deployment.apps/cert-manager-webhook", - "--for", "condition=Available", - "--namespace", "cert-manager", - "--timeout", "5m", - ) - - _, err := Run(cmd) - return err -} - -// IsCertManagerCRDsInstalled checks if any Cert Manager CRDs are installed -// by verifying the existence of key CRDs related to Cert Manager. -func IsCertManagerCRDsInstalled() bool { - // List of common Cert Manager CRDs - certManagerCRDs := []string{ - "certificates.cert-manager.io", - "issuers.cert-manager.io", - "clusterissuers.cert-manager.io", - "certificaterequests.cert-manager.io", - "orders.acme.cert-manager.io", - "challenges.acme.cert-manager.io", - } - - // Execute the kubectl command to get all CRDs - cmd := exec.Command("kubectl", "get", "crds") - output, err := Run(cmd) - if err != nil { - return false - } - - // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) - for _, crd := range certManagerCRDs { - for _, line := range crdList { - if strings.Contains(line, crd) { - return true - } - } - } - - return false -} - -// LoadImageToKindClusterWithName loads a local docker image to the kind cluster -func LoadImageToKindClusterWithName(name string) error { - cluster := "kind" - if v, ok := os.LookupEnv("KIND_CLUSTER"); ok { - cluster = v - } - kindOptions := []string{"load", "docker-image", name, "--name", cluster} - cmd := exec.Command("kind", kindOptions...) - _, err := Run(cmd) - return err -} - -// GetNonEmptyLines converts given command output string into individual objects -// according to line breakers, and ignores the empty elements in it. -func GetNonEmptyLines(output string) []string { - var res []string - elements := strings.Split(output, "\n") - for _, element := range elements { - if element != "" { - res = append(res, element) - } - } - - return res -} - -// GetProjectDir will return the directory where the project is -func GetProjectDir() (string, error) { - wd, err := os.Getwd() - if err != nil { - return wd, err - } - wd = strings.Replace(wd, "/test/e2e", "", -1) - return wd, nil -} - -// UncommentCode searches for target in the file and remove the comment prefix -// of the target content. The target content may span multiple lines. -func UncommentCode(filename, target, prefix string) error { - // false positive - // nolint:gosec - content, err := os.ReadFile(filename) - if err != nil { - return err - } - strContent := string(content) - - idx := strings.Index(strContent, target) - if idx < 0 { - return fmt.Errorf("unable to find the code %s to be uncomment", target) - } - - out := new(bytes.Buffer) - _, err = out.Write(content[:idx]) - if err != nil { - return err - } - - scanner := bufio.NewScanner(bytes.NewBufferString(target)) - if !scanner.Scan() { - return nil - } - for { - _, err := out.WriteString(strings.TrimPrefix(scanner.Text(), prefix)) - if err != nil { - return err - } - // Avoid writing a newline in case the previous line was the last in target. - if !scanner.Scan() { - break - } - if _, err := out.WriteString("\n"); err != nil { - return err - } - } - - _, err = out.Write(content[idx+len(target):]) - if err != nil { - return err - } - // false positive - // nolint:gosec - return os.WriteFile(filename, out.Bytes(), 0644) -} diff --git a/testdata/project-v4-with-grafana/.devcontainer/devcontainer.json b/testdata/project-v4-with-grafana/.devcontainer/devcontainer.json deleted file mode 100644 index e2cdc09c96c..00000000000 --- a/testdata/project-v4-with-grafana/.devcontainer/devcontainer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "Kubebuilder DevContainer", - "image": "golang:1.22", - "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/git:1": {} - }, - - "runArgs": ["--network=host"], - - "customizations": { - "vscode": { - "settings": { - "terminal.integrated.shell.linux": "/bin/bash" - }, - "extensions": [ - "ms-kubernetes-tools.vscode-kubernetes-tools", - "ms-azuretools.vscode-docker" - ] - } - }, - - "onCreateCommand": "bash .devcontainer/post-install.sh" -} - diff --git a/testdata/project-v4-with-grafana/.devcontainer/post-install.sh b/testdata/project-v4-with-grafana/.devcontainer/post-install.sh deleted file mode 100644 index 265c43ee8d3..00000000000 --- a/testdata/project-v4-with-grafana/.devcontainer/post-install.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -x - -curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 -chmod +x ./kind -mv ./kind /usr/local/bin/kind - -curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64 -chmod +x kubebuilder -mv kubebuilder /usr/local/bin/ - -KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt) -curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl" -chmod +x kubectl -mv kubectl /usr/local/bin/kubectl - -docker network create -d=bridge --subnet=172.19.0.0/24 kind - -kind version -kubebuilder version -docker --version -go version -kubectl version --client diff --git a/testdata/project-v4-with-grafana/.dockerignore b/testdata/project-v4-with-grafana/.dockerignore deleted file mode 100644 index a3aab7af70c..00000000000 --- a/testdata/project-v4-with-grafana/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file -# Ignore build and test binaries. -bin/ diff --git a/testdata/project-v4-with-grafana/.gitignore b/testdata/project-v4-with-grafana/.gitignore deleted file mode 100644 index ada68ff086c..00000000000 --- a/testdata/project-v4-with-grafana/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib -bin/* -Dockerfile.cross - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Go workspace file -go.work - -# Kubernetes Generated files - skip generated files, except for vendored files -!vendor/**/zz_generated.* - -# editor and IDE paraphernalia -.idea -.vscode -*.swp -*.swo -*~ diff --git a/testdata/project-v4-with-grafana/.golangci.yml b/testdata/project-v4-with-grafana/.golangci.yml deleted file mode 100644 index aac8a13f928..00000000000 --- a/testdata/project-v4-with-grafana/.golangci.yml +++ /dev/null @@ -1,47 +0,0 @@ -run: - timeout: 5m - allow-parallel-runners: true - -issues: - # don't skip warning about doc comments - # don't exclude the default set of lint - exclude-use-default: false - # restore some of the defaults - # (fill in the rest as needed) - exclude-rules: - - path: "api/*" - linters: - - lll - - path: "internal/*" - linters: - - dupl - - lll -linters: - disable-all: true - enable: - - dupl - - errcheck - - exportloopref - - ginkgolinter - - goconst - - gocyclo - - gofmt - - goimports - - gosimple - - govet - - ineffassign - - lll - - misspell - - nakedret - - prealloc - - revive - - staticcheck - - typecheck - - unconvert - - unparam - - unused - -linters-settings: - revive: - rules: - - name: comment-spacings diff --git a/testdata/project-v4-with-grafana/Dockerfile b/testdata/project-v4-with-grafana/Dockerfile deleted file mode 100644 index a48973ee7f3..00000000000 --- a/testdata/project-v4-with-grafana/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Build the manager binary -FROM golang:1.22 AS builder -ARG TARGETOS -ARG TARGETARCH - -WORKDIR /workspace -# Copy the Go Modules manifests -COPY go.mod go.mod -COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer -RUN go mod download - -# Copy the go source -COPY cmd/main.go cmd/main.go -COPY api/ api/ -COPY internal/controller/ internal/controller/ - -# Build -# the GOARCH has not a default value to allow the binary be built according to the host where the command -# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO -# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, -# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go - -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot -WORKDIR / -COPY --from=builder /workspace/manager . -USER 65532:65532 - -ENTRYPOINT ["/manager"] diff --git a/testdata/project-v4-with-grafana/PROJECT b/testdata/project-v4-with-grafana/PROJECT deleted file mode 100644 index 35d0977d50f..00000000000 --- a/testdata/project-v4-with-grafana/PROJECT +++ /dev/null @@ -1,12 +0,0 @@ -# Code generated by tool. DO NOT EDIT. -# This file is used to track the info used to scaffold your project -# and allow the plugins properly work. -# More info: https://book.kubebuilder.io/reference/project-config.html -domain: testproject.org -layout: -- go.kubebuilder.io/v4 -plugins: - grafana.kubebuilder.io/v1-alpha: {} -projectName: project-v4-with-grafana -repo: sigs.k8s.io/kubebuilder/testdata/project-v4-with-grafana -version: "3" diff --git a/testdata/project-v4-with-grafana/cmd/main.go b/testdata/project-v4-with-grafana/cmd/main.go deleted file mode 100644 index 1ddef472307..00000000000 --- a/testdata/project-v4-with-grafana/cmd/main.go +++ /dev/null @@ -1,159 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "crypto/tls" - "flag" - "os" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - - "k8s.io/apimachinery/pkg/runtime" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/healthz" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sigs.k8s.io/controller-runtime/pkg/metrics/filters" - metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" - "sigs.k8s.io/controller-runtime/pkg/webhook" - // +kubebuilder:scaffold:imports -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - - // +kubebuilder:scaffold:scheme -} - -func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - var secureMetrics bool - var enableHTTP2 bool - var tlsOpts []func(*tls.Config) - flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+ - "Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.") - flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") - flag.BoolVar(&enableLeaderElection, "leader-elect", false, - "Enable leader election for controller manager. "+ - "Enabling this will ensure there is only one active controller manager.") - flag.BoolVar(&secureMetrics, "metrics-secure", true, - "If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.") - flag.BoolVar(&enableHTTP2, "enable-http2", false, - "If set, HTTP/2 will be enabled for the metrics and webhook servers") - opts := zap.Options{ - Development: true, - } - opts.BindFlags(flag.CommandLine) - flag.Parse() - - ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - - // if the enable-http2 flag is false (the default), http/2 should be disabled - // due to its vulnerabilities. More specifically, disabling http/2 will - // prevent from being vulnerable to the HTTP/2 Stream Cancellation and - // Rapid Reset CVEs. For more information see: - // - https://github.com/advisories/GHSA-qppj-fm5r-hxr3 - // - https://github.com/advisories/GHSA-4374-p667-p6c8 - disableHTTP2 := func(c *tls.Config) { - setupLog.Info("disabling http/2") - c.NextProtos = []string{"http/1.1"} - } - - if !enableHTTP2 { - tlsOpts = append(tlsOpts, disableHTTP2) - } - - webhookServer := webhook.NewServer(webhook.Options{ - TLSOpts: tlsOpts, - }) - - // Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server. - // More info: - // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/metrics/server - // - https://book.kubebuilder.io/reference/metrics.html - metricsServerOptions := metricsserver.Options{ - BindAddress: metricsAddr, - SecureServing: secureMetrics, - // TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are - // not provided, self-signed certificates will be generated by default. This option is not recommended for - // production environments as self-signed certificates do not offer the same level of trust and security - // as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing - // unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName - // to provide certificates, ensuring the server communicates using trusted and secure certificates. - TLSOpts: tlsOpts, - } - - if secureMetrics { - // FilterProvider is used to protect the metrics endpoint with authn/authz. - // These configurations ensure that only authorized users and service accounts - // can access the metrics endpoint. The RBAC are configured in 'config/rbac/kustomization.yaml'. More info: - // https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/metrics/filters#WithAuthenticationAndAuthorization - metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization - } - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - Metrics: metricsServerOptions, - WebhookServer: webhookServer, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "bc2db930.testproject.org", - // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily - // when the Manager ends. This requires the binary to immediately end when the - // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly - // speeds up voluntary leader transitions as the new leader don't have to wait - // LeaseDuration time first. - // - // In the default scaffold provided, the program ends immediately after - // the manager stops, so would be fine to enable this option. However, - // if you are doing or is intended to do any operation such as perform cleanups - // after the manager stops then its usage might be unsafe. - // LeaderElectionReleaseOnCancel: true, - }) - if err != nil { - setupLog.Error(err, "unable to start manager") - os.Exit(1) - } - - // +kubebuilder:scaffold:builder - - if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up health check") - os.Exit(1) - } - if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil { - setupLog.Error(err, "unable to set up ready check") - os.Exit(1) - } - - setupLog.Info("starting manager") - if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { - setupLog.Error(err, "problem running manager") - os.Exit(1) - } -} diff --git a/testdata/project-v4-with-grafana/config/default/kustomization.yaml b/testdata/project-v4-with-grafana/config/default/kustomization.yaml deleted file mode 100644 index 2f83888dec7..00000000000 --- a/testdata/project-v4-with-grafana/config/default/kustomization.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# Adds namespace to all resources. -namespace: project-v4-with-grafana-system - -# Value of this field is prepended to the -# names of all resources, e.g. a deployment named -# "wordpress" becomes "alices-wordpress". -# Note that it should also match with the prefix (text before '-') of the namespace -# field above. -namePrefix: project-v4-with-grafana- - -# Labels to add to all resources and selectors. -#labels: -#- includeSelectors: true -# pairs: -# someName: someValue - -resources: -#- ../crd -- ../rbac -- ../manager -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in -# crd/kustomization.yaml -#- ../webhook -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. -#- ../certmanager -# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. -#- ../prometheus -# [METRICS] Expose the controller manager metrics service. -- metrics_service.yaml -# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy. -# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics. -# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will -# be able to communicate with the Webhook Server. -#- ../network-policy - -# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager -patches: -# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443. -# More info: https://book.kubebuilder.io/reference/metrics -- path: manager_metrics_patch.yaml - target: - kind: Deployment - -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in -# crd/kustomization.yaml -#- path: manager_webhook_patch.yaml - -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. -# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. -# 'CERTMANAGER' needs to be enabled to use ca injection -#- path: webhookcainjection_patch.yaml - -# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -# Uncomment the following replacements to add the cert-manager CA injection annotations -#replacements: -# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldPath: .metadata.namespace # namespace of the certificate CR -# targets: -# - select: -# kind: ValidatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - select: -# kind: MutatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - select: -# kind: CustomResourceDefinition -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 0 -# create: true -# - source: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldPath: .metadata.name -# targets: -# - select: -# kind: ValidatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - select: -# kind: MutatingWebhookConfiguration -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - select: -# kind: CustomResourceDefinition -# fieldPaths: -# - .metadata.annotations.[cert-manager.io/inject-ca-from] -# options: -# delimiter: '/' -# index: 1 -# create: true -# - source: # Add cert-manager annotation to the webhook Service -# kind: Service -# version: v1 -# name: webhook-service -# fieldPath: .metadata.name # namespace of the service -# targets: -# - select: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# fieldPaths: -# - .spec.dnsNames.0 -# - .spec.dnsNames.1 -# options: -# delimiter: '.' -# index: 0 -# create: true -# - source: -# kind: Service -# version: v1 -# name: webhook-service -# fieldPath: .metadata.namespace # namespace of the service -# targets: -# - select: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# fieldPaths: -# - .spec.dnsNames.0 -# - .spec.dnsNames.1 -# options: -# delimiter: '.' -# index: 1 -# create: true diff --git a/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml b/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml deleted file mode 100644 index 2aaef6536f4..00000000000 --- a/testdata/project-v4-with-grafana/config/default/manager_metrics_patch.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# This patch adds the args to allow exposing the metrics endpoint using HTTPS -- op: add - path: /spec/template/spec/containers/0/args/0 - value: --metrics-bind-address=:8443 diff --git a/testdata/project-v4-with-grafana/config/manager/kustomization.yaml b/testdata/project-v4-with-grafana/config/manager/kustomization.yaml deleted file mode 100644 index ad13e96b3fc..00000000000 --- a/testdata/project-v4-with-grafana/config/manager/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -resources: -- manager.yaml -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -images: -- name: controller - newName: controller - newTag: latest diff --git a/testdata/project-v4-with-grafana/config/manager/manager.yaml b/testdata/project-v4-with-grafana/config/manager/manager.yaml deleted file mode 100644 index f64bc38baf0..00000000000 --- a/testdata/project-v4-with-grafana/config/manager/manager.yaml +++ /dev/null @@ -1,95 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: system ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize -spec: - selector: - matchLabels: - control-plane: controller-manager - replicas: 1 - template: - metadata: - annotations: - kubectl.kubernetes.io/default-container: manager - labels: - control-plane: controller-manager - spec: - # TODO(user): Uncomment the following code to configure the nodeAffinity expression - # according to the platforms which are supported by your solution. - # It is considered best practice to support multiple architectures. You can - # build your manager image using the makefile target docker-buildx. - # affinity: - # nodeAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # nodeSelectorTerms: - # - matchExpressions: - # - key: kubernetes.io/arch - # operator: In - # values: - # - amd64 - # - arm64 - # - ppc64le - # - s390x - # - key: kubernetes.io/os - # operator: In - # values: - # - linux - securityContext: - runAsNonRoot: true - # TODO(user): For common cases that do not require escalating privileges - # it is recommended to ensure that all your Pods/Containers are restrictive. - # More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted - # Please uncomment the following code if your project does NOT have to work on old Kubernetes - # versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ). - # seccompProfile: - # type: RuntimeDefault - containers: - - command: - - /manager - args: - - --leader-elect - - --health-probe-bind-address=:8081 - image: controller:latest - name: manager - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - "ALL" - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - # TODO(user): Configure the resources accordingly based on the project requirements. - # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 10m - memory: 64Mi - serviceAccountName: controller-manager - terminationGracePeriodSeconds: 10 diff --git a/testdata/project-v4-with-grafana/config/network-policy/kustomization.yaml b/testdata/project-v4-with-grafana/config/network-policy/kustomization.yaml deleted file mode 100644 index ec0fb5e57df..00000000000 --- a/testdata/project-v4-with-grafana/config/network-policy/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: -- allow-metrics-traffic.yaml diff --git a/testdata/project-v4-with-grafana/config/prometheus/kustomization.yaml b/testdata/project-v4-with-grafana/config/prometheus/kustomization.yaml deleted file mode 100644 index ed137168a1d..00000000000 --- a/testdata/project-v4-with-grafana/config/prometheus/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: -- monitor.yaml diff --git a/testdata/project-v4-with-grafana/config/prometheus/monitor.yaml b/testdata/project-v4-with-grafana/config/prometheus/monitor.yaml deleted file mode 100644 index 4db5a1f1396..00000000000 --- a/testdata/project-v4-with-grafana/config/prometheus/monitor.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Prometheus Monitor Service (Metrics) -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-monitor - namespace: system -spec: - endpoints: - - path: /metrics - port: https # Ensure this is the name of the port that exposes HTTPS metrics - scheme: https - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - tlsConfig: - # TODO(user): The option insecureSkipVerify: true is not recommended for production since it disables - # certificate verification. This poses a significant security risk by making the system vulnerable to - # man-in-the-middle attacks, where an attacker could intercept and manipulate the communication between - # Prometheus and the monitored services. This could lead to unauthorized access to sensitive metrics data, - # compromising the integrity and confidentiality of the information. - # Please use the following options for secure configurations: - # caFile: /etc/metrics-certs/ca.crt - # certFile: /etc/metrics-certs/tls.crt - # keyFile: /etc/metrics-certs/tls.key - insecureSkipVerify: true - selector: - matchLabels: - control-plane: controller-manager diff --git a/testdata/project-v4-with-grafana/config/rbac/kustomization.yaml b/testdata/project-v4-with-grafana/config/rbac/kustomization.yaml deleted file mode 100644 index 5619aa00943..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/kustomization.yaml +++ /dev/null @@ -1,20 +0,0 @@ -resources: -# All RBAC will be applied under this service account in -# the deployment namespace. You may comment out this resource -# if your manager will use a service account that exists at -# runtime. Be sure to update RoleBinding and ClusterRoleBinding -# subjects if changing service account names. -- service_account.yaml -- role.yaml -- role_binding.yaml -- leader_election_role.yaml -- leader_election_role_binding.yaml -# The following RBAC configurations are used to protect -# the metrics endpoint with authn/authz. These configurations -# ensure that only authorized users and service accounts -# can access the metrics endpoint. Comment the following -# permissions if you want to disable this protection. -# More info: https://book.kubebuilder.io/reference/metrics.html -- metrics_auth_role.yaml -- metrics_auth_role_binding.yaml -- metrics_reader_role.yaml diff --git a/testdata/project-v4-with-grafana/config/rbac/leader_election_role.yaml b/testdata/project-v4-with-grafana/config/rbac/leader_election_role.yaml deleted file mode 100644 index 67c3dc38640..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/leader_election_role.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# permissions to do leader election. -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: leader-election-role -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch diff --git a/testdata/project-v4-with-grafana/config/rbac/leader_election_role_binding.yaml b/testdata/project-v4-with-grafana/config/rbac/leader_election_role_binding.yaml deleted file mode 100644 index 24ead23b976..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/leader_election_role_binding.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: leader-election-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: leader-election-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role.yaml b/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role.yaml deleted file mode 100644 index 32d2e4ec6b0..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: metrics-auth-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create diff --git a/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role_binding.yaml b/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role_binding.yaml deleted file mode 100644 index e775d67ff08..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/metrics_auth_role_binding.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: metrics-auth-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: metrics-auth-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-with-grafana/config/rbac/metrics_reader_role.yaml b/testdata/project-v4-with-grafana/config/rbac/metrics_reader_role.yaml deleted file mode 100644 index 51a75db47a5..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/metrics_reader_role.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: metrics-reader -rules: -- nonResourceURLs: - - "/metrics" - verbs: - - get diff --git a/testdata/project-v4-with-grafana/config/rbac/role.yaml b/testdata/project-v4-with-grafana/config/rbac/role.yaml deleted file mode 100644 index cb2161ed361..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/role.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: manager-role -rules: -- apiGroups: [""] - resources: ["pods"] - verbs: ["get", "list", "watch"] diff --git a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml b/testdata/project-v4-with-grafana/config/rbac/service_account.yaml deleted file mode 100644 index 24c0d3eb365..00000000000 --- a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/name: project-v4-with-grafana - app.kubernetes.io/managed-by: kustomize - name: controller-manager - namespace: system diff --git a/testdata/project-v4-with-grafana/dist/install.yaml b/testdata/project-v4-with-grafana/dist/install.yaml deleted file mode 100644 index ac9427cd5ef..00000000000 --- a/testdata/project-v4-with-grafana/dist/install.yaml +++ /dev/null @@ -1,226 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - control-plane: controller-manager - name: project-v4-with-grafana-system ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - name: project-v4-with-grafana-controller-manager - namespace: project-v4-with-grafana-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - name: project-v4-with-grafana-leader-election-role - namespace: project-v4-with-grafana-system -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - coordination.k8s.io - resources: - - leases - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - name: project-v4-with-grafana-manager-role -rules: -- apiGroups: - - "" - resources: - - pods - verbs: - - get - - list - - watch ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: project-v4-with-grafana-metrics-auth-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: project-v4-with-grafana-metrics-reader -rules: -- nonResourceURLs: - - /metrics - verbs: - - get ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - name: project-v4-with-grafana-leader-election-rolebinding - namespace: project-v4-with-grafana-system -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: project-v4-with-grafana-leader-election-role -subjects: -- kind: ServiceAccount - name: project-v4-with-grafana-controller-manager - namespace: project-v4-with-grafana-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - name: project-v4-with-grafana-manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: project-v4-with-grafana-manager-role -subjects: -- kind: ServiceAccount - name: project-v4-with-grafana-controller-manager - namespace: project-v4-with-grafana-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: project-v4-with-grafana-metrics-auth-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: project-v4-with-grafana-metrics-auth-role -subjects: -- kind: ServiceAccount - name: project-v4-with-grafana-controller-manager - namespace: project-v4-with-grafana-system ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - control-plane: controller-manager - name: project-v4-with-grafana-controller-manager-metrics-service - namespace: project-v4-with-grafana-system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: 8443 - selector: - control-plane: controller-manager ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-grafana - control-plane: controller-manager - name: project-v4-with-grafana-controller-manager - namespace: project-v4-with-grafana-system -spec: - replicas: 1 - selector: - matchLabels: - control-plane: controller-manager - template: - metadata: - annotations: - kubectl.kubernetes.io/default-container: manager - labels: - control-plane: controller-manager - spec: - containers: - - args: - - --metrics-bind-address=:8443 - - --leader-elect - - --health-probe-bind-address=:8081 - command: - - /manager - image: controller:latest - livenessProbe: - httpGet: - path: /healthz - port: 8081 - initialDelaySeconds: 15 - periodSeconds: 20 - name: manager - readinessProbe: - httpGet: - path: /readyz - port: 8081 - initialDelaySeconds: 5 - periodSeconds: 10 - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 10m - memory: 64Mi - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - securityContext: - runAsNonRoot: true - serviceAccountName: project-v4-with-grafana-controller-manager - terminationGracePeriodSeconds: 10 diff --git a/testdata/project-v4-with-grafana/go.mod b/testdata/project-v4-with-grafana/go.mod deleted file mode 100644 index 8fe09c6d773..00000000000 --- a/testdata/project-v4-with-grafana/go.mod +++ /dev/null @@ -1,98 +0,0 @@ -module sigs.k8s.io/kubebuilder/testdata/project-v4-with-grafana - -go 1.22.0 - -require ( - github.com/onsi/ginkgo/v2 v2.19.0 - github.com/onsi/gomega v1.33.1 - k8s.io/apimachinery v0.31.0 - k8s.io/client-go v0.31.0 - sigs.k8s.io/controller-runtime v0.19.0 -) - -require ( - github.com/antlr4-go/antlr/v4 v4.13.0 // indirect - github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-logr/zapr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.4 // indirect - github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/cel-go v0.20.1 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect - github.com/imdario/mergo v0.3.6 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.19.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/spf13/cobra v1.8.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/stoewer/go-strcase v1.2.0 // indirect - github.com/x448/float16 v0.8.4 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/grpc v1.65.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.31.0 // indirect - k8s.io/apiextensions-apiserver v0.31.0 // indirect - k8s.io/apiserver v0.31.0 // indirect - k8s.io/component-base v0.31.0 // indirect - k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect -) diff --git a/testdata/project-v4-with-grafana/hack/boilerplate.go.txt b/testdata/project-v4-with-grafana/hack/boilerplate.go.txt deleted file mode 100644 index 0d32012672a..00000000000 --- a/testdata/project-v4-with-grafana/hack/boilerplate.go.txt +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ \ No newline at end of file diff --git a/testdata/project-v4-with-grafana/test/e2e/e2e_test.go b/testdata/project-v4-with-grafana/test/e2e/e2e_test.go deleted file mode 100644 index 577e32bc9b6..00000000000 --- a/testdata/project-v4-with-grafana/test/e2e/e2e_test.go +++ /dev/null @@ -1,261 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package e2e - -import ( - "encoding/json" - "fmt" - "os" - "os/exec" - "path/filepath" - "time" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "sigs.k8s.io/kubebuilder/testdata/project-v4-with-grafana/test/utils" -) - -// namespace where the project is deployed in -const namespace = "project-v4-with-grafana-system" - -// serviceAccountName created for the project -const serviceAccountName = "project-v4-with-grafana-controller-manager" - -// metricsServiceName is the name of the metrics service of the project -const metricsServiceName = "project-v4-with-grafana-controller-manager-metrics-service" - -// metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data -const metricsRoleBindingName = "project-v4-with-grafana-metrics-binding" - -var _ = Describe("Manager", Ordered, func() { - // Before running the tests, set up the environment by creating the namespace, - // installing CRDs, and deploying the controller. - BeforeAll(func() { - By("creating manager namespace") - cmd := exec.Command("kubectl", "create", "ns", namespace) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") - - By("installing CRDs") - cmd = exec.Command("make", "install") - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") - - By("deploying the controller-manager") - cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") - }) - - // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, - // and deleting the namespace. - AfterAll(func() { - By("cleaning up the curl pod for metrics") - cmd := exec.Command("kubectl", "delete", "pod", "curl-metrics", "-n", namespace) - _, _ = utils.Run(cmd) - - By("undeploying the controller-manager") - cmd = exec.Command("make", "undeploy") - _, _ = utils.Run(cmd) - - By("uninstalling CRDs") - cmd = exec.Command("make", "uninstall") - _, _ = utils.Run(cmd) - - By("removing manager namespace") - cmd = exec.Command("kubectl", "delete", "ns", namespace) - _, _ = utils.Run(cmd) - }) - - SetDefaultEventuallyTimeout(2 * time.Minute) - SetDefaultEventuallyPollingInterval(time.Second) - - // The Context block contains the actual tests that validate the manager's behavior. - Context("Manager", func() { - var controllerPodName string - It("should run successfully", func() { - By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func(g Gomega) { - // Get the name of the controller-manager pod - cmd := exec.Command("kubectl", "get", - "pods", "-l", "control-plane=controller-manager", - "-o", "go-template={{ range .items }}"+ - "{{ if not .metadata.deletionTimestamp }}"+ - "{{ .metadata.name }}"+ - "{{ \"\\n\" }}{{ end }}{{ end }}", - "-n", namespace, - ) - - podOutput, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) - g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") - controllerPodName = podNames[0] - g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) - - // Validate the pod's status - cmd = exec.Command("kubectl", "get", - "pods", controllerPodName, "-o", "jsonpath={.status.phase}", - "-n", namespace, - ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") - } - // Repeatedly check if the controller-manager pod is running until it succeeds or times out. - Eventually(verifyControllerUp).Should(Succeed()) - }) - - It("should ensure the metrics endpoint is serving metrics", func() { - By("creating a ClusterRoleBinding for the service account to allow access to metrics") - cmd := exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName, - "--clusterrole=project-v4-with-grafana-metrics-reader", - fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), - ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") - - By("validating that the metrics service is available") - cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") - - By("validating that the ServiceMonitor for Prometheus is applied in the namespace") - cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") - - By("getting the service account token") - token, err := serviceAccountToken() - Expect(err).NotTo(HaveOccurred()) - Expect(token).NotTo(BeEmpty()) - - By("waiting for the metrics endpoint to be ready") - verifyMetricsEndpointReady := func(g Gomega) { - cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") - } - Eventually(verifyMetricsEndpointReady).Should(Succeed()) - - By("verifying that the controller manager is serving the metrics server") - verifyMetricsServerStarted := func(g Gomega) { - cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), - "Metrics server not yet started") - } - Eventually(verifyMetricsServerStarted).Should(Succeed()) - - By("creating the curl-metrics pod to access the metrics endpoint") - cmd = exec.Command("kubectl", "run", "curl-metrics", "--restart=Never", - "--namespace", namespace, - "--image=curlimages/curl:7.78.0", - "--", "/bin/sh", "-c", fmt.Sprintf( - "curl -v -k -H 'Authorization: Bearer %s' https://%s.%s.svc.cluster.local:8443/metrics", - token, metricsServiceName, namespace)) - Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create curl-metrics pod") - - By("waiting for the curl-metrics pod to complete.") - verifyCurlUp := func(g Gomega) { - cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", - "-o", "jsonpath={.status.phase}", - "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") - } - Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) - - By("getting the metrics by checking curl-metrics logs") - metricsOutput := getMetricsOutput() - Expect(metricsOutput).To(ContainSubstring( - "controller_runtime_reconcile_total", - )) - }) - - // +kubebuilder:scaffold:e2e-webhooks-checks - - // TODO: Customize the e2e test suite with scenarios specific to your project. - // Consider applying sample/CR(s) and check their status and/or verifying - // the reconciliation by using the metrics, i.e.: - // metricsOutput := getMetricsOutput() - // Expect(metricsOutput).To(ContainSubstring( - // fmt.Sprintf(`controller_runtime_reconcile_total{controller="%s",result="success"} 1`, - // strings.ToLower(), - // )) - }) -}) - -// serviceAccountToken returns a token for the specified service account in the given namespace. -// It uses the Kubernetes TokenRequest API to generate a token by directly sending a request -// and parsing the resulting token from the API response. -func serviceAccountToken() (string, error) { - const tokenRequestRawString = `{ - "apiVersion": "authentication.k8s.io/v1", - "kind": "TokenRequest" - }` - - // Temporary file to store the token request - secretName := fmt.Sprintf("%s-token-request", serviceAccountName) - tokenRequestFile := filepath.Join("/tmp", secretName) - err := os.WriteFile(tokenRequestFile, []byte(tokenRequestRawString), os.FileMode(0o644)) - if err != nil { - return "", err - } - - var out string - var rawJson string - verifyTokenCreation := func(g Gomega) { - // Execute kubectl command to create the token - cmd := exec.Command("kubectl", "create", "--raw", fmt.Sprintf( - "/api/v1/namespaces/%s/serviceaccounts/%s/token", - namespace, - serviceAccountName, - ), "-f", tokenRequestFile) - - output, err := cmd.CombinedOutput() - g.Expect(err).NotTo(HaveOccurred()) - - rawJson = string(output) - - // Parse the JSON output to extract the token - var token tokenRequest - err = json.Unmarshal([]byte(rawJson), &token) - g.Expect(err).NotTo(HaveOccurred()) - - out = token.Status.Token - } - Eventually(verifyTokenCreation).Should(Succeed()) - - return out, err -} - -// getMetricsOutput retrieves and returns the logs from the curl pod used to access the metrics endpoint. -func getMetricsOutput() string { - By("getting the curl-metrics logs") - cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) - metricsOutput, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr -} - -// tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, -// containing only the token field that we need to extract. -type tokenRequest struct { - Status struct { - Token string `json:"token"` - } `json:"status"` -} diff --git a/testdata/project-v4-with-grafana/test/utils/utils.go b/testdata/project-v4-with-grafana/test/utils/utils.go deleted file mode 100644 index db4ad3f02f6..00000000000 --- a/testdata/project-v4-with-grafana/test/utils/utils.go +++ /dev/null @@ -1,251 +0,0 @@ -/* -Copyright 2024 The Kubernetes authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package utils - -import ( - "bufio" - "bytes" - "fmt" - "os" - "os/exec" - "strings" - - . "github.com/onsi/ginkgo/v2" //nolint:golint,revive -) - -const ( - prometheusOperatorVersion = "v0.72.0" - prometheusOperatorURL = "https://github.com/prometheus-operator/prometheus-operator/" + - "releases/download/%s/bundle.yaml" - - certmanagerVersion = "v1.14.4" - certmanagerURLTmpl = "https://github.com/jetstack/cert-manager/releases/download/%s/cert-manager.yaml" -) - -func warnError(err error) { - _, _ = fmt.Fprintf(GinkgoWriter, "warning: %v\n", err) -} - -// Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { - dir, _ := GetProjectDir() - cmd.Dir = dir - - if err := os.Chdir(cmd.Dir); err != nil { - _, _ = fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err) - } - - cmd.Env = append(os.Environ(), "GO111MODULE=on") - command := strings.Join(cmd.Args, " ") - _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) - output, err := cmd.CombinedOutput() - if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) - } - - return output, nil -} - -// InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. -func InstallPrometheusOperator() error { - url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) - cmd := exec.Command("kubectl", "create", "-f", url) - _, err := Run(cmd) - return err -} - -// UninstallPrometheusOperator uninstalls the prometheus -func UninstallPrometheusOperator() { - url := fmt.Sprintf(prometheusOperatorURL, prometheusOperatorVersion) - cmd := exec.Command("kubectl", "delete", "-f", url) - if _, err := Run(cmd); err != nil { - warnError(err) - } -} - -// IsPrometheusCRDsInstalled checks if any Prometheus CRDs are installed -// by verifying the existence of key CRDs related to Prometheus. -func IsPrometheusCRDsInstalled() bool { - // List of common Prometheus CRDs - prometheusCRDs := []string{ - "prometheuses.monitoring.coreos.com", - "prometheusrules.monitoring.coreos.com", - "prometheusagents.monitoring.coreos.com", - } - - cmd := exec.Command("kubectl", "get", "crds", "-o", "custom-columns=NAME:.metadata.name") - output, err := Run(cmd) - if err != nil { - return false - } - crdList := GetNonEmptyLines(string(output)) - for _, crd := range prometheusCRDs { - for _, line := range crdList { - if strings.Contains(line, crd) { - return true - } - } - } - - return false -} - -// UninstallCertManager uninstalls the cert manager -func UninstallCertManager() { - url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) - cmd := exec.Command("kubectl", "delete", "-f", url) - if _, err := Run(cmd); err != nil { - warnError(err) - } -} - -// InstallCertManager installs the cert manager bundle. -func InstallCertManager() error { - url := fmt.Sprintf(certmanagerURLTmpl, certmanagerVersion) - cmd := exec.Command("kubectl", "apply", "-f", url) - if _, err := Run(cmd); err != nil { - return err - } - // Wait for cert-manager-webhook to be ready, which can take time if cert-manager - // was re-installed after uninstalling on a cluster. - cmd = exec.Command("kubectl", "wait", "deployment.apps/cert-manager-webhook", - "--for", "condition=Available", - "--namespace", "cert-manager", - "--timeout", "5m", - ) - - _, err := Run(cmd) - return err -} - -// IsCertManagerCRDsInstalled checks if any Cert Manager CRDs are installed -// by verifying the existence of key CRDs related to Cert Manager. -func IsCertManagerCRDsInstalled() bool { - // List of common Cert Manager CRDs - certManagerCRDs := []string{ - "certificates.cert-manager.io", - "issuers.cert-manager.io", - "clusterissuers.cert-manager.io", - "certificaterequests.cert-manager.io", - "orders.acme.cert-manager.io", - "challenges.acme.cert-manager.io", - } - - // Execute the kubectl command to get all CRDs - cmd := exec.Command("kubectl", "get", "crds") - output, err := Run(cmd) - if err != nil { - return false - } - - // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) - for _, crd := range certManagerCRDs { - for _, line := range crdList { - if strings.Contains(line, crd) { - return true - } - } - } - - return false -} - -// LoadImageToKindClusterWithName loads a local docker image to the kind cluster -func LoadImageToKindClusterWithName(name string) error { - cluster := "kind" - if v, ok := os.LookupEnv("KIND_CLUSTER"); ok { - cluster = v - } - kindOptions := []string{"load", "docker-image", name, "--name", cluster} - cmd := exec.Command("kind", kindOptions...) - _, err := Run(cmd) - return err -} - -// GetNonEmptyLines converts given command output string into individual objects -// according to line breakers, and ignores the empty elements in it. -func GetNonEmptyLines(output string) []string { - var res []string - elements := strings.Split(output, "\n") - for _, element := range elements { - if element != "" { - res = append(res, element) - } - } - - return res -} - -// GetProjectDir will return the directory where the project is -func GetProjectDir() (string, error) { - wd, err := os.Getwd() - if err != nil { - return wd, err - } - wd = strings.Replace(wd, "/test/e2e", "", -1) - return wd, nil -} - -// UncommentCode searches for target in the file and remove the comment prefix -// of the target content. The target content may span multiple lines. -func UncommentCode(filename, target, prefix string) error { - // false positive - // nolint:gosec - content, err := os.ReadFile(filename) - if err != nil { - return err - } - strContent := string(content) - - idx := strings.Index(strContent, target) - if idx < 0 { - return fmt.Errorf("unable to find the code %s to be uncomment", target) - } - - out := new(bytes.Buffer) - _, err = out.Write(content[:idx]) - if err != nil { - return err - } - - scanner := bufio.NewScanner(bytes.NewBufferString(target)) - if !scanner.Scan() { - return nil - } - for { - _, err := out.WriteString(strings.TrimPrefix(scanner.Text(), prefix)) - if err != nil { - return err - } - // Avoid writing a newline in case the previous line was the last in target. - if !scanner.Scan() { - break - } - if _, err := out.WriteString("\n"); err != nil { - return err - } - } - - _, err = out.Write(content[idx+len(target):]) - if err != nil { - return err - } - // false positive - // nolint:gosec - return os.WriteFile(filename, out.Bytes(), 0644) -} diff --git a/testdata/project-v4-multigroup/.devcontainer/devcontainer.json b/testdata/project-v4-with-plugins/.devcontainer/devcontainer.json similarity index 100% rename from testdata/project-v4-multigroup/.devcontainer/devcontainer.json rename to testdata/project-v4-with-plugins/.devcontainer/devcontainer.json diff --git a/testdata/project-v4-multigroup/.devcontainer/post-install.sh b/testdata/project-v4-with-plugins/.devcontainer/post-install.sh similarity index 100% rename from testdata/project-v4-multigroup/.devcontainer/post-install.sh rename to testdata/project-v4-with-plugins/.devcontainer/post-install.sh diff --git a/testdata/project-v4-multigroup/.dockerignore b/testdata/project-v4-with-plugins/.dockerignore similarity index 100% rename from testdata/project-v4-multigroup/.dockerignore rename to testdata/project-v4-with-plugins/.dockerignore diff --git a/testdata/project-v4-multigroup/.gitignore b/testdata/project-v4-with-plugins/.gitignore similarity index 100% rename from testdata/project-v4-multigroup/.gitignore rename to testdata/project-v4-with-plugins/.gitignore diff --git a/testdata/project-v4-multigroup/.golangci.yml b/testdata/project-v4-with-plugins/.golangci.yml similarity index 100% rename from testdata/project-v4-multigroup/.golangci.yml rename to testdata/project-v4-with-plugins/.golangci.yml diff --git a/testdata/project-v4-multigroup/Dockerfile b/testdata/project-v4-with-plugins/Dockerfile similarity index 100% rename from testdata/project-v4-multigroup/Dockerfile rename to testdata/project-v4-with-plugins/Dockerfile diff --git a/testdata/project-v4-with-grafana/Makefile b/testdata/project-v4-with-plugins/Makefile similarity index 97% rename from testdata/project-v4-with-grafana/Makefile rename to testdata/project-v4-with-plugins/Makefile index 6c48d493969..4109d816219 100644 --- a/testdata/project-v4-with-grafana/Makefile +++ b/testdata/project-v4-with-plugins/Makefile @@ -120,10 +120,10 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le docker-buildx: ## Build and push docker image for the manager for cross-platform support # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - - $(CONTAINER_TOOL) buildx create --name project-v4-with-grafana-builder - $(CONTAINER_TOOL) buildx use project-v4-with-grafana-builder + - $(CONTAINER_TOOL) buildx create --name project-v4-with-plugins-builder + $(CONTAINER_TOOL) buildx use project-v4-with-plugins-builder - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . - - $(CONTAINER_TOOL) buildx rm project-v4-with-grafana-builder + - $(CONTAINER_TOOL) buildx rm project-v4-with-plugins-builder rm Dockerfile.cross .PHONY: build-installer diff --git a/testdata/project-v4-with-deploy-image/PROJECT b/testdata/project-v4-with-plugins/PROJECT similarity index 79% rename from testdata/project-v4-with-deploy-image/PROJECT rename to testdata/project-v4-with-plugins/PROJECT index 1b2ee48a339..adff7695415 100644 --- a/testdata/project-v4-with-deploy-image/PROJECT +++ b/testdata/project-v4-with-plugins/PROJECT @@ -23,8 +23,9 @@ plugins: options: image: busybox:1.36.1 version: v1alpha1 -projectName: project-v4-with-deploy-image -repo: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image + grafana.kubebuilder.io/v1-alpha: {} +projectName: project-v4-with-plugins +repo: sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins resources: - api: crdVersion: v1 @@ -33,7 +34,7 @@ resources: domain: testproject.org group: example.com kind: Memcached - path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1 version: v1alpha1 webhooks: validation: true @@ -45,6 +46,6 @@ resources: domain: testproject.org group: example.com kind: Busybox - path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1 + path: sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1 version: v1alpha1 version: "3" diff --git a/testdata/project-v4-with-grafana/README.md b/testdata/project-v4-with-plugins/README.md similarity index 93% rename from testdata/project-v4-with-grafana/README.md rename to testdata/project-v4-with-plugins/README.md index a208300c1e6..39377250d34 100644 --- a/testdata/project-v4-with-grafana/README.md +++ b/testdata/project-v4-with-plugins/README.md @@ -1,4 +1,4 @@ -# project-v4-with-grafana +# project-v4-with-plugins // TODO(user): Add simple overview of use/purpose ## Description @@ -16,7 +16,7 @@ **Build and push your image to the location specified by `IMG`:** ```sh -make docker-build docker-push IMG=/project-v4-with-grafana:tag +make docker-build docker-push IMG=/project-v4-with-plugins:tag ``` **NOTE:** This image ought to be published in the personal registry you specified. @@ -32,7 +32,7 @@ make install **Deploy the Manager to the cluster with the image specified by `IMG`:** ```sh -make deploy IMG=/project-v4-with-grafana:tag +make deploy IMG=/project-v4-with-plugins:tag ``` > **NOTE**: If you encounter RBAC errors, you may need to grant yourself cluster-admin @@ -73,7 +73,7 @@ Following are the steps to build the installer and distribute this project to us 1. Build the installer for the image built and published in the registry: ```sh -make build-installer IMG=/project-v4-with-grafana:tag +make build-installer IMG=/project-v4-with-plugins:tag ``` NOTE: The makefile target mentioned above generates an 'install.yaml' @@ -86,7 +86,7 @@ its dependencies. Users can just run kubectl apply -f to install the project, i.e.: ```sh -kubectl apply -f https://raw.githubusercontent.com//project-v4-with-grafana//dist/install.yaml +kubectl apply -f https://raw.githubusercontent.com//project-v4-with-plugins//dist/install.yaml ``` ## Contributing diff --git a/testdata/project-v4-with-plugins/api/v1alpha1/busybox_types.go b/testdata/project-v4-with-plugins/api/v1alpha1/busybox_types.go new file mode 100644 index 00000000000..cd1fd6da5d6 --- /dev/null +++ b/testdata/project-v4-with-plugins/api/v1alpha1/busybox_types.go @@ -0,0 +1,77 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// BusyboxSpec defines the desired state of Busybox +type BusyboxSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Size defines the number of Busybox instances + // The following markers will use OpenAPI v3 schema to validate the value + // More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=3 + // +kubebuilder:validation:ExclusiveMaximum=false + Size int32 `json:"size,omitempty"` +} + +// BusyboxStatus defines the observed state of Busybox +type BusyboxStatus struct { + // Represents the observations of a Busybox's current state. + // Busybox.status.conditions.type are: "Available", "Progressing", and "Degraded" + // Busybox.status.conditions.status are one of True, False, Unknown. + // Busybox.status.conditions.reason the value should be a CamelCase string and producers of specific + // condition types may define expected values and meanings for this field, and whether the values + // are considered a guaranteed API. + // Busybox.status.conditions.Message is a human readable message indicating details about the transition. + // For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties + + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// Busybox is the Schema for the busyboxes API +type Busybox struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BusyboxSpec `json:"spec,omitempty"` + Status BusyboxStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// BusyboxList contains a list of Busybox +type BusyboxList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Busybox `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Busybox{}, &BusyboxList{}) +} diff --git a/testdata/project-v4-multigroup/api/foo/v1/groupversion_info.go b/testdata/project-v4-with-plugins/api/v1alpha1/groupversion_info.go similarity index 80% rename from testdata/project-v4-multigroup/api/foo/v1/groupversion_info.go rename to testdata/project-v4-with-plugins/api/v1alpha1/groupversion_info.go index f90e36f69ec..110a9b573a1 100644 --- a/testdata/project-v4-multigroup/api/foo/v1/groupversion_info.go +++ b/testdata/project-v4-with-plugins/api/v1alpha1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1 contains API Schema definitions for the foo v1 API group. +// Package v1alpha1 contains API Schema definitions for the example.com v1alpha1 API group. // +kubebuilder:object:generate=true -// +groupName=foo.testproject.org -package v1 +// +groupName=example.com.testproject.org +package v1alpha1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "foo.testproject.org", Version: "v1"} + GroupVersion = schema.GroupVersion{Group: "example.com.testproject.org", Version: "v1alpha1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme. SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/testdata/project-v4-with-plugins/api/v1alpha1/memcached_types.go b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_types.go new file mode 100644 index 00000000000..7c4116e82a5 --- /dev/null +++ b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_types.go @@ -0,0 +1,80 @@ +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// MemcachedSpec defines the desired state of Memcached +type MemcachedSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Size defines the number of Memcached instances + // The following markers will use OpenAPI v3 schema to validate the value + // More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=3 + // +kubebuilder:validation:ExclusiveMaximum=false + Size int32 `json:"size,omitempty"` + + // Port defines the port that will be used to init the container with the image + ContainerPort int32 `json:"containerPort,omitempty"` +} + +// MemcachedStatus defines the observed state of Memcached +type MemcachedStatus struct { + // Represents the observations of a Memcached's current state. + // Memcached.status.conditions.type are: "Available", "Progressing", and "Degraded" + // Memcached.status.conditions.status are one of True, False, Unknown. + // Memcached.status.conditions.reason the value should be a CamelCase string and producers of specific + // condition types may define expected values and meanings for this field, and whether the values + // are considered a guaranteed API. + // Memcached.status.conditions.Message is a human readable message indicating details about the transition. + // For further information see: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties + + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status + +// Memcached is the Schema for the memcacheds API +type Memcached struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MemcachedSpec `json:"spec,omitempty"` + Status MemcachedStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// MemcachedList contains a list of Memcached +type MemcachedList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Memcached `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Memcached{}, &MemcachedList{}) +} diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook.go b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook.go similarity index 56% rename from testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook.go rename to testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook.go index ef8552fe278..1c3350ccfd9 100644 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook.go +++ b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v1alpha1 import ( "context" @@ -29,13 +29,13 @@ import ( // nolint:unused // log is for logging in this package. -var cruiserlog = logf.Log.WithName("cruiser-resource") +var memcachedlog = logf.Log.WithName("memcached-resource") // SetupWebhookWithManager will setup the manager to manage the webhooks. -func (r *Cruiser) SetupWebhookWithManager(mgr ctrl.Manager) error { +func (r *Memcached) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). For(r). - WithValidator(&CruiserCustomValidator{}). + WithValidator(&MemcachedCustomValidator{}). Complete() } @@ -44,53 +44,53 @@ func (r *Cruiser) SetupWebhookWithManager(mgr ctrl.Manager) error { // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. // NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here. // Modifying the path for an invalid path can cause API server errors; failing to locate the webhook. -// +kubebuilder:webhook:path=/validate-ship-testproject-org-v2alpha1-cruiser,mutating=false,failurePolicy=fail,sideEffects=None,groups=ship.testproject.org,resources=cruisers,verbs=create;update,versions=v2alpha1,name=vcruiser.kb.io,admissionReviewVersions=v1 +// +kubebuilder:webhook:path=/validate-example-com-testproject-org-v1alpha1-memcached,mutating=false,failurePolicy=fail,sideEffects=None,groups=example.com.testproject.org,resources=memcacheds,verbs=create;update,versions=v1alpha1,name=vmemcached.kb.io,admissionReviewVersions=v1 // +kubebuilder:object:generate=false -// CruiserCustomValidator struct is responsible for validating the Cruiser resource +// MemcachedCustomValidator struct is responsible for validating the Memcached resource // when it is created, updated, or deleted. // // NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods, // as this struct is used only for temporary operations and does not need to be deeply copied. -type CruiserCustomValidator struct { +type MemcachedCustomValidator struct { //TODO(user): Add more fields as needed for validation } -var _ webhook.CustomValidator = &CruiserCustomValidator{} +var _ webhook.CustomValidator = &MemcachedCustomValidator{} -// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Cruiser. -func (v *CruiserCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - cruiser, ok := obj.(*Cruiser) +// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Memcached. +func (v *MemcachedCustomValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + memcached, ok := obj.(*Memcached) if !ok { - return nil, fmt.Errorf("expected a Cruiser object but got %T", obj) + return nil, fmt.Errorf("expected a Memcached object but got %T", obj) } - cruiserlog.Info("Validation for Cruiser upon creation", "name", cruiser.GetName()) + memcachedlog.Info("Validation for Memcached upon creation", "name", memcached.GetName()) // TODO(user): fill in your validation logic upon object creation. return nil, nil } -// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Cruiser. -func (v *CruiserCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { - cruiser, ok := newObj.(*Cruiser) +// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Memcached. +func (v *MemcachedCustomValidator) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { + memcached, ok := newObj.(*Memcached) if !ok { - return nil, fmt.Errorf("expected a Cruiser object but got %T", newObj) + return nil, fmt.Errorf("expected a Memcached object but got %T", newObj) } - cruiserlog.Info("Validation for Cruiser upon update", "name", cruiser.GetName()) + memcachedlog.Info("Validation for Memcached upon update", "name", memcached.GetName()) // TODO(user): fill in your validation logic upon object update. return nil, nil } -// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Cruiser. -func (v *CruiserCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { - cruiser, ok := obj.(*Cruiser) +// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Memcached. +func (v *MemcachedCustomValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { + memcached, ok := obj.(*Memcached) if !ok { - return nil, fmt.Errorf("expected a Cruiser object but got %T", obj) + return nil, fmt.Errorf("expected a Memcached object but got %T", obj) } - cruiserlog.Info("Validation for Cruiser upon deletion", "name", cruiser.GetName()) + memcachedlog.Info("Validation for Memcached upon deletion", "name", memcached.GetName()) // TODO(user): fill in your validation logic upon object deletion. diff --git a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook_test.go b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook_test.go similarity index 91% rename from testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook_test.go rename to testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook_test.go index 9dbe29a8dfc..784108d26d4 100644 --- a/testdata/project-v4-multigroup/api/ship/v2alpha1/cruiser_webhook_test.go +++ b/testdata/project-v4-with-plugins/api/v1alpha1/memcached_webhook_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2alpha1 +package v1alpha1 import ( . "github.com/onsi/ginkgo/v2" @@ -22,13 +22,13 @@ import ( // TODO (user): Add any additional imports if needed ) -var _ = Describe("Cruiser Webhook", func() { +var _ = Describe("Memcached Webhook", func() { var ( - obj *Cruiser + obj *Memcached ) BeforeEach(func() { - obj = &Cruiser{} + obj = &Memcached{} Expect(obj).NotTo(BeNil(), "Expected obj to be initialized") // TODO (user): Add any setup logic common to all tests @@ -38,7 +38,7 @@ var _ = Describe("Cruiser Webhook", func() { // TODO (user): Add any teardown logic common to all tests }) - Context("When creating or updating Cruiser under Validating Webhook", func() { + Context("When creating or updating Memcached under Validating Webhook", func() { // TODO (user): Add logic for validating webhooks // Example: // It("Should deny creation if a required field is missing", func() { diff --git a/testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go b/testdata/project-v4-with-plugins/api/v1alpha1/webhook_suite_test.go similarity index 100% rename from testdata/project-v4-with-deploy-image/api/v1alpha1/webhook_suite_test.go rename to testdata/project-v4-with-plugins/api/v1alpha1/webhook_suite_test.go diff --git a/testdata/project-v4-with-plugins/api/v1alpha1/zz_generated.deepcopy.go b/testdata/project-v4-with-plugins/api/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..a41c7b842d1 --- /dev/null +++ b/testdata/project-v4-with-plugins/api/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,218 @@ +//go:build !ignore_autogenerated + +/* +Copyright 2024 The Kubernetes authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Busybox) DeepCopyInto(out *Busybox) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Busybox. +func (in *Busybox) DeepCopy() *Busybox { + if in == nil { + return nil + } + out := new(Busybox) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Busybox) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BusyboxList) DeepCopyInto(out *BusyboxList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Busybox, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BusyboxList. +func (in *BusyboxList) DeepCopy() *BusyboxList { + if in == nil { + return nil + } + out := new(BusyboxList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BusyboxList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BusyboxSpec) DeepCopyInto(out *BusyboxSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BusyboxSpec. +func (in *BusyboxSpec) DeepCopy() *BusyboxSpec { + if in == nil { + return nil + } + out := new(BusyboxSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BusyboxStatus) DeepCopyInto(out *BusyboxStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BusyboxStatus. +func (in *BusyboxStatus) DeepCopy() *BusyboxStatus { + if in == nil { + return nil + } + out := new(BusyboxStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Memcached) DeepCopyInto(out *Memcached) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Memcached. +func (in *Memcached) DeepCopy() *Memcached { + if in == nil { + return nil + } + out := new(Memcached) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Memcached) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MemcachedList) DeepCopyInto(out *MemcachedList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Memcached, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemcachedList. +func (in *MemcachedList) DeepCopy() *MemcachedList { + if in == nil { + return nil + } + out := new(MemcachedList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MemcachedList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MemcachedSpec) DeepCopyInto(out *MemcachedSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemcachedSpec. +func (in *MemcachedSpec) DeepCopy() *MemcachedSpec { + if in == nil { + return nil + } + out := new(MemcachedSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MemcachedStatus) DeepCopyInto(out *MemcachedStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemcachedStatus. +func (in *MemcachedStatus) DeepCopy() *MemcachedStatus { + if in == nil { + return nil + } + out := new(MemcachedStatus) + in.DeepCopyInto(out) + return out +} diff --git a/testdata/project-v4-with-deploy-image/cmd/main.go b/testdata/project-v4-with-plugins/cmd/main.go similarity index 97% rename from testdata/project-v4-with-deploy-image/cmd/main.go rename to testdata/project-v4-with-plugins/cmd/main.go index 24e43ccb13a..ade191db8f1 100644 --- a/testdata/project-v4-with-deploy-image/cmd/main.go +++ b/testdata/project-v4-with-plugins/cmd/main.go @@ -35,8 +35,8 @@ import ( metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" - "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/internal/controller" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" + "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/internal/controller" // +kubebuilder:scaffold:imports ) @@ -126,7 +126,7 @@ func main() { WebhookServer: webhookServer, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "1836d577.testproject.org", + LeaderElectionID: "a13ae5d8.testproject.org", // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily // when the Manager ends. This requires the binary to immediately end when the // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly diff --git a/testdata/project-v4-multigroup/config/certmanager/certificate.yaml b/testdata/project-v4-with-plugins/config/certmanager/certificate.yaml similarity index 87% rename from testdata/project-v4-multigroup/config/certmanager/certificate.yaml rename to testdata/project-v4-with-plugins/config/certmanager/certificate.yaml index d6bd556f1b4..68214a62d39 100644 --- a/testdata/project-v4-multigroup/config/certmanager/certificate.yaml +++ b/testdata/project-v4-with-plugins/config/certmanager/certificate.yaml @@ -5,7 +5,7 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: selfsigned-issuer namespace: system @@ -19,8 +19,8 @@ metadata: app.kubernetes.io/name: certificate app.kubernetes.io/instance: serving-cert app.kubernetes.io/component: certificate - app.kubernetes.io/created-by: project-v4-multigroup - app.kubernetes.io/part-of: project-v4-multigroup + app.kubernetes.io/created-by: project-v4-with-plugins + app.kubernetes.io/part-of: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml namespace: system diff --git a/testdata/project-v4-multigroup/config/certmanager/kustomization.yaml b/testdata/project-v4-with-plugins/config/certmanager/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/certmanager/kustomization.yaml rename to testdata/project-v4-with-plugins/config/certmanager/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/certmanager/kustomizeconfig.yaml b/testdata/project-v4-with-plugins/config/certmanager/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/certmanager/kustomizeconfig.yaml rename to testdata/project-v4-with-plugins/config/certmanager/kustomizeconfig.yaml diff --git a/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_busyboxes.yaml b/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_busyboxes.yaml new file mode 100644 index 00000000000..e6e2e98c7ae --- /dev/null +++ b/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_busyboxes.yaml @@ -0,0 +1,116 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + name: busyboxes.example.com.testproject.org +spec: + group: example.com.testproject.org + names: + kind: Busybox + listKind: BusyboxList + plural: busyboxes + singular: busybox + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Busybox is the Schema for the busyboxes API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: BusyboxSpec defines the desired state of Busybox + properties: + size: + description: |- + Size defines the number of Busybox instances + The following markers will use OpenAPI v3 schema to validate the value + More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + format: int32 + maximum: 3 + minimum: 1 + type: integer + type: object + status: + description: BusyboxStatus defines the observed state of Busybox + properties: + conditions: + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_memcacheds.yaml b/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_memcacheds.yaml new file mode 100644 index 00000000000..cf77a6f3fd9 --- /dev/null +++ b/testdata/project-v4-with-plugins/config/crd/bases/example.com.testproject.org_memcacheds.yaml @@ -0,0 +1,121 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + name: memcacheds.example.com.testproject.org +spec: + group: example.com.testproject.org + names: + kind: Memcached + listKind: MemcachedList + plural: memcacheds + singular: memcached + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Memcached is the Schema for the memcacheds API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: MemcachedSpec defines the desired state of Memcached + properties: + containerPort: + description: Port defines the port that will be used to init the container + with the image + format: int32 + type: integer + size: + description: |- + Size defines the number of Memcached instances + The following markers will use OpenAPI v3 schema to validate the value + More info: https://book.kubebuilder.io/reference/markers/crd-validation.html + format: int32 + maximum: 3 + minimum: 1 + type: integer + type: object + status: + description: MemcachedStatus defines the observed state of Memcached + properties: + conditions: + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/testdata/project-v4-with-deploy-image/config/crd/kustomization.yaml b/testdata/project-v4-with-plugins/config/crd/kustomization.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/crd/kustomization.yaml rename to testdata/project-v4-with-plugins/config/crd/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/crd/kustomizeconfig.yaml b/testdata/project-v4-with-plugins/config/crd/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/crd/kustomizeconfig.yaml rename to testdata/project-v4-with-plugins/config/crd/kustomizeconfig.yaml diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml b/testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml similarity index 84% rename from testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml rename to testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml index fba0c3ed6fd..5b9e839364d 100644 --- a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_crew_captains.yaml +++ b/testdata/project-v4-with-plugins/config/crd/patches/cainjection_in_memcacheds.yaml @@ -4,4 +4,4 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME - name: captains.crew.testproject.org + name: memcacheds.example.com.testproject.org diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml b/testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml similarity index 88% rename from testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml rename to testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml index f73ae2e8abc..4a56b0f4c69 100644 --- a/testdata/project-v4-multigroup/config/crd/patches/webhook_in_crew_captains.yaml +++ b/testdata/project-v4-with-plugins/config/crd/patches/webhook_in_memcacheds.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: captains.crew.testproject.org + name: memcacheds.example.com.testproject.org spec: conversion: strategy: Webhook diff --git a/testdata/project-v4-multigroup/config/default/kustomization.yaml b/testdata/project-v4-with-plugins/config/default/kustomization.yaml similarity index 98% rename from testdata/project-v4-multigroup/config/default/kustomization.yaml rename to testdata/project-v4-with-plugins/config/default/kustomization.yaml index 32e0e86801e..3f17cef261d 100644 --- a/testdata/project-v4-multigroup/config/default/kustomization.yaml +++ b/testdata/project-v4-with-plugins/config/default/kustomization.yaml @@ -1,12 +1,12 @@ # Adds namespace to all resources. -namespace: project-v4-multigroup-system +namespace: project-v4-with-plugins-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named # "wordpress" becomes "alices-wordpress". # Note that it should also match with the prefix (text before '-') of the namespace # field above. -namePrefix: project-v4-multigroup- +namePrefix: project-v4-with-plugins- # Labels to add to all resources and selectors. #labels: diff --git a/testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml b/testdata/project-v4-with-plugins/config/default/manager_metrics_patch.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/default/manager_metrics_patch.yaml rename to testdata/project-v4-with-plugins/config/default/manager_metrics_patch.yaml diff --git a/testdata/project-v4-multigroup/config/default/manager_webhook_patch.yaml b/testdata/project-v4-with-plugins/config/default/manager_webhook_patch.yaml similarity index 91% rename from testdata/project-v4-multigroup/config/default/manager_webhook_patch.yaml rename to testdata/project-v4-with-plugins/config/default/manager_webhook_patch.yaml index 9fd690c819f..34989fbbeb1 100644 --- a/testdata/project-v4-multigroup/config/default/manager_webhook_patch.yaml +++ b/testdata/project-v4-with-plugins/config/default/manager_webhook_patch.yaml @@ -4,7 +4,7 @@ metadata: name: controller-manager namespace: system labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize spec: template: diff --git a/testdata/project-v4-with-grafana/config/default/metrics_service.yaml b/testdata/project-v4-with-plugins/config/default/metrics_service.yaml similarity index 86% rename from testdata/project-v4-with-grafana/config/default/metrics_service.yaml rename to testdata/project-v4-with-plugins/config/default/metrics_service.yaml index fded59c2325..45339096982 100644 --- a/testdata/project-v4-with-grafana/config/default/metrics_service.yaml +++ b/testdata/project-v4-with-plugins/config/default/metrics_service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-grafana + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-service namespace: system diff --git a/testdata/project-v4-multigroup/config/default/webhookcainjection_patch.yaml b/testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml similarity index 83% rename from testdata/project-v4-multigroup/config/default/webhookcainjection_patch.yaml rename to testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml index 5a278ed6e95..3afc9037018 100644 --- a/testdata/project-v4-multigroup/config/default/webhookcainjection_patch.yaml +++ b/testdata/project-v4-with-plugins/config/default/webhookcainjection_patch.yaml @@ -4,7 +4,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: mutating-webhook-configuration annotations: @@ -17,8 +17,8 @@ metadata: app.kubernetes.io/name: validatingwebhookconfiguration app.kubernetes.io/instance: validating-webhook-configuration app.kubernetes.io/component: webhook - app.kubernetes.io/created-by: project-v4-multigroup - app.kubernetes.io/part-of: project-v4-multigroup + app.kubernetes.io/created-by: project-v4-with-plugins + app.kubernetes.io/part-of: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: validating-webhook-configuration annotations: diff --git a/testdata/project-v4-multigroup/config/manager/kustomization.yaml b/testdata/project-v4-with-plugins/config/manager/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/manager/kustomization.yaml rename to testdata/project-v4-with-plugins/config/manager/kustomization.yaml diff --git a/testdata/project-v4-with-deploy-image/config/manager/manager.yaml b/testdata/project-v4-with-plugins/config/manager/manager.yaml similarity index 96% rename from testdata/project-v4-with-deploy-image/config/manager/manager.yaml rename to testdata/project-v4-with-plugins/config/manager/manager.yaml index 0341968d86f..b04cea1a357 100644 --- a/testdata/project-v4-with-deploy-image/config/manager/manager.yaml +++ b/testdata/project-v4-with-plugins/config/manager/manager.yaml @@ -3,7 +3,7 @@ kind: Namespace metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: system --- @@ -14,7 +14,7 @@ metadata: namespace: system labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize spec: selector: diff --git a/testdata/project-v4-multigroup/config/network-policy/allow-metrics-traffic.yaml b/testdata/project-v4-with-plugins/config/network-policy/allow-metrics-traffic.yaml similarity index 93% rename from testdata/project-v4-multigroup/config/network-policy/allow-metrics-traffic.yaml rename to testdata/project-v4-with-plugins/config/network-policy/allow-metrics-traffic.yaml index 3f144fb140e..c7a0bf9dd58 100644 --- a/testdata/project-v4-multigroup/config/network-policy/allow-metrics-traffic.yaml +++ b/testdata/project-v4-with-plugins/config/network-policy/allow-metrics-traffic.yaml @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: allow-metrics-traffic namespace: system diff --git a/testdata/project-v4-multigroup/config/network-policy/allow-webhook-traffic.yaml b/testdata/project-v4-with-plugins/config/network-policy/allow-webhook-traffic.yaml similarity index 93% rename from testdata/project-v4-multigroup/config/network-policy/allow-webhook-traffic.yaml rename to testdata/project-v4-with-plugins/config/network-policy/allow-webhook-traffic.yaml index ec32d71710c..c75092b53e2 100644 --- a/testdata/project-v4-multigroup/config/network-policy/allow-webhook-traffic.yaml +++ b/testdata/project-v4-with-plugins/config/network-policy/allow-webhook-traffic.yaml @@ -5,7 +5,7 @@ apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: allow-webhook-traffic namespace: system diff --git a/testdata/project-v4-multigroup/config/network-policy/kustomization.yaml b/testdata/project-v4-with-plugins/config/network-policy/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/network-policy/kustomization.yaml rename to testdata/project-v4-with-plugins/config/network-policy/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/prometheus/kustomization.yaml b/testdata/project-v4-with-plugins/config/prometheus/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/prometheus/kustomization.yaml rename to testdata/project-v4-with-plugins/config/prometheus/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/prometheus/monitor.yaml b/testdata/project-v4-with-plugins/config/prometheus/monitor.yaml similarity index 96% rename from testdata/project-v4-multigroup/config/prometheus/monitor.yaml rename to testdata/project-v4-with-plugins/config/prometheus/monitor.yaml index 89d2f351f5b..58e9d5440eb 100644 --- a/testdata/project-v4-multigroup/config/prometheus/monitor.yaml +++ b/testdata/project-v4-with-plugins/config/prometheus/monitor.yaml @@ -4,7 +4,7 @@ kind: ServiceMonitor metadata: labels: control-plane: controller-manager - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager-metrics-monitor namespace: system diff --git a/testdata/project-v4-with-deploy-image/config/rbac/busybox_editor_role.yaml b/testdata/project-v4-with-plugins/config/rbac/busybox_editor_role.yaml similarity index 88% rename from testdata/project-v4-with-deploy-image/config/rbac/busybox_editor_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/busybox_editor_role.yaml index 1148b24f263..cce1597dd9b 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/busybox_editor_role.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/busybox_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: busybox-editor-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/busybox_viewer_role.yaml b/testdata/project-v4-with-plugins/config/rbac/busybox_viewer_role.yaml similarity index 87% rename from testdata/project-v4-with-deploy-image/config/rbac/busybox_viewer_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/busybox_viewer_role.yaml index cb50fa03407..9ff4ba57069 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/busybox_viewer_role.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/busybox_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: busybox-viewer-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/kustomization.yaml b/testdata/project-v4-with-plugins/config/rbac/kustomization.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/rbac/kustomization.yaml rename to testdata/project-v4-with-plugins/config/rbac/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/leader_election_role.yaml b/testdata/project-v4-with-plugins/config/rbac/leader_election_role.yaml similarity index 91% rename from testdata/project-v4-multigroup/config/rbac/leader_election_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/leader_election_role.yaml index 14015b3499d..330d2352ba7 100644 --- a/testdata/project-v4-multigroup/config/rbac/leader_election_role.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/leader_election_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: leader-election-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/leader_election_role_binding.yaml b/testdata/project-v4-with-plugins/config/rbac/leader_election_role_binding.yaml similarity index 86% rename from testdata/project-v4-multigroup/config/rbac/leader_election_role_binding.yaml rename to testdata/project-v4-with-plugins/config/rbac/leader_election_role_binding.yaml index 7af36fa2d81..b86da7901f0 100644 --- a/testdata/project-v4-multigroup/config/rbac/leader_election_role_binding.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/leader_election_role_binding.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: leader-election-rolebinding roleRef: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/memcached_editor_role.yaml b/testdata/project-v4-with-plugins/config/rbac/memcached_editor_role.yaml similarity index 88% rename from testdata/project-v4-with-deploy-image/config/rbac/memcached_editor_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/memcached_editor_role.yaml index 49009c8a25e..37feccf6a64 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/memcached_editor_role.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/memcached_editor_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: memcached-editor-role rules: diff --git a/testdata/project-v4-with-deploy-image/config/rbac/memcached_viewer_role.yaml b/testdata/project-v4-with-plugins/config/rbac/memcached_viewer_role.yaml similarity index 87% rename from testdata/project-v4-with-deploy-image/config/rbac/memcached_viewer_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/memcached_viewer_role.yaml index b9c45fa10ba..655f7986162 100644 --- a/testdata/project-v4-with-deploy-image/config/rbac/memcached_viewer_role.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/memcached_viewer_role.yaml @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: memcached-viewer-role rules: diff --git a/testdata/project-v4-multigroup/config/rbac/metrics_auth_role.yaml b/testdata/project-v4-with-plugins/config/rbac/metrics_auth_role.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/rbac/metrics_auth_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/metrics_auth_role.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/metrics_auth_role_binding.yaml b/testdata/project-v4-with-plugins/config/rbac/metrics_auth_role_binding.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/rbac/metrics_auth_role_binding.yaml rename to testdata/project-v4-with-plugins/config/rbac/metrics_auth_role_binding.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/metrics_reader_role.yaml b/testdata/project-v4-with-plugins/config/rbac/metrics_reader_role.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/rbac/metrics_reader_role.yaml rename to testdata/project-v4-with-plugins/config/rbac/metrics_reader_role.yaml diff --git a/testdata/project-v4-with-deploy-image/config/rbac/role.yaml b/testdata/project-v4-with-plugins/config/rbac/role.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/rbac/role.yaml rename to testdata/project-v4-with-plugins/config/rbac/role.yaml diff --git a/testdata/project-v4-with-grafana/config/rbac/role_binding.yaml b/testdata/project-v4-with-plugins/config/rbac/role_binding.yaml similarity index 86% rename from testdata/project-v4-with-grafana/config/rbac/role_binding.yaml rename to testdata/project-v4-with-plugins/config/rbac/role_binding.yaml index ea0f0189035..e9c53696a9e 100644 --- a/testdata/project-v4-with-grafana/config/rbac/role_binding.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/role_binding.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: - app.kubernetes.io/name: project-v4-with-grafana + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: manager-rolebinding roleRef: diff --git a/testdata/project-v4-multigroup/config/rbac/service_account.yaml b/testdata/project-v4-with-plugins/config/rbac/service_account.yaml similarity index 73% rename from testdata/project-v4-multigroup/config/rbac/service_account.yaml rename to testdata/project-v4-with-plugins/config/rbac/service_account.yaml index 25d4288f404..3f3872d879f 100644 --- a/testdata/project-v4-multigroup/config/rbac/service_account.yaml +++ b/testdata/project-v4-with-plugins/config/rbac/service_account.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: ServiceAccount metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: controller-manager namespace: system diff --git a/testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_busybox.yaml b/testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml similarity index 83% rename from testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_busybox.yaml rename to testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml index aab844d6b95..2265d1caf7f 100644 --- a/testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_busybox.yaml +++ b/testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_busybox.yaml @@ -2,7 +2,7 @@ apiVersion: example.com.testproject.org/v1alpha1 kind: Busybox metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: busybox-sample spec: diff --git a/testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_memcached.yaml b/testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml similarity index 87% rename from testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_memcached.yaml rename to testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml index 0d873712c23..e15fd410c68 100644 --- a/testdata/project-v4-with-deploy-image/config/samples/example.com_v1alpha1_memcached.yaml +++ b/testdata/project-v4-with-plugins/config/samples/example.com_v1alpha1_memcached.yaml @@ -2,7 +2,7 @@ apiVersion: example.com.testproject.org/v1alpha1 kind: Memcached metadata: labels: - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: memcached-sample spec: diff --git a/testdata/project-v4-with-deploy-image/config/samples/kustomization.yaml b/testdata/project-v4-with-plugins/config/samples/kustomization.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/samples/kustomization.yaml rename to testdata/project-v4-with-plugins/config/samples/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/webhook/kustomization.yaml b/testdata/project-v4-with-plugins/config/webhook/kustomization.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/webhook/kustomization.yaml rename to testdata/project-v4-with-plugins/config/webhook/kustomization.yaml diff --git a/testdata/project-v4-multigroup/config/webhook/kustomizeconfig.yaml b/testdata/project-v4-with-plugins/config/webhook/kustomizeconfig.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/webhook/kustomizeconfig.yaml rename to testdata/project-v4-with-plugins/config/webhook/kustomizeconfig.yaml diff --git a/testdata/project-v4-with-deploy-image/config/webhook/manifests.yaml b/testdata/project-v4-with-plugins/config/webhook/manifests.yaml similarity index 100% rename from testdata/project-v4-with-deploy-image/config/webhook/manifests.yaml rename to testdata/project-v4-with-plugins/config/webhook/manifests.yaml diff --git a/testdata/project-v4-multigroup/config/webhook/service.yaml b/testdata/project-v4-with-plugins/config/webhook/service.yaml similarity index 83% rename from testdata/project-v4-multigroup/config/webhook/service.yaml rename to testdata/project-v4-with-plugins/config/webhook/service.yaml index 0ba1f669758..a2c259db493 100644 --- a/testdata/project-v4-multigroup/config/webhook/service.yaml +++ b/testdata/project-v4-with-plugins/config/webhook/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: labels: - app.kubernetes.io/name: project-v4-multigroup + app.kubernetes.io/name: project-v4-with-plugins app.kubernetes.io/managed-by: kustomize name: webhook-service namespace: system diff --git a/testdata/project-v4-with-deploy-image/dist/install.yaml b/testdata/project-v4-with-plugins/dist/install.yaml similarity index 86% rename from testdata/project-v4-with-deploy-image/dist/install.yaml rename to testdata/project-v4-with-plugins/dist/install.yaml index 4e29265f0ae..3dc302435ba 100644 --- a/testdata/project-v4-with-deploy-image/dist/install.yaml +++ b/testdata/project-v4-with-plugins/dist/install.yaml @@ -3,9 +3,9 @@ kind: Namespace metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins control-plane: controller-manager - name: project-v4-with-deploy-image-system + name: project-v4-with-plugins-system --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition @@ -135,8 +135,8 @@ spec: webhook: clientConfig: service: - name: project-v4-with-deploy-image-webhook-service - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-webhook-service + namespace: project-v4-with-plugins-system path: /convert conversionReviewVersions: - v1 @@ -259,18 +259,18 @@ kind: ServiceAccount metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-controller-manager - namespace: project-v4-with-deploy-image-system + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-controller-manager + namespace: project-v4-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-leader-election-role - namespace: project-v4-with-deploy-image-system + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-leader-election-role + namespace: project-v4-with-plugins-system rules: - apiGroups: - "" @@ -309,8 +309,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-busybox-editor-role + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-busybox-editor-role rules: - apiGroups: - example.com.testproject.org @@ -336,8 +336,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-busybox-viewer-role + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-busybox-viewer-role rules: - apiGroups: - example.com.testproject.org @@ -357,7 +357,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-with-deploy-image-manager-role + name: project-v4-with-plugins-manager-role rules: - apiGroups: - apps @@ -421,8 +421,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-memcached-editor-role + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-memcached-editor-role rules: - apiGroups: - example.com.testproject.org @@ -448,8 +448,8 @@ kind: ClusterRole metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-memcached-viewer-role + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-memcached-viewer-role rules: - apiGroups: - example.com.testproject.org @@ -469,7 +469,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-with-deploy-image-metrics-auth-role + name: project-v4-with-plugins-metrics-auth-role rules: - apiGroups: - authentication.k8s.io @@ -487,7 +487,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: project-v4-with-deploy-image-metrics-reader + name: project-v4-with-plugins-metrics-reader rules: - nonResourceURLs: - /metrics @@ -499,56 +499,56 @@ kind: RoleBinding metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-leader-election-rolebinding - namespace: project-v4-with-deploy-image-system + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-leader-election-rolebinding + namespace: project-v4-with-plugins-system roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: project-v4-with-deploy-image-leader-election-role + name: project-v4-with-plugins-leader-election-role subjects: - kind: ServiceAccount - name: project-v4-with-deploy-image-controller-manager - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-controller-manager + namespace: project-v4-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-manager-rolebinding + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-manager-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: project-v4-with-deploy-image-manager-role + name: project-v4-with-plugins-manager-role subjects: - kind: ServiceAccount - name: project-v4-with-deploy-image-controller-manager - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-controller-manager + namespace: project-v4-with-plugins-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: project-v4-with-deploy-image-metrics-auth-rolebinding + name: project-v4-with-plugins-metrics-auth-rolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: project-v4-with-deploy-image-metrics-auth-role + name: project-v4-with-plugins-metrics-auth-role subjects: - kind: ServiceAccount - name: project-v4-with-deploy-image-controller-manager - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-controller-manager + namespace: project-v4-with-plugins-system --- apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins control-plane: controller-manager - name: project-v4-with-deploy-image-controller-manager-metrics-service - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-controller-manager-metrics-service + namespace: project-v4-with-plugins-system spec: ports: - name: https @@ -563,9 +563,9 @@ kind: Service metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image - name: project-v4-with-deploy-image-webhook-service - namespace: project-v4-with-deploy-image-system + app.kubernetes.io/name: project-v4-with-plugins + name: project-v4-with-plugins-webhook-service + namespace: project-v4-with-plugins-system spec: ports: - port: 443 @@ -579,10 +579,10 @@ kind: Deployment metadata: labels: app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/name: project-v4-with-deploy-image + app.kubernetes.io/name: project-v4-with-plugins control-plane: controller-manager - name: project-v4-with-deploy-image-controller-manager - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-controller-manager + namespace: project-v4-with-plugins-system spec: replicas: 1 selector: @@ -643,7 +643,7 @@ spec: readOnly: true securityContext: runAsNonRoot: true - serviceAccountName: project-v4-with-deploy-image-controller-manager + serviceAccountName: project-v4-with-plugins-controller-manager terminationGracePeriodSeconds: 10 volumes: - name: cert @@ -654,14 +654,14 @@ spec: apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: - name: project-v4-with-deploy-image-validating-webhook-configuration + name: project-v4-with-plugins-validating-webhook-configuration webhooks: - admissionReviewVersions: - v1 clientConfig: service: - name: project-v4-with-deploy-image-webhook-service - namespace: project-v4-with-deploy-image-system + name: project-v4-with-plugins-webhook-service + namespace: project-v4-with-plugins-system path: /validate-example-com-testproject-org-v1alpha1-memcached failurePolicy: Fail name: vmemcached.kb.io diff --git a/testdata/project-v4-multigroup/go.mod b/testdata/project-v4-with-plugins/go.mod similarity index 98% rename from testdata/project-v4-multigroup/go.mod rename to testdata/project-v4-with-plugins/go.mod index 03db01b03e8..6e87ffd0948 100644 --- a/testdata/project-v4-multigroup/go.mod +++ b/testdata/project-v4-with-plugins/go.mod @@ -1,4 +1,4 @@ -module sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup +module sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins go 1.22.0 diff --git a/testdata/project-v4-with-plugins/grafana/controller-resources-metrics.json b/testdata/project-v4-with-plugins/grafana/controller-resources-metrics.json new file mode 100644 index 00000000000..629e0d3c9b1 --- /dev/null +++ b/testdata/project-v4-with-plugins/grafana/controller-resources-metrics.json @@ -0,0 +1,306 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 2, + "interval": "1m", + "links": [], + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.4.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "rate(process_cpu_seconds_total{job=\"$job\", namespace=\"$namespace\", pod=\"$pod\"}[5m]) * 100", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Pod: {{pod}} | Container: {{container}}", + "refId": "A", + "step": 10 + } + ], + "title": "Controller CPU Usage", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "bytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 4, + "interval": "1m", + "links": [], + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.4.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "process_resident_memory_bytes{job=\"$job\", namespace=\"$namespace\", pod=\"$pod\"}", + "format": "time_series", + "interval": "", + "intervalFactor": 2, + "legendFormat": "Pod: {{pod}} | Container: {{container}}", + "refId": "A", + "step": 10 + } + ], + "title": "Controller Memory Usage", + "type": "timeseries" + } + ], + "refresh": "", + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\"}, job)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "job", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\"}, job)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "current": { + "selected": false, + "text": "observability", + "value": "observability" + }, + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total, namespace)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "namespace", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total, namespace)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "current": { + "selected": false, + "text": "All", + "value": "$__all" + }, + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\", job=~\"$job\"}, pod)", + "hide": 2, + "includeAll": true, + "label": "pod", + "multi": true, + "name": "pod", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\", job=~\"$job\"}, pod)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Controller-Resources-Metrics", + "weekStart": "" +} diff --git a/testdata/project-v4-with-plugins/grafana/controller-runtime-metrics.json b/testdata/project-v4-with-plugins/grafana/controller-runtime-metrics.json new file mode 100644 index 00000000000..c8eea4cb434 --- /dev/null +++ b/testdata/project-v4-with-plugins/grafana/controller-runtime-metrics.json @@ -0,0 +1,898 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 9, + "panels": [], + "title": "Reconciliation Metrics", + "type": "row" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 85 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 24, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "9.5.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "controller_runtime_active_workers{job=\"$job\", namespace=\"$namespace\"}", + "interval": "", + "legendFormat": "{{controller}} {{instance}}", + "refId": "A" + } + ], + "title": "Number of workers in use", + "type": "gauge" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "Total number of reconciliations per controller", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "cpm" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 11, + "x": 3, + "y": 1 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "editorMode": "code", + "exemplar": true, + "expr": "sum(rate(controller_runtime_reconcile_total{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, pod)", + "interval": "", + "legendFormat": "{{instance}} {{pod}}", + "range": true, + "refId": "A" + } + ], + "title": "Total Reconciliation Count Per Controller", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "Total number of reconciliation errors per controller", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "cpm" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 10, + "x": 14, + "y": 1 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "editorMode": "code", + "exemplar": true, + "expr": "sum(rate(controller_runtime_reconcile_errors_total{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, pod)", + "interval": "", + "legendFormat": "{{instance}} {{pod}}", + "range": true, + "refId": "A" + } + ], + "title": "Reconciliation Error Count Per Controller", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 9 + }, + "id": 11, + "panels": [], + "title": "Work Queue Metrics", + "type": "row" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 85 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 3, + "x": 0, + "y": 10 + }, + "id": 22, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "9.5.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "workqueue_depth{job=\"$job\", namespace=\"$namespace\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "WorkQueue Depth", + "type": "gauge" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "How long in seconds an item stays in workqueue before being requested", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 11, + "x": 3, + "y": 10 + }, + "id": 13, + "options": { + "legend": { + "calcs": [ + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.50, sum(rate(workqueue_queue_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "interval": "", + "legendFormat": "P50 {{name}} {{instance}} ", + "refId": "A" + }, + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.90, sum(rate(workqueue_queue_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "hide": false, + "interval": "", + "legendFormat": "P90 {{name}} {{instance}} ", + "refId": "B" + }, + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum(rate(workqueue_queue_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "hide": false, + "interval": "", + "legendFormat": "P99 {{name}} {{instance}} ", + "refId": "C" + } + ], + "title": "Seconds For Items Stay In Queue (before being requested) (P50, P90, P99)", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 10, + "x": 14, + "y": 10 + }, + "id": 15, + "options": { + "legend": { + "calcs": [], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "8.4.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "sum(rate(workqueue_adds_total{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name)", + "interval": "", + "legendFormat": "{{name}} {{instance}}", + "refId": "A" + } + ], + "title": "Work Queue Add Rate", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "How many seconds of work has done that is in progress and hasn't been observed by work_duration.\nLarge values indicate stuck threads.\nOne can deduce the number of stuck threads by observing the rate at which this increases.", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 85 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 0, + "y": 18 + }, + "id": 23, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "9.5.3", + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "rate(workqueue_unfinished_work_seconds{job=\"$job\", namespace=\"$namespace\"}[5m])", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Unfinished Seconds", + "type": "gauge" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "How long in seconds processing an item from workqueue takes.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 11, + "x": 3, + "y": 18 + }, + "id": 19, + "options": { + "legend": { + "calcs": [ + "max", + "mean" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.50, sum(rate(workqueue_work_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "interval": "", + "legendFormat": "P50 {{name}} {{instance}} ", + "refId": "A" + }, + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.90, sum(rate(workqueue_work_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "hide": false, + "interval": "", + "legendFormat": "P90 {{name}} {{instance}} ", + "refId": "B" + }, + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "histogram_quantile(0.99, sum(rate(workqueue_work_duration_seconds_bucket{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name, le))", + "hide": false, + "interval": "", + "legendFormat": "P99 {{name}} {{instance}} ", + "refId": "C" + } + ], + "title": "Seconds Processing Items From WorkQueue (P50, P90, P99)", + "type": "timeseries" + }, + { + "datasource": "${DS_PROMETHEUS}", + "description": "Total number of retries handled by workqueue", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 3, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 10, + "x": 14, + "y": 18 + }, + "id": 17, + "options": { + "legend": { + "calcs": [], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": "${DS_PROMETHEUS}", + "exemplar": true, + "expr": "sum(rate(workqueue_retries_total{job=\"$job\", namespace=\"$namespace\"}[5m])) by (instance, name)", + "interval": "", + "legendFormat": "{{name}} {{instance}} ", + "refId": "A" + } + ], + "title": "Work Queue Retries Rate", + "type": "timeseries" + } + ], + "refresh": "", + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\"}, job)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "job", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\"}, job)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total, namespace)", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "namespace", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total, namespace)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + }, + { + "current": { + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] + }, + "datasource": "${DS_PROMETHEUS}", + "definition": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\", job=~\"$job\"}, pod)", + "hide": 2, + "includeAll": true, + "label": "pod", + "multi": true, + "name": "pod", + "options": [], + "query": { + "query": "label_values(controller_runtime_reconcile_total{namespace=~\"$namespace\", job=~\"$job\"}, pod)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-15m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Controller-Runtime-Metrics", + "weekStart": "" +} diff --git a/testdata/project-v4-with-plugins/grafana/custom-metrics/config.yaml b/testdata/project-v4-with-plugins/grafana/custom-metrics/config.yaml new file mode 100644 index 00000000000..3ee1bebdf24 --- /dev/null +++ b/testdata/project-v4-with-plugins/grafana/custom-metrics/config.yaml @@ -0,0 +1,15 @@ +--- +customMetrics: +# - metric: # Raw custom metric (required) +# type: # Metric type: counter/gauge/histogram (required) +# expr: # Prom_ql for the metric (optional) +# unit: # Unit of measurement, examples: s,none,bytes,percent,etc. (optional) +# +# +# Example: +# --- +# customMetrics: +# - metric: foo_bar +# unit: none +# type: histogram +# expr: histogram_quantile(0.90, sum by(instance, le) (rate(foo_bar{job=\"$job\", namespace=\"$namespace\"}[5m]))) diff --git a/testdata/project-v4-multigroup/hack/boilerplate.go.txt b/testdata/project-v4-with-plugins/hack/boilerplate.go.txt similarity index 100% rename from testdata/project-v4-multigroup/hack/boilerplate.go.txt rename to testdata/project-v4-with-plugins/hack/boilerplate.go.txt diff --git a/testdata/project-v4-with-deploy-image/internal/controller/busybox_controller.go b/testdata/project-v4-with-plugins/internal/controller/busybox_controller.go similarity index 99% rename from testdata/project-v4-with-deploy-image/internal/controller/busybox_controller.go rename to testdata/project-v4-with-plugins/internal/controller/busybox_controller.go index c531d0e00be..31a8638972f 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/busybox_controller.go +++ b/testdata/project-v4-with-plugins/internal/controller/busybox_controller.go @@ -36,7 +36,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" ) const busyboxFinalizer = "example.com.testproject.org/finalizer" @@ -403,7 +403,7 @@ func labelsForBusybox() map[string]string { if err == nil { imageTag = strings.Split(image, ":")[1] } - return map[string]string{"app.kubernetes.io/name": "project-v4-with-deploy-image", + return map[string]string{"app.kubernetes.io/name": "project-v4-with-plugins", "app.kubernetes.io/version": imageTag, "app.kubernetes.io/managed-by": "BusyboxController", } diff --git a/testdata/project-v4-with-deploy-image/internal/controller/busybox_controller_test.go b/testdata/project-v4-with-plugins/internal/controller/busybox_controller_test.go similarity index 99% rename from testdata/project-v4-with-deploy-image/internal/controller/busybox_controller_test.go rename to testdata/project-v4-with-plugins/internal/controller/busybox_controller_test.go index d0bd06dcbbf..7b049733cf7 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/busybox_controller_test.go +++ b/testdata/project-v4-with-plugins/internal/controller/busybox_controller_test.go @@ -32,7 +32,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/reconcile" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" ) var _ = Describe("Busybox controller", func() { diff --git a/testdata/project-v4-with-deploy-image/internal/controller/memcached_controller.go b/testdata/project-v4-with-plugins/internal/controller/memcached_controller.go similarity index 99% rename from testdata/project-v4-with-deploy-image/internal/controller/memcached_controller.go rename to testdata/project-v4-with-plugins/internal/controller/memcached_controller.go index 020f0b0c398..a5a387bc657 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/memcached_controller.go +++ b/testdata/project-v4-with-plugins/internal/controller/memcached_controller.go @@ -36,7 +36,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" ) const memcachedFinalizer = "example.com.testproject.org/finalizer" @@ -409,7 +409,7 @@ func labelsForMemcached() map[string]string { if err == nil { imageTag = strings.Split(image, ":")[1] } - return map[string]string{"app.kubernetes.io/name": "project-v4-with-deploy-image", + return map[string]string{"app.kubernetes.io/name": "project-v4-with-plugins", "app.kubernetes.io/version": imageTag, "app.kubernetes.io/managed-by": "MemcachedController", } diff --git a/testdata/project-v4-with-deploy-image/internal/controller/memcached_controller_test.go b/testdata/project-v4-with-plugins/internal/controller/memcached_controller_test.go similarity index 99% rename from testdata/project-v4-with-deploy-image/internal/controller/memcached_controller_test.go rename to testdata/project-v4-with-plugins/internal/controller/memcached_controller_test.go index 77f6c35de03..fc4ba1cc690 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/memcached_controller_test.go +++ b/testdata/project-v4-with-plugins/internal/controller/memcached_controller_test.go @@ -32,7 +32,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/reconcile" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" ) var _ = Describe("Memcached controller", func() { diff --git a/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go b/testdata/project-v4-with-plugins/internal/controller/suite_test.go similarity index 98% rename from testdata/project-v4-with-deploy-image/internal/controller/suite_test.go rename to testdata/project-v4-with-plugins/internal/controller/suite_test.go index fd3033d88a4..5259421161e 100644 --- a/testdata/project-v4-with-deploy-image/internal/controller/suite_test.go +++ b/testdata/project-v4-with-plugins/internal/controller/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/api/v1alpha1" + examplecomv1alpha1 "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/api/v1alpha1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v4-with-grafana/test/e2e/e2e_suite_test.go b/testdata/project-v4-with-plugins/test/e2e/e2e_suite_test.go similarity index 95% rename from testdata/project-v4-with-grafana/test/e2e/e2e_suite_test.go rename to testdata/project-v4-with-plugins/test/e2e/e2e_suite_test.go index 24357e32ee0..6250b847b2c 100644 --- a/testdata/project-v4-with-grafana/test/e2e/e2e_suite_test.go +++ b/testdata/project-v4-with-plugins/test/e2e/e2e_suite_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/kubebuilder/testdata/project-v4-with-grafana/test/utils" + "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/test/utils" ) var ( @@ -43,7 +43,7 @@ var ( // projectImage is the name of the image which will be build and loaded // with the code source changes to be tested. - projectImage = "example.com/project-v4-with-grafana:v0.0.1" + projectImage = "example.com/project-v4-with-plugins:v0.0.1" ) // TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated, @@ -52,7 +52,7 @@ var ( // CertManager and Prometheus. func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-with-grafana integration test suite\n") + _, _ = fmt.Fprintf(GinkgoWriter, "Starting project-v4-with-plugins integration test suite\n") RunSpecs(t, "e2e suite") } diff --git a/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go b/testdata/project-v4-with-plugins/test/e2e/e2e_test.go similarity index 95% rename from testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go rename to testdata/project-v4-with-plugins/test/e2e/e2e_test.go index f48626f98af..dbcdbaa61a2 100644 --- a/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go +++ b/testdata/project-v4-with-plugins/test/e2e/e2e_test.go @@ -27,20 +27,20 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "sigs.k8s.io/kubebuilder/testdata/project-v4-with-deploy-image/test/utils" + "sigs.k8s.io/kubebuilder/testdata/project-v4-with-plugins/test/utils" ) // namespace where the project is deployed in -const namespace = "project-v4-with-deploy-image-system" +const namespace = "project-v4-with-plugins-system" // serviceAccountName created for the project -const serviceAccountName = "project-v4-with-deploy-image-controller-manager" +const serviceAccountName = "project-v4-with-plugins-controller-manager" // metricsServiceName is the name of the metrics service of the project -const metricsServiceName = "project-v4-with-deploy-image-controller-manager-metrics-service" +const metricsServiceName = "project-v4-with-plugins-controller-manager-metrics-service" // metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data -const metricsRoleBindingName = "project-v4-with-deploy-image-metrics-binding" +const metricsRoleBindingName = "project-v4-with-plugins-metrics-binding" var _ = Describe("Manager", Ordered, func() { // Before running the tests, set up the environment by creating the namespace, @@ -119,7 +119,7 @@ var _ = Describe("Manager", Ordered, func() { It("should ensure the metrics endpoint is serving metrics", func() { By("creating a ClusterRoleBinding for the service account to allow access to metrics") cmd := exec.Command("kubectl", "create", "clusterrolebinding", metricsRoleBindingName, - "--clusterrole=project-v4-with-deploy-image-metrics-reader", + "--clusterrole=project-v4-with-plugins-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) _, err := utils.Run(cmd) @@ -199,7 +199,7 @@ var _ = Describe("Manager", Ordered, func() { verifyCAInjection := func(g Gomega) { cmd := exec.Command("kubectl", "get", "validatingwebhookconfigurations.admissionregistration.k8s.io", - "project-v4-with-deploy-image-validating-webhook-configuration", + "project-v4-with-plugins-validating-webhook-configuration", "-o", "go-template={{ range .webhooks }}{{ .clientConfig.caBundle }}{{ end }}") vwhOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred()) diff --git a/testdata/project-v4-multigroup/test/utils/utils.go b/testdata/project-v4-with-plugins/test/utils/utils.go similarity index 100% rename from testdata/project-v4-multigroup/test/utils/utils.go rename to testdata/project-v4-with-plugins/test/utils/utils.go