diff --git a/docs/book/src/plugins/declarative-v1.md b/docs/book/src/plugins/declarative-v1.md index c3513618da..ac3eb13b69 100644 --- a/docs/book/src/plugins/declarative-v1.md +++ b/docs/book/src/plugins/declarative-v1.md @@ -1,4 +1,18 @@ -# Declarative Plugin +# [Deprecated] Declarative Plugin + + The declarative plugin allows you to create [controllers][controller-runtime] using the [kubebuilder-declarative-pattern][kubebuilder-declarative-pattern]. By using the declarative plugin, you can make the required changes on top of what is scaffolded by default when you create a Go project with Kubebuilder and the Golang plugins (i.e. go/v2, go/v3). diff --git a/docs/book/src/plugins/to-add-optional-features.md b/docs/book/src/plugins/to-add-optional-features.md index 085b11fda9..f62da55d2a 100644 --- a/docs/book/src/plugins/to-add-optional-features.md +++ b/docs/book/src/plugins/to-add-optional-features.md @@ -2,8 +2,8 @@ The following plugins are useful to generate code and take advantage of optional features -| Plugin | Key | Description | -| ---------------------------------------------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [declarative.go.kubebuilder.io/v1](declarative-v1.md) | `declarative/v1` | Optional plugin used to scaffold APIs/controllers using the [kubebuilder-declarative-pattern][kubebuilder-declarative-pattern] project. | -| [grafana.kubebuilder.io/v1-alpha](grafana-v1-alpha.md) | `grafana/v1-alpha` | Optional helper plugin which can be used to scaffold Grafana Manifests Dashboards for the default metrics which are exported by controller-runtime. | -| [deploy-image.go.kubebuilder.io/v1-alpha](deploy-image-plugin-v1-alpha) | `deploy-image/v1-alpha` | Optional helper plugin which can be used to scaffold APIs and controller with code implementation to Deploy and Manage an Operand(image). | +| Plugin | Key | Description | +|-------------------------------------------------------------------------| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [declarative.go.kubebuilder.io/v1 - (Deprecated) ](declarative-v1.md) | `declarative/v1` | Optional plugin used to scaffold APIs/controllers using the [kubebuilder-declarative-pattern][kubebuilder-declarative-pattern] project. | +| [grafana.kubebuilder.io/v1-alpha](grafana-v1-alpha.md) | `grafana/v1-alpha` | Optional helper plugin which can be used to scaffold Grafana Manifests Dashboards for the default metrics which are exported by controller-runtime. | +| [deploy-image.go.kubebuilder.io/v1-alpha](deploy-image-plugin-v1-alpha) | `deploy-image/v1-alpha` | Optional helper plugin which can be used to scaffold APIs and controller with code implementation to Deploy and Manage an Operand(image). | diff --git a/pkg/plugins/golang/declarative/v1/plugin.go b/pkg/plugins/golang/declarative/v1/plugin.go index 76cf07c7c3..bb553a3aaa 100644 --- a/pkg/plugins/golang/declarative/v1/plugin.go +++ b/pkg/plugins/golang/declarative/v1/plugin.go @@ -14,6 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Deprecated: The declarative plugin has been deprecated. +// The Declarative plugin is an implementation derived from the kubebuilder-declarative-pattern project. +// As the project maintainers possess the most comprehensive knowledge about its changes and Kubebuilder +// allows the creation of custom plugins using its library, it has been decided that this plugin will be +// better maintained within the kubebuilder-declarative-pattern project +// itself, which falls under its domain of responsibility. This decision aims to improve the maintainability +// of both the plugin and Kubebuilder, ultimately providing an enhanced user experience. +// To follow up on this work, please refer to the Issue #293: +// https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/issues/293. package v1 import ( @@ -61,5 +70,13 @@ type pluginConfig struct { } func (p Plugin) DeprecationWarning() string { - return "" + return "The declarative plugin has been deprecated. \n" + + "The Declarative plugin is an implementation derived from the kubebuilder-declarative-pattern project. " + + "As the project maintainers possess the most comprehensive knowledge about its changes and Kubebuilder " + + "allows the creation of custom plugins using its library, it has been decided that this plugin will be " + + "better maintained within the kubebuilder-declarative-pattern project " + + "itself, which falls under its domain of responsibility. This decision aims to improve the maintainability " + + "of both the plugin and Kubebuilder, ultimately providing an enhanced user experience." + + "To follow up on this work, please refer to the Issue #293: " + + "https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/issues/293." } diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh index a145caece1..07dd9c1c4f 100755 --- a/test/testdata/generate.sh +++ b/test/testdata/generate.sh @@ -102,11 +102,6 @@ function scaffold_test_project { $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 =~ declarative ]]; 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 FirstMate --controller=true --resource=true --make=false - $kb create api --group crew --version v1 --kind Admiral --controller=true --resource=true --namespaced=false --make=false 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:1.4.36-alpine --image-container-command="memcached,-m=64,-o,modern,-v" --image-container-port="11211" --run-as-user="1001" --plugins="deploy-image/v1-alpha" --make=false @@ -135,6 +130,5 @@ scaffold_test_project project-v3 --plugins="go/v3" # [Currently, default CLI plugin] - [Next version, alpha] Project version v4-alpha scaffold_test_project project-v4 --plugins="go/v4" scaffold_test_project project-v4-multigroup --plugins="go/v4" -scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative" scaffold_test_project project-v4-with-deploy-image --plugins="go/v4" scaffold_test_project project-v4-with-grafana --plugins="go/v4" diff --git a/test/testdata/test.sh b/test/testdata/test.sh index e4a534693f..162a66419a 100755 --- a/test/testdata/test.sh +++ b/test/testdata/test.sh @@ -33,6 +33,5 @@ build_kb # Project version v4-alpha test_project project-v4 test_project project-v4-multigroup -test_project project-v4-declarative-v1 test_project project-v4-with-deploy-image test_project project-v4-with-grafana diff --git a/testdata/project-v4-declarative-v1/.dockerignore b/testdata/project-v4-declarative-v1/.dockerignore deleted file mode 100644 index a3aab7af70..0000000000 --- a/testdata/project-v4-declarative-v1/.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-declarative-v1/.gitignore b/testdata/project-v4-declarative-v1/.gitignore deleted file mode 100644 index 7f02333db7..0000000000 --- a/testdata/project-v4-declarative-v1/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ - -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib -bin/* -Dockerfile.cross - -# Test binary, build with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# 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-declarative-v1/Dockerfile b/testdata/project-v4-declarative-v1/Dockerfile deleted file mode 100644 index fee7871fdc..0000000000 --- a/testdata/project-v4-declarative-v1/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# Build the manager binary -FROM golang:1.20 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/ -# https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/master/docs/addon/walkthrough/README.md#adding-a-manifest -# Stage channels and make readable -COPY channels/ /channels/ -RUN chmod -R a+rx /channels/ - -# 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 . -# copy channels -COPY --from=builder /channels /channels - -USER 65532:65532 - -ENTRYPOINT ["/manager"] diff --git a/testdata/project-v4-declarative-v1/Makefile b/testdata/project-v4-declarative-v1/Makefile deleted file mode 100644 index ca35b69cc0..0000000000 --- a/testdata/project-v4-declarative-v1/Makefile +++ /dev/null @@ -1,163 +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.27.1 - -# 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 ./... -coverprofile cover.out - -##@ 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: test ## 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: test ## 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-v3-builder - $(CONTAINER_TOOL) buildx use project-v3-builder - - $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross . - - $(CONTAINER_TOOL) buildx rm project-v3-builder - rm Dockerfile.cross - -##@ 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: ## 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 - - -##@ Build 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 - -## Tool Versions -KUSTOMIZE_VERSION ?= v5.0.1 -CONTROLLER_TOOLS_VERSION ?= v0.12.0 - -.PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading. -$(KUSTOMIZE): $(LOCALBIN) - @if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \ - echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \ - rm -rf $(LOCALBIN)/kustomize; \ - fi - test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION) - -.PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. -$(CONTROLLER_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ - GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) - -.PHONY: envtest -envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. -$(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest diff --git a/testdata/project-v4-declarative-v1/PROJECT b/testdata/project-v4-declarative-v1/PROJECT deleted file mode 100644 index 9753638b39..0000000000 --- a/testdata/project-v4-declarative-v1/PROJECT +++ /dev/null @@ -1,53 +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 -- declarative.go.kubebuilder.io/v1 -plugins: - declarative.go.kubebuilder.io/v1: - resources: - - domain: testproject.org - group: crew - kind: Captain - version: v1 - - domain: testproject.org - group: crew - kind: FirstMate - version: v1 - - domain: testproject.org - group: crew - kind: Admiral - version: v1 -projectName: project-v4-declarative-v1 -repo: sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1 -resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: crew - kind: Captain - path: sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1 - version: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: testproject.org - group: crew - kind: FirstMate - path: sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1 - version: v1 -- api: - crdVersion: v1 - controller: true - domain: testproject.org - group: crew - kind: Admiral - path: sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1 - version: v1 -version: "3" diff --git a/testdata/project-v4-declarative-v1/README.md b/testdata/project-v4-declarative-v1/README.md deleted file mode 100644 index d798867cdd..0000000000 --- a/testdata/project-v4-declarative-v1/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# project-v4-declarative-v1 -// TODO(user): Add simple overview of use/purpose - -## Description -// TODO(user): An in-depth paragraph about your project and overview of use - -## Getting Started -You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster. -**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows). - -### Running on the cluster -1. Install Instances of Custom Resources: - -```sh -kubectl apply -k config/samples/ -``` - -2. Build and push your image to the location specified by `IMG`: - -```sh -make docker-build docker-push IMG=/project-v4-declarative-v1:tag -``` - -3. Deploy the controller to the cluster with the image specified by `IMG`: - -```sh -make deploy IMG=/project-v4-declarative-v1:tag -``` - -### Uninstall CRDs -To delete the CRDs from the cluster: - -```sh -make uninstall -``` - -### Undeploy controller -UnDeploy the controller from the cluster: - -```sh -make undeploy -``` - -## Contributing -// TODO(user): Add detailed information on how you would like others to contribute to this project - -### How it works -This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/). - -It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/), -which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. - -### Test It Out -1. Install the CRDs into the cluster: - -```sh -make install -``` - -2. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running): - -```sh -make run -``` - -**NOTE:** You can also run this in one step by running: `make install run` - -### Modifying the API definitions -If you are editing the API definitions, generate the manifests such as CRs or CRDs using: - -```sh -make manifests -``` - -**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 2023 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-declarative-v1/api/v1/admiral_types.go b/testdata/project-v4-declarative-v1/api/v1/admiral_types.go deleted file mode 100644 index 83f507b191..0000000000 --- a/testdata/project-v4-declarative-v1/api/v1/admiral_types.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2023 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" - addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1" -) - -// 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. - -// AdmiralSpec defines the desired state of Admiral -type AdmiralSpec struct { - addonv1alpha1.CommonSpec `json:",inline"` - addonv1alpha1.PatchSpec `json:",inline"` - - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// AdmiralStatus defines the observed state of Admiral -type AdmiralStatus struct { - addonv1alpha1.CommonStatus `json:",inline"` - - // 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 - -// Admiral is the Schema for the admirals API -type Admiral struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec AdmiralSpec `json:"spec,omitempty"` - Status AdmiralStatus `json:"status,omitempty"` -} - -var _ addonv1alpha1.CommonObject = &Admiral{} - -func (o *Admiral) ComponentName() string { - return "admiral" -} - -func (o *Admiral) CommonSpec() addonv1alpha1.CommonSpec { - return o.Spec.CommonSpec -} - -func (o *Admiral) PatchSpec() addonv1alpha1.PatchSpec { - return o.Spec.PatchSpec -} - -func (o *Admiral) GetCommonStatus() addonv1alpha1.CommonStatus { - return o.Status.CommonStatus -} - -func (o *Admiral) SetCommonStatus(s addonv1alpha1.CommonStatus) { - o.Status.CommonStatus = s -} - -//+kubebuilder:object:root=true - -// AdmiralList contains a list of Admiral -type AdmiralList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Admiral `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Admiral{}, &AdmiralList{}) -} diff --git a/testdata/project-v4-declarative-v1/api/v1/captain_types.go b/testdata/project-v4-declarative-v1/api/v1/captain_types.go deleted file mode 100644 index b82e24ec32..0000000000 --- a/testdata/project-v4-declarative-v1/api/v1/captain_types.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023 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" - addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1" -) - -// 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 { - addonv1alpha1.CommonSpec `json:",inline"` - addonv1alpha1.PatchSpec `json:",inline"` - - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// CaptainStatus defines the observed state of Captain -type CaptainStatus struct { - addonv1alpha1.CommonStatus `json:",inline"` - - // 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"` -} - -var _ addonv1alpha1.CommonObject = &Captain{} - -func (o *Captain) ComponentName() string { - return "captain" -} - -func (o *Captain) CommonSpec() addonv1alpha1.CommonSpec { - return o.Spec.CommonSpec -} - -func (o *Captain) PatchSpec() addonv1alpha1.PatchSpec { - return o.Spec.PatchSpec -} - -func (o *Captain) GetCommonStatus() addonv1alpha1.CommonStatus { - return o.Status.CommonStatus -} - -func (o *Captain) SetCommonStatus(s addonv1alpha1.CommonStatus) { - o.Status.CommonStatus = s -} - -//+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-declarative-v1/api/v1/firstmate_types.go b/testdata/project-v4-declarative-v1/api/v1/firstmate_types.go deleted file mode 100644 index a410f27f48..0000000000 --- a/testdata/project-v4-declarative-v1/api/v1/firstmate_types.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023 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" - addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1" -) - -// 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. - -// FirstMateSpec defines the desired state of FirstMate -type FirstMateSpec struct { - addonv1alpha1.CommonSpec `json:",inline"` - addonv1alpha1.PatchSpec `json:",inline"` - - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file -} - -// FirstMateStatus defines the observed state of FirstMate -type FirstMateStatus struct { - addonv1alpha1.CommonStatus `json:",inline"` - - // 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 - -// FirstMate is the Schema for the firstmates API -type FirstMate struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec FirstMateSpec `json:"spec,omitempty"` - Status FirstMateStatus `json:"status,omitempty"` -} - -var _ addonv1alpha1.CommonObject = &FirstMate{} - -func (o *FirstMate) ComponentName() string { - return "firstmate" -} - -func (o *FirstMate) CommonSpec() addonv1alpha1.CommonSpec { - return o.Spec.CommonSpec -} - -func (o *FirstMate) PatchSpec() addonv1alpha1.PatchSpec { - return o.Spec.PatchSpec -} - -func (o *FirstMate) GetCommonStatus() addonv1alpha1.CommonStatus { - return o.Status.CommonStatus -} - -func (o *FirstMate) SetCommonStatus(s addonv1alpha1.CommonStatus) { - o.Status.CommonStatus = s -} - -//+kubebuilder:object:root=true - -// FirstMateList contains a list of FirstMate -type FirstMateList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []FirstMate `json:"items"` -} - -func init() { - SchemeBuilder.Register(&FirstMate{}, &FirstMateList{}) -} diff --git a/testdata/project-v4-declarative-v1/api/v1/groupversion_info.go b/testdata/project-v4-declarative-v1/api/v1/groupversion_info.go deleted file mode 100644 index fe267f232c..0000000000 --- a/testdata/project-v4-declarative-v1/api/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2023 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-declarative-v1/api/v1/zz_generated.deepcopy.go b/testdata/project-v4-declarative-v1/api/v1/zz_generated.deepcopy.go deleted file mode 100644 index 334a92168c..0000000000 --- a/testdata/project-v4-declarative-v1/api/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,302 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright 2023 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 *Admiral) DeepCopyInto(out *Admiral) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Admiral. -func (in *Admiral) DeepCopy() *Admiral { - if in == nil { - return nil - } - out := new(Admiral) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Admiral) 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 *AdmiralList) DeepCopyInto(out *AdmiralList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Admiral, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralList. -func (in *AdmiralList) DeepCopy() *AdmiralList { - if in == nil { - return nil - } - out := new(AdmiralList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AdmiralList) 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 *AdmiralSpec) DeepCopyInto(out *AdmiralSpec) { - *out = *in - out.CommonSpec = in.CommonSpec - in.PatchSpec.DeepCopyInto(&out.PatchSpec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralSpec. -func (in *AdmiralSpec) DeepCopy() *AdmiralSpec { - if in == nil { - return nil - } - out := new(AdmiralSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmiralStatus) DeepCopyInto(out *AdmiralStatus) { - *out = *in - in.CommonStatus.DeepCopyInto(&out.CommonStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralStatus. -func (in *AdmiralStatus) DeepCopy() *AdmiralStatus { - if in == nil { - return nil - } - out := new(AdmiralStatus) - in.DeepCopyInto(out) - return out -} - -// 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) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.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 - out.CommonSpec = in.CommonSpec - in.PatchSpec.DeepCopyInto(&out.PatchSpec) -} - -// 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 - in.CommonStatus.DeepCopyInto(&out.CommonStatus) -} - -// 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 -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FirstMate) DeepCopyInto(out *FirstMate) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMate. -func (in *FirstMate) DeepCopy() *FirstMate { - if in == nil { - return nil - } - out := new(FirstMate) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FirstMate) 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 *FirstMateList) DeepCopyInto(out *FirstMateList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]FirstMate, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateList. -func (in *FirstMateList) DeepCopy() *FirstMateList { - if in == nil { - return nil - } - out := new(FirstMateList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FirstMateList) 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 *FirstMateSpec) DeepCopyInto(out *FirstMateSpec) { - *out = *in - out.CommonSpec = in.CommonSpec - in.PatchSpec.DeepCopyInto(&out.PatchSpec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateSpec. -func (in *FirstMateSpec) DeepCopy() *FirstMateSpec { - if in == nil { - return nil - } - out := new(FirstMateSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FirstMateStatus) DeepCopyInto(out *FirstMateStatus) { - *out = *in - in.CommonStatus.DeepCopyInto(&out.CommonStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateStatus. -func (in *FirstMateStatus) DeepCopy() *FirstMateStatus { - if in == nil { - return nil - } - out := new(FirstMateStatus) - in.DeepCopyInto(out) - return out -} diff --git a/testdata/project-v4-declarative-v1/channels/packages/admiral/0.0.1/manifest.yaml b/testdata/project-v4-declarative-v1/channels/packages/admiral/0.0.1/manifest.yaml deleted file mode 100644 index af9a253c58..0000000000 --- a/testdata/project-v4-declarative-v1/channels/packages/admiral/0.0.1/manifest.yaml +++ /dev/null @@ -1 +0,0 @@ -# Placeholder manifest - replace with the manifest for your addon diff --git a/testdata/project-v4-declarative-v1/channels/packages/captain/0.0.1/manifest.yaml b/testdata/project-v4-declarative-v1/channels/packages/captain/0.0.1/manifest.yaml deleted file mode 100644 index af9a253c58..0000000000 --- a/testdata/project-v4-declarative-v1/channels/packages/captain/0.0.1/manifest.yaml +++ /dev/null @@ -1 +0,0 @@ -# Placeholder manifest - replace with the manifest for your addon diff --git a/testdata/project-v4-declarative-v1/channels/packages/firstmate/0.0.1/manifest.yaml b/testdata/project-v4-declarative-v1/channels/packages/firstmate/0.0.1/manifest.yaml deleted file mode 100644 index af9a253c58..0000000000 --- a/testdata/project-v4-declarative-v1/channels/packages/firstmate/0.0.1/manifest.yaml +++ /dev/null @@ -1 +0,0 @@ -# Placeholder manifest - replace with the manifest for your addon diff --git a/testdata/project-v4-declarative-v1/channels/stable b/testdata/project-v4-declarative-v1/channels/stable deleted file mode 100644 index 31216a4aca..0000000000 --- a/testdata/project-v4-declarative-v1/channels/stable +++ /dev/null @@ -1,3 +0,0 @@ -# Versions for the stable channel -manifests: -- version: 0.0.1 diff --git a/testdata/project-v4-declarative-v1/cmd/main.go b/testdata/project-v4-declarative-v1/cmd/main.go deleted file mode 100644 index 4f90472a04..0000000000 --- a/testdata/project-v4-declarative-v1/cmd/main.go +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright 2023 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 ( - "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" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1" - "sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/internal/controller" - //+kubebuilder:scaffold:imports -) - -var ( - scheme = runtime.NewScheme() - setupLog = ctrl.Log.WithName("setup") -) - -func init() { - utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - - utilruntime.Must(crewv1.AddToScheme(scheme)) - //+kubebuilder:scaffold:scheme -} - -func main() { - var metricsAddr string - var enableLeaderElection bool - var probeAddr string - flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") - 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.") - opts := zap.Options{ - Development: true, - } - opts.BindFlags(flag.CommandLine) - flag.Parse() - - ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) - - mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, - HealthProbeBindAddress: probeAddr, - LeaderElection: enableLeaderElection, - LeaderElectionID: "661f9a6b.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 = (&controller.CaptainReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Captain") - os.Exit(1) - } - if err = (&controller.FirstMateReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "FirstMate") - os.Exit(1) - } - if err = (&controller.AdmiralReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "Admiral") - 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-declarative-v1/config/crd/bases/crew.testproject.org_admirals.yaml b/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_admirals.yaml deleted file mode 100644 index 730c7e63b5..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_admirals.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: admirals.crew.testproject.org -spec: - group: crew.testproject.org - names: - kind: Admiral - listKind: AdmiralList - plural: admirals - singular: admiral - scope: Cluster - versions: - - name: v1 - schema: - openAPIV3Schema: - description: Admiral is the Schema for the admirals 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: AdmiralSpec defines the desired state of Admiral - properties: - channel: - description: 'Channel specifies a channel that can be used to resolve - a specific addon, eg: stable It will be ignored if Version is specified' - type: string - patches: - items: - type: object - x-kubernetes-preserve-unknown-fields: true - type: array - version: - description: Version specifies the exact addon version to be deployed, - eg 1.2.3 It should not be specified if Channel is specified - type: string - type: object - status: - description: AdmiralStatus defines the observed state of Admiral - properties: - errors: - items: - type: string - type: array - healthy: - type: boolean - phase: - type: string - required: - - healthy - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_captains.yaml b/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_captains.yaml deleted file mode 100644 index d007d81277..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_captains.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - 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: - channel: - description: 'Channel specifies a channel that can be used to resolve - a specific addon, eg: stable It will be ignored if Version is specified' - type: string - patches: - items: - type: object - x-kubernetes-preserve-unknown-fields: true - type: array - version: - description: Version specifies the exact addon version to be deployed, - eg 1.2.3 It should not be specified if Channel is specified - type: string - type: object - status: - description: CaptainStatus defines the observed state of Captain - properties: - errors: - items: - type: string - type: array - healthy: - type: boolean - phase: - type: string - required: - - healthy - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_firstmates.yaml b/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_firstmates.yaml deleted file mode 100644 index 85bae3b3f1..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/bases/crew.testproject.org_firstmates.yaml +++ /dev/null @@ -1,69 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.12.0 - name: firstmates.crew.testproject.org -spec: - group: crew.testproject.org - names: - kind: FirstMate - listKind: FirstMateList - plural: firstmates - singular: firstmate - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: FirstMate is the Schema for the firstmates 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: FirstMateSpec defines the desired state of FirstMate - properties: - channel: - description: 'Channel specifies a channel that can be used to resolve - a specific addon, eg: stable It will be ignored if Version is specified' - type: string - patches: - items: - type: object - x-kubernetes-preserve-unknown-fields: true - type: array - version: - description: Version specifies the exact addon version to be deployed, - eg 1.2.3 It should not be specified if Channel is specified - type: string - type: object - status: - description: FirstMateStatus defines the observed state of FirstMate - properties: - errors: - items: - type: string - type: array - healthy: - type: boolean - phase: - type: string - required: - - healthy - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/testdata/project-v4-declarative-v1/config/crd/kustomization.yaml b/testdata/project-v4-declarative-v1/config/crd/kustomization.yaml deleted file mode 100644 index 687526d8e7..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/kustomization.yaml +++ /dev/null @@ -1,27 +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/crew.testproject.org_firstmates.yaml -- bases/crew.testproject.org_admirals.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_captains.yaml -#- path: patches/webhook_in_firstmates.yaml -#- path: patches/webhook_in_admirals.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_captains.yaml -#- path: patches/cainjection_in_firstmates.yaml -#- path: patches/cainjection_in_admirals.yaml -#+kubebuilder:scaffold:crdkustomizecainjectionpatch - -# the following config is for teaching kustomize how to do kustomization for CRDs. -configurations: -- kustomizeconfig.yaml diff --git a/testdata/project-v4-declarative-v1/config/crd/kustomizeconfig.yaml b/testdata/project-v4-declarative-v1/config/crd/kustomizeconfig.yaml deleted file mode 100644 index ec5c150a9d..0000000000 --- a/testdata/project-v4-declarative-v1/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-declarative-v1/config/crd/patches/cainjection_in_admirals.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_admirals.yaml deleted file mode 100644 index 49bfa257d3..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_admirals.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: admirals.crew.testproject.org diff --git a/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_captains.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_captains.yaml deleted file mode 100644 index fba0c3ed6f..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_captains.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: captains.crew.testproject.org diff --git a/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_firstmates.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_firstmates.yaml deleted file mode 100644 index 69292458eb..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/cainjection_in_firstmates.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: firstmates.crew.testproject.org diff --git a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_admirals.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_admirals.yaml deleted file mode 100644 index 0ce2808578..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_admirals.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: admirals.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_captains.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_captains.yaml deleted file mode 100644 index f73ae2e8ab..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_captains.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: captains.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_firstmates.yaml b/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_firstmates.yaml deleted file mode 100644 index 76ee5acedb..0000000000 --- a/testdata/project-v4-declarative-v1/config/crd/patches/webhook_in_firstmates.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: firstmates.crew.testproject.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/testdata/project-v4-declarative-v1/config/default/kustomization.yaml b/testdata/project-v4-declarative-v1/config/default/kustomization.yaml deleted file mode 100644 index f1e0ad9272..0000000000 --- a/testdata/project-v4-declarative-v1/config/default/kustomization.yaml +++ /dev/null @@ -1,144 +0,0 @@ -# Adds namespace to all resources. -namespace: project-v4-declarative-v1-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-declarative-v1- - -# 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 - -patchesStrategicMerge: -# Protect the /metrics endpoint by putting it behind auth. -# If you want your controller-manager to expose the /metrics -# endpoint w/o any authn/z, please comment the following line. -- manager_auth_proxy_patch.yaml - - - -# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in -# crd/kustomization.yaml -#- 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 -#- 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-declarative-v1/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v4-declarative-v1/config/default/manager_auth_proxy_patch.yaml deleted file mode 100644 index 73fad2a675..0000000000 --- a/testdata/project-v4-declarative-v1/config/default/manager_auth_proxy_patch.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# This patch inject a sidecar container which is a HTTP proxy for the -# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system -spec: - template: - spec: - containers: - - name: kube-rbac-proxy - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - "ALL" - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.14.1 - args: - - "--secure-listen-address=0.0.0.0:8443" - - "--upstream=http://127.0.0.1:8080/" - - "--logtostderr=true" - - "--v=0" - ports: - - containerPort: 8443 - protocol: TCP - name: https - resources: - limits: - cpu: 500m - memory: 128Mi - requests: - cpu: 5m - memory: 64Mi - - name: manager - args: - - "--health-probe-bind-address=:8081" - - "--metrics-bind-address=127.0.0.1:8080" - - "--leader-elect" diff --git a/testdata/project-v4-declarative-v1/config/default/manager_config_patch.yaml b/testdata/project-v4-declarative-v1/config/default/manager_config_patch.yaml deleted file mode 100644 index f6f5891692..0000000000 --- a/testdata/project-v4-declarative-v1/config/default/manager_config_patch.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system -spec: - template: - spec: - containers: - - name: manager diff --git a/testdata/project-v4-declarative-v1/config/manager/kustomization.yaml b/testdata/project-v4-declarative-v1/config/manager/kustomization.yaml deleted file mode 100644 index 5c5f0b84cb..0000000000 --- a/testdata/project-v4-declarative-v1/config/manager/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: -- manager.yaml diff --git a/testdata/project-v4-declarative-v1/config/manager/manager.yaml b/testdata/project-v4-declarative-v1/config/manager/manager.yaml deleted file mode 100644 index 3c451f1011..0000000000 --- a/testdata/project-v4-declarative-v1/config/manager/manager.yaml +++ /dev/null @@ -1,102 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: namespace - app.kubernetes.io/instance: system - app.kubernetes.io/component: manager - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - 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: deployment - app.kubernetes.io/instance: controller-manager - app.kubernetes.io/component: manager - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - 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 - 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-declarative-v1/config/prometheus/kustomization.yaml b/testdata/project-v4-declarative-v1/config/prometheus/kustomization.yaml deleted file mode 100644 index ed137168a1..0000000000 --- a/testdata/project-v4-declarative-v1/config/prometheus/kustomization.yaml +++ /dev/null @@ -1,2 +0,0 @@ -resources: -- monitor.yaml diff --git a/testdata/project-v4-declarative-v1/config/prometheus/monitor.yaml b/testdata/project-v4-declarative-v1/config/prometheus/monitor.yaml deleted file mode 100644 index 61fc67b22f..0000000000 --- a/testdata/project-v4-declarative-v1/config/prometheus/monitor.yaml +++ /dev/null @@ -1,26 +0,0 @@ - -# Prometheus Monitor Service (Metrics) -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: servicemonitor - app.kubernetes.io/instance: controller-manager-metrics-monitor - app.kubernetes.io/component: metrics - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-monitor - namespace: system -spec: - endpoints: - - path: /metrics - port: https - scheme: https - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token - tlsConfig: - insecureSkipVerify: true - selector: - matchLabels: - control-plane: controller-manager diff --git a/testdata/project-v4-declarative-v1/config/rbac/admiral_editor_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/admiral_editor_role.yaml deleted file mode 100644 index 1576cae697..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/admiral_editor_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# permissions for end users to edit admirals. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: admiral-editor-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: admiral-editor-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - admirals - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - admirals/status - verbs: - - get diff --git a/testdata/project-v4-declarative-v1/config/rbac/admiral_viewer_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/admiral_viewer_role.yaml deleted file mode 100644 index c99224d4ef..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/admiral_viewer_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to view admirals. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: admiral-viewer-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: admiral-viewer-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - admirals - verbs: - - get - - list - - watch -- apiGroups: - - crew.testproject.org - resources: - - admirals/status - verbs: - - get diff --git a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_client_clusterrole.yaml b/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_client_clusterrole.yaml deleted file mode 100644 index 919613c489..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_client_clusterrole.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: metrics-reader - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: metrics-reader -rules: -- nonResourceURLs: - - "/metrics" - verbs: - - get diff --git a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role.yaml deleted file mode 100644 index 357383f9f7..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: proxy-role - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: proxy-role -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create diff --git a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role_binding.yaml b/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role_binding.yaml deleted file mode 100644 index 1d36447d71..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_role_binding.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: clusterrolebinding - app.kubernetes.io/instance: proxy-rolebinding - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: proxy-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: proxy-role -subjects: -- kind: ServiceAccount - name: controller-manager - namespace: system diff --git a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_service.yaml b/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_service.yaml deleted file mode 100644 index 30eca5566f..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/auth_proxy_service.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - control-plane: controller-manager - app.kubernetes.io/name: service - app.kubernetes.io/instance: controller-manager-metrics-service - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: controller-manager-metrics-service - namespace: system -spec: - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: https - selector: - control-plane: controller-manager diff --git a/testdata/project-v4-declarative-v1/config/rbac/captain_editor_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/captain_editor_role.yaml deleted file mode 100644 index 915caa6747..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/captain_editor_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# permissions for end users to edit captains. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: captain-editor-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: 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-declarative-v1/config/rbac/captain_viewer_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/captain_viewer_role.yaml deleted file mode 100644 index 64f1902b10..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/captain_viewer_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to view captains. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: captain-viewer-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: 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-declarative-v1/config/rbac/firstmate_editor_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/firstmate_editor_role.yaml deleted file mode 100644 index d006022868..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/firstmate_editor_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# permissions for end users to edit firstmates. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: firstmate-editor-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: firstmate-editor-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - firstmates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - firstmates/status - verbs: - - get diff --git a/testdata/project-v4-declarative-v1/config/rbac/firstmate_viewer_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/firstmate_viewer_role.yaml deleted file mode 100644 index f73a37dc0d..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/firstmate_viewer_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to view firstmates. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: firstmate-viewer-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: firstmate-viewer-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - firstmates - verbs: - - get - - list - - watch -- apiGroups: - - crew.testproject.org - resources: - - firstmates/status - verbs: - - get diff --git a/testdata/project-v4-declarative-v1/config/rbac/kustomization.yaml b/testdata/project-v4-declarative-v1/config/rbac/kustomization.yaml deleted file mode 100644 index 731832a6ac..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/kustomization.yaml +++ /dev/null @@ -1,18 +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 -# Comment the following 4 lines if you want to disable -# the auth proxy (https://github.com/brancz/kube-rbac-proxy) -# which protects your /metrics endpoint. -- auth_proxy_service.yaml -- auth_proxy_role.yaml -- auth_proxy_role_binding.yaml -- auth_proxy_client_clusterrole.yaml diff --git a/testdata/project-v4-declarative-v1/config/rbac/leader_election_role.yaml b/testdata/project-v4-declarative-v1/config/rbac/leader_election_role.yaml deleted file mode 100644 index d3daae8ea0..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/leader_election_role.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# permissions to do leader election. -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - labels: - app.kubernetes.io/name: role - app.kubernetes.io/instance: leader-election-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - 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-declarative-v1/config/rbac/leader_election_role_binding.yaml b/testdata/project-v4-declarative-v1/config/rbac/leader_election_role_binding.yaml deleted file mode 100644 index e888847394..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/leader_election_role_binding.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - labels: - app.kubernetes.io/name: rolebinding - app.kubernetes.io/instance: leader-election-rolebinding - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - 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-declarative-v1/config/rbac/role.yaml b/testdata/project-v4-declarative-v1/config/rbac/role.yaml deleted file mode 100644 index 6565ab5336..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/role.yaml +++ /dev/null @@ -1,66 +0,0 @@ ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: manager-role -rules: -- apiGroups: - - crew.testproject.org - resources: - - admirals - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - admirals/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/status - verbs: - - get - - patch - - update -- apiGroups: - - crew.testproject.org - resources: - - firstmates - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - crew.testproject.org - resources: - - firstmates/status - verbs: - - get - - patch - - update diff --git a/testdata/project-v4-declarative-v1/config/rbac/role_binding.yaml b/testdata/project-v4-declarative-v1/config/rbac/role_binding.yaml deleted file mode 100644 index 89468ce732..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/role_binding.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - labels: - app.kubernetes.io/name: clusterrolebinding - app.kubernetes.io/instance: manager-rolebinding - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - 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-declarative-v1/config/rbac/service_account.yaml b/testdata/project-v4-declarative-v1/config/rbac/service_account.yaml deleted file mode 100644 index 304dead705..0000000000 --- a/testdata/project-v4-declarative-v1/config/rbac/service_account.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - labels: - app.kubernetes.io/name: serviceaccount - app.kubernetes.io/instance: controller-manager-sa - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: project-v4-declarative-v1 - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - name: controller-manager - namespace: system diff --git a/testdata/project-v4-declarative-v1/config/samples/crew_v1_admiral.yaml b/testdata/project-v4-declarative-v1/config/samples/crew_v1_admiral.yaml deleted file mode 100644 index ebe264df03..0000000000 --- a/testdata/project-v4-declarative-v1/config/samples/crew_v1_admiral.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: crew.testproject.org/v1 -kind: Admiral -metadata: - labels: - app.kubernetes.io/name: admiral - app.kubernetes.io/instance: admiral-sample - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: project-v4-declarative-v1 - name: admiral-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-declarative-v1/config/samples/crew_v1_captain.yaml b/testdata/project-v4-declarative-v1/config/samples/crew_v1_captain.yaml deleted file mode 100644 index fa873e6254..0000000000 --- a/testdata/project-v4-declarative-v1/config/samples/crew_v1_captain.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: crew.testproject.org/v1 -kind: Captain -metadata: - labels: - app.kubernetes.io/name: captain - app.kubernetes.io/instance: captain-sample - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: project-v4-declarative-v1 - name: captain-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-declarative-v1/config/samples/crew_v1_firstmate.yaml b/testdata/project-v4-declarative-v1/config/samples/crew_v1_firstmate.yaml deleted file mode 100644 index c025672bde..0000000000 --- a/testdata/project-v4-declarative-v1/config/samples/crew_v1_firstmate.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: crew.testproject.org/v1 -kind: FirstMate -metadata: - labels: - app.kubernetes.io/name: firstmate - app.kubernetes.io/instance: firstmate-sample - app.kubernetes.io/part-of: project-v4-declarative-v1 - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: project-v4-declarative-v1 - name: firstmate-sample -spec: - # TODO(user): Add fields here diff --git a/testdata/project-v4-declarative-v1/config/samples/kustomization.yaml b/testdata/project-v4-declarative-v1/config/samples/kustomization.yaml deleted file mode 100644 index b5cf9e60f5..0000000000 --- a/testdata/project-v4-declarative-v1/config/samples/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ -## Append samples of your project ## -resources: -- crew_v1_captain.yaml -- crew_v1_firstmate.yaml -- crew_v1_admiral.yaml -#+kubebuilder:scaffold:manifestskustomizesamples diff --git a/testdata/project-v4-declarative-v1/go.mod b/testdata/project-v4-declarative-v1/go.mod deleted file mode 100644 index b93d3bb786..0000000000 --- a/testdata/project-v4-declarative-v1/go.mod +++ /dev/null @@ -1,116 +0,0 @@ -module sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1 - -go 1.20 - -require ( - github.com/go-logr/logr v1.2.4 - github.com/onsi/ginkgo/v2 v2.9.5 - github.com/onsi/gomega v1.27.7 - k8s.io/apimachinery v0.27.2 - k8s.io/client-go v0.27.2 - sigs.k8s.io/controller-runtime v0.15.0 - sigs.k8s.io/kubebuilder-declarative-pattern v0.13.0-beta.1.0.20230604223042-9a410556b95d -) - -require ( - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/MakeNowJust/heredoc v1.0.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.10.2 // indirect - github.com/emirpasic/gods v1.12.0 // indirect - github.com/evanphx/json-patch v4.12.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect - github.com/fatih/camelcase v1.0.0 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/fvbommel/sortorder v1.0.1 // indirect - github.com/go-errors/errors v1.0.1 // indirect - github.com/go-git/gcfg v1.5.0 // indirect - github.com/go-git/go-billy/v5 v5.0.0 // indirect - github.com/go-git/go-git/v5 v5.1.0 // indirect - github.com/go-logr/zapr v1.2.4 // 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.3 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // 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.3 // indirect - github.com/google/btree v1.0.1 // indirect - github.com/google/gnostic v0.6.9 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect - github.com/imdario/mergo v0.3.15 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect - github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/moby/spdystream v0.2.0 // indirect - github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.15.1 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.43.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect - github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sergi/go-diff v1.1.0 // indirect - github.com/spf13/cobra v1.6.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/xanzy/ssh-agent v0.2.1 // indirect - github.com/xlab/treeprint v1.1.0 // indirect - go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect - go.uber.org/atomic v1.7.0 // indirect - go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.9.1 // indirect - gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.30.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.27.2 // indirect - k8s.io/apiextensions-apiserver v0.27.2 // indirect - k8s.io/cli-runtime v0.26.3 // indirect - k8s.io/component-base v0.27.2 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/kubectl v0.26.3 // indirect - k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect - sigs.k8s.io/cli-utils v0.33.0 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kubebuilder-declarative-pattern/applylib v0.0.0-20230420203711-4abaa68e1923 // indirect - sigs.k8s.io/kustomize/api v0.12.1 // indirect - sigs.k8s.io/kustomize/kstatus v0.0.2-0.20200509233124-065f70705d4d // indirect - sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) diff --git a/testdata/project-v4-declarative-v1/hack/boilerplate.go.txt b/testdata/project-v4-declarative-v1/hack/boilerplate.go.txt deleted file mode 100644 index 8c36d12450..0000000000 --- a/testdata/project-v4-declarative-v1/hack/boilerplate.go.txt +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright 2023 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-declarative-v1/internal/controller/admiral_controller.go b/testdata/project-v4-declarative-v1/internal/controller/admiral_controller.go deleted file mode 100644 index 126171a2a1..0000000000 --- a/testdata/project-v4-declarative-v1/internal/controller/admiral_controller.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023 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 ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1" -) - -var _ reconcile.Reconciler = &AdmiralReconciler{} - -// AdmiralReconciler reconciles a Admiral object -type AdmiralReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme - - declarative.Reconciler -} - -//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/status,verbs=get;update;patch - -// SetupWithManager sets up the controller with the Manager. -func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error { - addon.Init() - - labels := map[string]string{ - "k8s-app": "admiral", - } - - watchLabels := declarative.SourceLabel(mgr.GetScheme()) - - if err := r.Reconciler.Init(mgr, &crewv1.Admiral{}, - declarative.WithObjectTransform(declarative.AddLabels(labels)), - declarative.WithOwner(declarative.SourceAsOwner), - declarative.WithLabels(watchLabels), - declarative.WithStatus(status.NewBasic(mgr.GetClient())), - // TODO: add an application to your manifest: declarative.WithObjectTransform(addon.TransformApplicationFromStatus), - // TODO: add an application to your manifest: declarative.WithManagedApplication(watchLabels), - declarative.WithObjectTransform(addon.ApplyPatches), - ); err != nil { - return err - } - - c, err := controller.New("admiral-controller", mgr, controller.Options{Reconciler: r}) - if err != nil { - return err - } - - // Watch for changes to Admiral - err = c.Watch(source.Kind(mgr.GetCache(), &crewv1.Admiral{}), &handler.EnqueueRequestForObject{}) - if err != nil { - return err - } - - // Watch for changes to deployed objects - err = declarative.WatchAll(mgr.GetConfig(), c, r, watchLabels) - if err != nil { - return err - } - - return nil -} diff --git a/testdata/project-v4-declarative-v1/internal/controller/captain_controller.go b/testdata/project-v4-declarative-v1/internal/controller/captain_controller.go deleted file mode 100644 index 5de7552186..0000000000 --- a/testdata/project-v4-declarative-v1/internal/controller/captain_controller.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023 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 ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1" -) - -var _ reconcile.Reconciler = &CaptainReconciler{} - -// CaptainReconciler reconciles a Captain object -type CaptainReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme - - declarative.Reconciler -} - -//+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 - -// SetupWithManager sets up the controller with the Manager. -func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error { - addon.Init() - - labels := map[string]string{ - "k8s-app": "captain", - } - - watchLabels := declarative.SourceLabel(mgr.GetScheme()) - - if err := r.Reconciler.Init(mgr, &crewv1.Captain{}, - declarative.WithObjectTransform(declarative.AddLabels(labels)), - declarative.WithOwner(declarative.SourceAsOwner), - declarative.WithLabels(watchLabels), - declarative.WithStatus(status.NewBasic(mgr.GetClient())), - // TODO: add an application to your manifest: declarative.WithObjectTransform(addon.TransformApplicationFromStatus), - // TODO: add an application to your manifest: declarative.WithManagedApplication(watchLabels), - declarative.WithObjectTransform(addon.ApplyPatches), - ); err != nil { - return err - } - - c, err := controller.New("captain-controller", mgr, controller.Options{Reconciler: r}) - if err != nil { - return err - } - - // Watch for changes to Captain - err = c.Watch(source.Kind(mgr.GetCache(), &crewv1.Captain{}), &handler.EnqueueRequestForObject{}) - if err != nil { - return err - } - - // Watch for changes to deployed objects - err = declarative.WatchAll(mgr.GetConfig(), c, r, watchLabels) - if err != nil { - return err - } - - return nil -} diff --git a/testdata/project-v4-declarative-v1/internal/controller/firstmate_controller.go b/testdata/project-v4-declarative-v1/internal/controller/firstmate_controller.go deleted file mode 100644 index 28d592cad9..0000000000 --- a/testdata/project-v4-declarative-v1/internal/controller/firstmate_controller.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023 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 ( - "github.com/go-logr/logr" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status" - "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative" - - crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v4-declarative-v1/api/v1" -) - -var _ reconcile.Reconciler = &FirstMateReconciler{} - -// FirstMateReconciler reconciles a FirstMate object -type FirstMateReconciler struct { - client.Client - Log logr.Logger - Scheme *runtime.Scheme - - declarative.Reconciler -} - -//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/status,verbs=get;update;patch - -// SetupWithManager sets up the controller with the Manager. -func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error { - addon.Init() - - labels := map[string]string{ - "k8s-app": "firstmate", - } - - watchLabels := declarative.SourceLabel(mgr.GetScheme()) - - if err := r.Reconciler.Init(mgr, &crewv1.FirstMate{}, - declarative.WithObjectTransform(declarative.AddLabels(labels)), - declarative.WithOwner(declarative.SourceAsOwner), - declarative.WithLabels(watchLabels), - declarative.WithStatus(status.NewBasic(mgr.GetClient())), - // TODO: add an application to your manifest: declarative.WithObjectTransform(addon.TransformApplicationFromStatus), - // TODO: add an application to your manifest: declarative.WithManagedApplication(watchLabels), - declarative.WithObjectTransform(addon.ApplyPatches), - ); err != nil { - return err - } - - c, err := controller.New("firstmate-controller", mgr, controller.Options{Reconciler: r}) - if err != nil { - return err - } - - // Watch for changes to FirstMate - err = c.Watch(source.Kind(mgr.GetCache(), &crewv1.FirstMate{}), &handler.EnqueueRequestForObject{}) - if err != nil { - return err - } - - // Watch for changes to deployed objects - err = declarative.WatchAll(mgr.GetConfig(), c, r, watchLabels) - if err != nil { - return err - } - - return nil -} diff --git a/testdata/project-v4-declarative-v1/internal/controller/suite_test.go b/testdata/project-v4-declarative-v1/internal/controller/suite_test.go deleted file mode 100644 index de5e58a7d4..0000000000 --- a/testdata/project-v4-declarative-v1/internal/controller/suite_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2023 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 ( - "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-declarative-v1/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 - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - 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.27.1-%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") - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -})