From 8f2f5eacbb8be33655706198b2e53374a2e705d9 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Tue, 29 Apr 2025 17:32:35 +0200 Subject: [PATCH 01/22] remove old files --- Makefile | 283 ------------------------------------ hack/common/Dockerfile | 12 -- hack/common/build-binary.sh | 18 --- hack/common/build-image.sh | 33 ----- hack/common/environment.sh | 17 --- hack/common/get-registry.sh | 40 ----- hack/common/get-version.sh | 22 --- hack/common/lib.sh | 12 -- 8 files changed, 437 deletions(-) delete mode 100644 Makefile delete mode 100644 hack/common/Dockerfile delete mode 100755 hack/common/build-binary.sh delete mode 100755 hack/common/build-image.sh delete mode 100755 hack/common/environment.sh delete mode 100755 hack/common/get-registry.sh delete mode 100755 hack/common/get-version.sh delete mode 100755 hack/common/lib.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index e7d274a..0000000 --- a/Makefile +++ /dev/null @@ -1,283 +0,0 @@ -PROJECT_FULL_NAME := control-plane-operator - -# Image URL to use all building/pushing image targets -IMG_VERSION ?= dev -IMG_BASE ?= $(PROJECT_FULL_NAME) -IMG ?= $(IMG_BASE):$(IMG_VERSION) -# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -# Pick from https://storage.googleapis.com/kubebuilder-tools -ENVTEST_K8S_VERSION = 1.30.0 - -export UUT_IMAGES = {"openmcp-project/control-plane-operator":"$(IMG)"} -SET_BASE_DIR := $(eval BASE_DIR=$(shell git rev-parse --show-toplevel)) -GENERATED_DIR := ${BASE_DIR}/hack/.generated - -# 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 - -GOOS ?= linux -GOARCH ?= $(shell go env GOARCH) -CONTAINER_PLATFORM ?= $(GOOS)/$(GOARCH) - -# 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 - $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=cmd/embedded/crds - -.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 - go tool cover --html=cover.out -o cover.html - go tool cover -func cover.out | tail -n 1 - -LINTER ?= $(LOCALBIN)/golangci-lint -LINTER_VERSION ?= v1.64.7 -.PHONY: golangci-lint -golangci-lint: localbin ## Download golangci-lint locally if necessary. If wrong version is installed, it will be overwritten. - test -s $(LINTER) && $(LINTER) --version | grep -q $(subst v,,$(LINTER_VERSION)) || \ - ( echo "Installing golangci-lint $(LINTER_VERSION) ..."; \ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) $(LINTER_VERSION) ) - - -.PHONY: lint -lint: golangci-lint ## Run golangci-lint to lint code - $(LOCALBIN)/golangci-lint run ./... --timeout=15m - -.PHONY: tidy -tidy: - go mod tidy -e - -.PHONY: verify -verify: lint goimports vet - - -.PHONY: prepare-release -prepare-release: lint goimports vet - -.PHONY: localbin -localbin: - @test -d $(LOCALBIN) || mkdir -p $(LOCALBIN) - -FORMATTER_VERSION ?= v0.26.0 - -.PHONY: goimports -goimports: localbin ## Download goimports locally if necessary. If wrong version is installed, it will be overwritten. - @test -s $(FORMATTER) && test -s hack/goimports_version && cat hack/goimports_version | grep -q $(FORMATTER_VERSION) || \ - ( echo "Installing goimports $(FORMATTER_VERSION) ..."; \ - GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(FORMATTER_VERSION) && \ - echo $(FORMATTER_VERSION) > hack/goimports_version ) - -##@ Build -build: generate ## Builds binaries for all components specified in COMPONENTS and all platforms specified in PLATFORMS. - @PLATFORMS=$(PLATFORMS) COMPONENTS=control-plane-operator ./hack/common/build-binary.sh - -.PHONY: run -run: manifests generate fmt vet ## Run a controller from your host. - go run ./cmd/main.go start - -PLATFORMS ?= linux/arm64,linux/amd64 -EFFECTIVE_VERSION ?=$(shell cat ./VERSION) - -.PHONY: image-build -image-build: ## Builds the docker images for all components specified in COMPONENTS and all platforms specified in PLATFORMS. Requires 'make build' to have run before. - @PLATFORMS=$(PLATFORMS) COMPONENTS=control-plane-operator EFFECTIVE_VERSION=$(EFFECTIVE_VERSION) ./hack/common/build-image.sh - - -.PHONY: docker-push -docker-push: ## Push docker image with the manager. - $(CONTAINER_TOOL) push ${IMG} - - -##@ 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 - - -.PHONY: pull-secrets -pull-secrets: - @echo "Creating Pull Secret(s)" - mkdir -p ${GENERATED_DIR} - ${BASE_DIR}/hack/create-token-opt.sh - -##@ 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 -GOTESTSUM ?= $(LOCALBIN)/gotestsum -KIND ?= kind # fix this to use tools - -## Tool Versions -KUSTOMIZE_VERSION ?= v5.1.1 -CONTROLLER_TOOLS_VERSION ?= v0.16.4 - -.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: gotestsum -gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary. -$(GOTESTSUM): $(LOCALBIN) - test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@latest - -.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 - -### ------------------------------------ DEVELOPMENT - LOCAL ------------------------------------ ### -.PHONY: dev-build -dev-build: docker-build - @echo "Finished building docker image" ${IMG} - -.PHONY: dev-base -dev-base: manifests kustomize dev-build dev-clean dev-cluster flux-install flux-secret helm-install-local - -.PHONY: dev-cluster -dev-cluster: - $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev - $(KIND) load docker-image ${IMG} --name=$(PROJECT_FULL_NAME)-dev - -.PHONY: dev-local -dev-local: - $(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev - $(MAKE) install - $(MAKE) flux-install - $(MAKE) flux-secret - -.PHONY: helm-install-local -helm-install-local: - helm upgrade --create-namespace --namespace co-system --install $(PROJECT_FULL_NAME) charts/$(PROJECT_FULL_NAME)/ -f test/e2e/testdata/values.yaml --set image.repository=$(IMG_BASE) --set image.tag=$(IMG_VERSION) --set image.pullPolicy=Never - -.PHONY: dev-clean -dev-clean: - $(KIND) delete cluster --name=$(PROJECT_FULL_NAME)-dev - -.PHONY: dev-run -dev-run: - ## todo: add flag --debug - go run ./cmd/main.go start - - -.PHONY: flux-install -flux-install: - kubectl apply -f https://github.com/fluxcd/flux2/releases/latest/download/install.yaml - -### ------------------------------------ HELM ------------------------------------ ### - -.PHONY: helm-chart -helm-chart: - OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/Chart.yaml.tpl > charts/$(PROJECT_FULL_NAME)/Chart.yaml - OPERATOR_VERSION=$(shell cat VERSION) envsubst < charts/$(PROJECT_FULL_NAME)/values.yaml.tpl > charts/$(PROJECT_FULL_NAME)/values.yaml - -### ------------------------------------------------------------------------------ ### - -# initializes pre-commit hooks using lefthook https://github.com/evilmartians/lefthook -lefthook: - @lefthook install - -### ------------------------------------ E2E - Tests ------------------------------------ ### -.PHONY: e2e -e2e: helm-chart docker-build e2e.prep run-e2e-with-report - -.PHONY: run-e2e -run-e2e: docker-build - go test -v ./... -tags=e2e - -.PHONY: run-e2e-with-report -run-e2e-with-report: docker-build run-e2e-with-report-only - -.PHONY: e2e.prep -e2e.prep: docker-build pull-secrets - echo E2E_IMAGES=$$UUT_IMAGES > e2e.env - echo PULL_SECRET_USER=$(shell cat ${GENERATED_DIR}/artifactory-user) > secret.env - -echo PULL_SECRET_PASSWORD=$(shell cat ${GENERATED_DIR}/artifactory-bearer-token.json) >> secret.env - -run-e2e-with-report-only: gotestsum - @echo "UUT_IMAGES=$$UUT_IMAGES" - $(GOTESTSUM) --debug --format standard-verbose --junitfile=integration-tests.xml -- --tags=e2e ./.../e2e -test.v -test.short -short -v -timeout 30m diff --git a/hack/common/Dockerfile b/hack/common/Dockerfile deleted file mode 100644 index c6783d8..0000000 --- a/hack/common/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# Use distroless as minimal base image to package the component binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot -ARG TARGETOS -ARG TARGETARCH -ARG COMPONENT -WORKDIR / -COPY bin/$COMPONENT-$TARGETOS.$TARGETARCH / -USER 65532:65532 - -# docker doesn't substitue args in ENTRYPOINT, so we replace this during the build script -ENTRYPOINT ["/"] diff --git a/hack/common/build-binary.sh b/hack/common/build-binary.sh deleted file mode 100755 index 94d5729..0000000 --- a/hack/common/build-binary.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -euo pipefail -source "$(realpath "$(dirname $0)/environment.sh")" - -echo -echo "> Building binaries ..." -( - cd "$PROJECT_ROOT" - for comp in ${COMPONENTS//,/ }; do - for pf in ${PLATFORMS//,/ }; do - echo "> Building binary for component '$comp' ($pf) ..." | indent 1 - os=${pf%/*} - arch=${pf#*/} - CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -a -o bin/${comp}-${os}.${arch} cmd/main.go | indent 2 - done - done -) diff --git a/hack/common/build-image.sh b/hack/common/build-image.sh deleted file mode 100755 index c1595c5..0000000 --- a/hack/common/build-image.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -set -euo pipefail -source "$(realpath "$(dirname $0)/environment.sh")" - -if [[ -z ${IMAGE_REGISTRY:-} ]]; then - IMAGE_REGISTRY=$("$COMMON_SCRIPT_DIR/get-registry.sh" -i) -fi - -VERSION=$("$COMMON_SCRIPT_DIR/get-version.sh") - -DOCKER_BUILDER_NAME="mcp-multiarch-builder" -if ! docker buildx ls | grep "$DOCKER_BUILDER_NAME" >/dev/null; then - docker buildx create --name "$DOCKER_BUILDER_NAME" -fi - -# remove temporary Dockerfile on exit -trap "rm -f \"${PROJECT_ROOT}/Dockerfile.tmp\"" EXIT - -echo -echo "> Building images ..." -for comp in ${COMPONENTS//,/ }; do - for pf in ${PLATFORMS//,/ }; do - os=${pf%/*} - arch=${pf#*/} - img="${IMAGE_REGISTRY}/${comp}:${VERSION}-${os}-${arch}" - echo "> Building image for component '$comp' ($pf): $img ..." | indent 1 - cat "${COMMON_SCRIPT_DIR}/Dockerfile" | sed "s//$comp/g" > "${PROJECT_ROOT}/Dockerfile.tmp" - docker buildx build --builder ${DOCKER_BUILDER_NAME} --load --build-arg COMPONENT=${comp} --platform ${pf} -t $img -f Dockerfile.tmp "${PROJECT_ROOT}" | indent 2 - done -done - -docker buildx rm "$DOCKER_BUILDER_NAME" \ No newline at end of file diff --git a/hack/common/environment.sh b/hack/common/environment.sh deleted file mode 100755 index 2d03251..0000000 --- a/hack/common/environment.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -export COMMON_SCRIPT_DIR="$(realpath "$(dirname ${BASH_SOURCE[0]})")" -source "$COMMON_SCRIPT_DIR/lib.sh" -export PROJECT_ROOT="${PROJECT_ROOT:-$(realpath "$COMMON_SCRIPT_DIR/../..")}" -export COMPONENT_DEFINITION_FILE="${COMPONENT_DEFINITION_FILE:-"$PROJECT_ROOT/components/components.yaml"}" - -export LOCALBIN="${LOCALBIN:-"$PROJECT_ROOT/bin"}" -export HELM="${HELM:-"$LOCALBIN/helm"}" -export JQ="${JQ:-"$LOCALBIN/jq"}" -export FORMATTER=${FORMATTER:-"$LOCALBIN/goimports"} -export OCM="${OCM:-"$LOCALBIN/ocm"}" -export YAML2JSON="${YAML2JSON:-"$LOCALBIN/yaml2json"}" - -if [[ -f "$COMMON_SCRIPT_DIR/../environment.sh" ]]; then - source "$COMMON_SCRIPT_DIR/../environment.sh" -fi diff --git a/hack/common/get-registry.sh b/hack/common/get-registry.sh deleted file mode 100755 index fe299fd..0000000 --- a/hack/common/get-registry.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -eu - -set -euo pipefail - -if [[ -z ${BASE_REGISTRY:-} ]]; then - BASE_REGISTRY=ghcr.io/openmcp-project -fi - -if [[ -z ${IMAGE_REGISTRY:-} ]]; then - IMAGE_REGISTRY=$BASE_REGISTRY -fi -if [[ -z ${CHART_REGISTRY:-} ]]; then - CHART_REGISTRY=$BASE_REGISTRY/charts -fi -if [[ -z ${COMPONENT_REGISTRY:-} ]]; then - COMPONENT_REGISTRY=$BASE_REGISTRY/components -fi - -mode="BASE_" - -while [[ "$#" -gt 0 ]]; do - case ${1:-} in - "-i"|"--image") - mode="IMAGE_" - ;; - "-h"|"--helm") - mode="CHART_" - ;; - "-c"|"--component") - mode="COMPONENT_" - ;; - *) - echo "invalid argument: $1" 1>&2 - exit 1 - ;; - esac - shift -done - -eval echo "\$${mode}REGISTRY" diff --git a/hack/common/get-version.sh b/hack/common/get-version.sh deleted file mode 100755 index afc4cc9..0000000 --- a/hack/common/get-version.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -eu - -if [[ -n ${EFFECTIVE_VERSION:-} ]] ; then - # running in the pipeline use the provided EFFECTIVE_VERSION - echo "$EFFECTIVE_VERSION" - exit 0 -fi - -set -euo pipefail -source "$(realpath "$(dirname $0)/environment.sh")" - -VERSION="$(cat "${PROJECT_ROOT}/VERSION")" - -( - cd "$PROJECT_ROOT" - - if [[ "$VERSION" = *-dev ]] ; then - VERSION="$VERSION-$(git rev-parse HEAD)" - fi - - echo "$VERSION" -) diff --git a/hack/common/lib.sh b/hack/common/lib.sh deleted file mode 100755 index fbbf560..0000000 --- a/hack/common/lib.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# pipe some text into 'indent X' to indent each line by X levels (one 'level' being two spaces) -function indent() { - local level=${1:-""} - if [[ -z "$level" ]]; then - level=1 - fi - local spaces=$(($level * 2)) - local iv=$(printf %${spaces}s) - sed "s/^/$iv/" -} \ No newline at end of file From 521a4b2d0faca13613179bf911ce9056d2751634 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Tue, 29 Apr 2025 17:32:56 +0200 Subject: [PATCH 02/22] add submodule --- .gitmodules | 3 +++ Makefile | 1 + hack/common | 1 + 3 files changed, 5 insertions(+) create mode 100644 .gitmodules create mode 120000 Makefile create mode 160000 hack/common diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c0425ec --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "hack/common"] + path = hack/common + url = https://github.com/openmcp-project/build diff --git a/Makefile b/Makefile new file mode 120000 index 0000000..2b98345 --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +hack/common/Makefile \ No newline at end of file diff --git a/hack/common b/hack/common new file mode 160000 index 0000000..f9fe558 --- /dev/null +++ b/hack/common @@ -0,0 +1 @@ +Subproject commit f9fe558a9ef4029d8268945d3ea86c9130039fdd From d32b3e803931758d4835b60d4c1ec56875bd07cc Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:05:17 +0200 Subject: [PATCH 03/22] add Taskfile --- Taskfile.yaml | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Taskfile.yaml diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..6b6f42b --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,107 @@ +version: 3 + +# vars: # cannot be specified here due to https://github.com/go-task/task/issues/2108 +# NESTED_MODULES: api +# API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' +# MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' +# CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' +# COMPONENTS: 'control-plane-operator' +# REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' +# GENERATE_DOCS_INDEX: "true" + +includes: + shared: + taskfile: hack/common/Taskfile_controller.yaml + flatten: true + excludes: + - test + - test-envtest-dep + - build:bin:val:test + - build-raw + - build:bin:build-raw + # put task names in here which are overwritten in this file + vars: + NESTED_MODULES: api + API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' + MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' + CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' + COMPONENTS: 'control-plane-operator' + REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' + GENERATE_DOCS_INDEX: "true" + ENVTEST_REQUIRED: "true" + ENVTEST_K8S_VERSION: "1.30.0" + common: # imported a second time so that overwriting task definitions can call the overwritten task with a 'c:' prefix + taskfile: hack/common/Taskfile_controller.yaml + internal: true + aliases: + - c + vars: + NESTED_MODULES: api + API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' + MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' + CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' + COMPONENTS: 'control-plane-operator' + REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' + GENERATE_DOCS_INDEX: "true" + ENVTEST_REQUIRED: "true" + ENVTEST_K8S_VERSION: "1.30.0" + + +# tasks: +# build:bin:val:test: +# desc: " Run all tests." +# env: +# ENVTEST_K8S_VERSION: "1.30.0" + +# run: once +# # requires: +# # vars: +# # - CODE_DIRS +# deps: +# - test-envtest-dep +# cmds: +# - 'PROJECT_ROOT="{{.ROOT_DIR2}}" NESTED_MODULES="{{.NESTED_MODULES}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' + +tasks: + test: + desc: " Run all tests." + run: once + aliases: + - build:bin:val:test + vars: + NESTED_MODULES: api + API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' + MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' + CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' + COMPONENTS: 'control-plane-operator' + REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' + GENERATE_DOCS_INDEX: "true" + ENVTEST_REQUIRED: "true" + ENVTEST_K8S_VERSION: "1.30.0" + deps: + - test-envtest-dep + cmds: + - 'PROJECT_ROOT="{{.ROOT_DIR2}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' + + test-envtest-dep: + desc: " Install the envtest dependency, if marked as required." + run: once + status: + - '[ "{{.ENVTEST_REQUIRED | default "false"}}" != "true" ]' + cmds: + - task: tools:envtest + internal: true + + build-raw: + desc: " Build the binary. Opposed to the regular build, this one just builds and skips code generation/validation tasks." + summary: | + This task builds the binary for the current operating system and architecture. + To overwrite this, set the 'OS' and 'ARCH' environment variables. + The binary is saved in the 'bin' folder, as $COMPONENT.$OS-$ARCH. + aliases: + - build:bin:build-raw + cmds: + - for: + var: COMPONENTS + as: COMPONENT + cmd: 'CGO_ENABLED=0 GOOS={{.OS}} GOARCH={{.ARCH}} go build -a -o {{.ROOT_DIR2}}/bin/{{.COMPONENT}}.{{.OS}}-{{.ARCH}} {{.ROOT_DIR2}}/cmd/main.go' \ No newline at end of file From 91b5b8a290caf0b0654fe7a9ce52acba02349e4c Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:05:47 +0200 Subject: [PATCH 04/22] add generated files --- ...e.orchestrate.cloud.sap_controlplanes.yaml | 539 ++++++++++++++++++ ...oud.sap_crossplanepackagerestrictions.yaml | 108 ++++ ...orchestrate.cloud.sap_releasechannels.yaml | 155 +++++ docs/README.md | 3 + 4 files changed, 805 insertions(+) create mode 100644 api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml create mode 100644 api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml create mode 100644 api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml create mode 100644 docs/README.md diff --git a/api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml new file mode 100644 index 0000000..d34ba8a --- /dev/null +++ b/api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml @@ -0,0 +1,539 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.3 + name: controlplanes.core.orchestrate.cloud.sap +spec: + group: core.orchestrate.cloud.sap + names: + kind: ControlPlane + listKind: ControlPlaneList + plural: controlplanes + shortNames: + - cp + singular: controlplane + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + - jsonPath: .status.componentsHealthy + name: Components Healthy + type: integer + - jsonPath: .status.componentsEnabled + name: Components Enabled + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: ControlPlane is the Schema for the ControlPlane 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: ControlPlaneSpec defines the desired state of ControlPlane + properties: + btpServiceOperator: + description: |- + Configuration for the BTP Service Operator. More info: + https://github.com/SAP/sap-btp-service-operator + properties: + chart: + description: Optional custom chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + values: + description: Optional additional values that should be passed + to the BTP Service Operator Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of BTP Service Operator to install. + type: string + required: + - version + type: object + certManager: + description: |- + CertManager configures the cert-manager component. More info: + https://cert-manager.io/ + properties: + chart: + description: Optional custom chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + values: + description: Optional additional values that should be passed + to the cert-manager Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of the cert-manager to install. + type: string + required: + - version + type: object + coreRef: + default: + name: default + description: Reference to a core configuration + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + crossplane: + description: Configuration for the Crossplane installation of this + ControlPlane. + properties: + chart: + description: Optional custom Helm chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + providers: + description: List of Crossplane providers to be installed. + items: + description: |- + CrossplaneProviderConfig represents configuration for Crossplane providers in a ControlPlane. + Primarily based on the Crossplane open source API. + properties: + controllerConfigRef: + description: |- + ControllerConfigRef references a ControllerConfig resource that will be + used to configure the packaged controller Deployment. + Deprecated: Use RuntimeConfigReference instead. + properties: + name: + description: Name of the ControllerConfig. + type: string + required: + - name + type: object + name: + description: |- + Name of the provider. + Using a well-known name will automatically configure the "package" field. + type: string + package: + description: |- + Provider package to be installed. + If "name" is set to a well-known value, this field will be configured automatically. + type: string + packagePullPolicy: + default: IfNotPresent + description: |- + Pull policy for the provider. + One of Always, Never, IfNotPresent. + enum: + - Always + - Never + - IfNotPresent + type: string + packagePullSecrets: + description: PackagePullSecrets are named secrets in the + same namespace that can be used to fetch packages from + private registries. + items: + description: |- + LocalObjectReference contains enough information to let you locate the + referenced object inside the same namespace. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: array + runtimeConfigRef: + default: + name: default + description: |- + RuntimeConfigRef references a RuntimeConfig resource that will be used + to configure the package runtime. + properties: + apiVersion: + default: pkg.crossplane.io/v1beta1 + description: API version of the referent. + type: string + kind: + default: DeploymentRuntimeConfig + description: Kind of the referent. + type: string + name: + description: Name of the RuntimeConfig. + type: string + required: + - name + type: object + version: + description: Version of the provider to install. + type: string + required: + - name + - version + type: object + type: array + values: + description: Optional additional values that should be passed + to the Crossplane Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of Crossplane to install. + type: string + required: + - version + type: object + externalSecretsOperator: + description: |- + Configuration for the External Secrets Operator. More info: + https://external-secrets.io + properties: + chart: + description: Optional custom chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + values: + description: Optional additional values that should be passed + to the External Secrets Operator Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of External Secrets Operator to install. + type: string + required: + - version + type: object + flux: + description: |- + Configuration for Flux. More info: + https://fluxcd.io/ + properties: + chart: + description: Optional custom chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + values: + description: Optional additional values that should be passed + to the Flux Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of Flux to install. + type: string + required: + - version + type: object + kyverno: + description: |- + Configuration for Kyverno. More info: + https://kyverno.io/ + properties: + chart: + description: Optional custom chart configuration. + properties: + name: + description: Name of the Helm chart + type: string + repository: + description: Repository is the URL to a Helm repository + type: string + version: + description: Version of the Helm chart, latest version if + not set + type: string + type: object + values: + description: Optional additional values that should be passed + to the Kyverno Helm chart. + x-kubernetes-preserve-unknown-fields: true + version: + description: The Version of Kyverno to install. + type: string + required: + - version + type: object + pullSecrets: + description: Pull secrets which will be used when pulling charts, + providers, etc. + items: + description: |- + LocalObjectReference contains enough information to let you locate the + referenced object inside the same namespace. + properties: + name: + default: "" + description: |- + Name of the referent. + This field is effectively required, but due to backwards compatibility is + allowed to be empty. Instances of this type with an empty value here are + almost certainly wrong. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + type: string + type: object + x-kubernetes-map-type: atomic + type: array + target: + description: Configuration of the ControlPlane target (local or remote + cluster) + properties: + fluxServiceAccount: + description: FluxServiceAccount is a reference to a service account + that should be used by Flux. + properties: + name: + description: Name is the name of the service account. + minLength: 1 + type: string + namespace: + description: Namespace is the namespace of the service account. + minLength: 1 + type: string + overrides: + description: Overrides specifies fields that should be overwritten + when a kubeconfig is generated from this ServiceAccountReference. + properties: + host: + description: Host must be a host string, a host:port pair, + or a URL to the base of the apiserver. + type: string + type: object + required: + - name + - namespace + type: object + kubeconfig: + description: Kubeconfig is an inline kubeconfig. + x-kubernetes-preserve-unknown-fields: true + kubeconfigFile: + description: KubeconfigFile is a path to a file containing a kubeconfig. + type: string + kubeconfigRef: + description: KubeconfigRef is a reference to a Kubernetes secret + that contains a kubeconfig. + properties: + key: + default: kubeconfig + description: The key of the secret to select from. Must be + a valid secret key. + type: string + name: + description: name is unique within a namespace to reference + a secret resource. + type: string + namespace: + description: namespace defines the space within which the + secret name must be unique. + type: string + required: + - key + type: object + x-kubernetes-map-type: atomic + serviceAccount: + description: ServiceAccount references a local service account. + properties: + caData: + description: |- + CAData holds (Base64-)PEM-encoded bytes. + CAData takes precedence over CAFile. + This value is optional. If not provided, the CAData of the in-cluster config will be used. + Providing an empty string means that the operating system's defaults root certificates will be used. + type: string + caFile: + description: |- + CAFile points to a file containing the root certificates for the API server. + This value is optional. If not provided, the value of CAData will be used. + type: string + host: + description: |- + Host must be a host string, a host:port pair, or a URL to the base of the apiserver. + This value is optional. If not provided, the local API server will be used. + type: string + name: + description: |- + Name is the name of the service account. + This value is optional. If not provided, the pod's service account will be used. + type: string + namespace: + description: |- + Namespace is the name of the service account. + This value is optional. If not provided, the pod's service account will be used. + type: string + tokenFile: + description: |- + TokenFile points to a file containing a bearer token (e.g. projected service account token (PSAT) with custom audience) to be used for authentication against the API server. + If provided, all other authentication methods (Basic, client-side TLS, etc.) will be disabled. + type: string + type: object + required: + - fluxServiceAccount + type: object + telemetry: + description: Configuration for the telemetry. + properties: + enabled: + description: Enables or disables telemetry. + type: boolean + type: object + required: + - target + type: object + status: + description: ControlPlaneStatus defines the observed state of ControlPlane + properties: + componentsEnabled: + description: Number of enabled components. + type: integer + componentsHealthy: + description: Number of healthy components. + type: integer + conditions: + description: Current service state of the ControlPlane. + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + namespace: + description: Namespace that contains resources related to the ControlPlane. + type: string + required: + - componentsEnabled + - componentsHealthy + - conditions + - namespace + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml new file mode 100644 index 0000000..467d2db --- /dev/null +++ b/api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml @@ -0,0 +1,108 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.3 + name: crossplanepackagerestrictions.core.orchestrate.cloud.sap +spec: + group: core.orchestrate.cloud.sap + names: + kind: CrossplanePackageRestriction + listKind: CrossplanePackageRestrictionList + plural: crossplanepackagerestrictions + singular: crossplanepackagerestriction + scope: Cluster + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: CrossplanePackageRestriction is the Schema for the crossplanepackagerestrictions + 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: CrossplanePackageRestrictionSpec defines the desired state + of CrossplanePackageRestriction + properties: + configurations: + description: |- + PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. + If both Registries and Packages are empty, no packages of this type will be allowed. + properties: + packages: + items: + type: string + type: array + registries: + items: + type: string + type: array + required: + - packages + - registries + type: object + functions: + description: |- + PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. + If both Registries and Packages are empty, no packages of this type will be allowed. + properties: + packages: + items: + type: string + type: array + registries: + items: + type: string + type: array + required: + - packages + - registries + type: object + providers: + description: |- + PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. + If both Registries and Packages are empty, no packages of this type will be allowed. + properties: + packages: + items: + type: string + type: array + registries: + items: + type: string + type: array + required: + - packages + - registries + type: object + required: + - configurations + - functions + - providers + type: object + status: + description: CrossplanePackageRestrictionStatus defines the observed state + of CrossplanePackageRestriction + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml new file mode 100644 index 0000000..04893c9 --- /dev/null +++ b/api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml @@ -0,0 +1,155 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.3 + name: releasechannels.core.orchestrate.cloud.sap +spec: + group: core.orchestrate.cloud.sap + names: + kind: ReleaseChannel + listKind: ReleaseChannelList + plural: releasechannels + shortNames: + - rc + singular: releasechannel + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: ReleaseChannel is the Schema for the ReleaseChannel 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: ReleaseChannelSpec defines the desired state of ReleaseChannel + properties: + interval: + default: 15m + description: Interval specifies the timespan when the registry is + checked again + type: string + ocmRegistrySecretKey: + description: |- + Here you must specify the key which contains the tar based ocm registry in the referenced secret. + Required, if ocmRegistrySecretRef is specified. + type: string + ocmRegistrySecretRef: + description: |- + This parameter can be used for a tar based ocm registry in a secret. + The secret referenced here must contain a key where a tar based ocm registry is stored in. + properties: + name: + description: name is unique within a namespace to reference a + secret resource. + type: string + namespace: + description: namespace defines the space within which the secret + name must be unique. + type: string + type: object + x-kubernetes-map-type: atomic + ocmRegistryUrl: + description: Specify a ocm registry url where the releasechannel components + are uploaded + minLength: 1 + type: string + prefixFilter: + description: |- + When specified only components starting with this prefix will be fetched. + Also this prefix will be cut from the componentNames in the status field. + type: string + pullSecretRef: + description: |- + This should be a reference to a secret, which has the `username` and `password` keys. + If specified, will be used when accessing the ocmRegistry specified in ocmRegistryUrl. + properties: + name: + description: name is unique within a namespace to reference a + secret resource. + type: string + namespace: + description: namespace defines the space within which the secret + name must be unique. + type: string + type: object + x-kubernetes-map-type: atomic + required: + - interval + type: object + status: + description: ReleaseChannelStatus defines the observed state of ReleaseChannel + properties: + components: + description: The components which are inside the ocm registry + items: + properties: + name: + description: Name of the component which can be used to install + it via the controlplane CR. + type: string + versions: + description: All available versions for that component. + items: + properties: + dockerRef: + description: if it's a Docker Image, this specifies the + Docker reference for pulling the image + type: string + helmChart: + description: if it's a helm chart, this specifies the + chart name + type: string + helmRepo: + description: if it's a helm chart, this specifies the + helm repo + type: string + version: + description: The version number for that ComponentVersion + type: string + required: + - version + type: object + type: array + required: + - name + - versions + type: object + type: array + type: object + type: object + x-kubernetes-validations: + - message: You can't specify 'ocmRegistryUrl' and 'ocmRegistrySecretRef' at + the same time, either use a remote ocm registry or a secret + rule: (!(has(self.spec.ocmRegistryUrl) && has(self.spec.ocmRegistrySecretRef))) + - message: You need to specify an 'ocmRegistrySecretKey' if you want to use + the 'ocmRegistrySecretRef'. + rule: (!(has(self.spec.ocmRegistrySecretRef) && !has(self.spec.ocmRegistrySecretKey))) + - message: If you specify a 'pullSecretRef' you must specify an 'ocmRegistryUrl' + otherwise the 'pullSecretRef' will not be used. + rule: (!(has(self.spec.pullSecretRef) && !has(self.spec.ocmRegistryUrl))) + served: true + storage: true + subresources: + status: {} diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..a3c6441 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ + +# Documentation Index + From 1394974432892f747001dead430c019819c822a3 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:06:21 +0200 Subject: [PATCH 05/22] fix .golangci.yaml --- .golangci.yaml | 8 ++++++++ .golangci.yml | 39 --------------------------------------- 2 files changed, 8 insertions(+), 39 deletions(-) create mode 100644 .golangci.yaml delete mode 100644 .golangci.yml diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..083aa42 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,8 @@ +run: + concurrency: 4 + timeout: 10m + +issues: + exclude-files: + - "zz_generated.*\\.go$" + - "tmp/.*" diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index fec73d8..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,39 +0,0 @@ -run: - timeout: 5m - allow-parallel-runners: true - -issues: - # don't skip warning about doc comments - # don't exclude the default set of lint - exclude-use-default: false - # restore some of the defaults - # (fill in the rest as needed) - exclude-rules: - - path: "api/*" - linters: - - lll - - path: "internal/*" - linters: - - dupl - - lll -linters: - enable: - - dupl - - errcheck - - copyloopvar - - goconst - - gocyclo - - gofmt - - goimports - - gosimple - - govet - - ineffassign - - lll - - misspell - - nakedret - - prealloc - - staticcheck - - typecheck - - unconvert - - unused - disable: [] From 72fb71422531b51e3a60667cff5f6e2e79892570 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:06:46 +0200 Subject: [PATCH 06/22] fix test --- pkg/utils/envtest/envtest.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/utils/envtest/envtest.go b/pkg/utils/envtest/envtest.go index 5665f0c..6d4206a 100644 --- a/pkg/utils/envtest/envtest.go +++ b/pkg/utils/envtest/envtest.go @@ -22,6 +22,8 @@ var ( errK8sVersionNotFound = errors.New("value of ENVTEST_K8S_VERSION not found") k8sVersionRegexp = regexp.MustCompile(`ENVTEST_K8S_VERSION\s*=\s*(.+)\n`) + + k8sVersionEnvName = "ENVTEST_K8S_VERSION" ) // Install uses make to install the envtest dependencies and sets the @@ -109,6 +111,12 @@ func findMakefile(root string) (string, error) { } func readK8sVersion(makefilePath string) (string, error) { + // try to read environment variables first. + version := os.Getenv("ENVTEST_K8S_VERSION") + if len(version) != 0 { + return version, nil + } + // fall back to reading the makefile! bytes, err := os.ReadFile(makefilePath) if err != nil { return "", errors.Join(errFailedToReadMakefile, err) From 25a6be03b472f13574040ca9245a2a5ab540bcde Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:07:13 +0200 Subject: [PATCH 07/22] fmtd files --- api/v1beta1/zz_generated.deepcopy.go | 18 +----------------- internal/controller/controlplane_controller.go | 14 ++++++++------ .../controller/controlplane_controller_test.go | 13 +++++++------ internal/controller/kubeconfigs.go | 5 +++-- .../controller/releasechannel_controller.go | 5 +++-- .../releasechannel_controller_test.go | 5 +++-- internal/controller/remote_config_builder.go | 3 ++- .../controller/remote_config_builder_test.go | 3 ++- internal/controller/secret_controller.go | 5 +++-- internal/controller/secret_controller_test.go | 3 ++- internal/ocm/ocm.go | 3 ++- internal/ocm/ocm_test.go | 6 ++++-- internal/schemes/schemes.go | 3 ++- ...rossplane_provider_admission_policy_test.go | 3 ++- test/e2e/cp_crossplane_providers_test.go | 5 +++-- test/e2e/cp_kyverno_test.go | 3 ++- test/e2e/utils_test.go | 5 +++-- 17 files changed, 52 insertions(+), 50 deletions(-) diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 72dcc78..5962198 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -1,28 +1,12 @@ //go:build !ignore_autogenerated -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - // Code generated by controller-gen. DO NOT EDIT. package v1beta1 import ( corev1 "k8s.io/api/core/v1" - "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/internal/controller/controlplane_controller.go b/internal/controller/controlplane_controller.go index 659572c..b819824 100644 --- a/internal/controller/controlplane_controller.go +++ b/internal/controller/controlplane_controller.go @@ -23,9 +23,10 @@ import ( "time" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/internal/ocm" "k8s.io/apimachinery/pkg/types" + "github.com/openmcp-project/control-plane-operator/internal/ocm" + "github.com/openmcp-project/control-plane-operator/cmd/options" "github.com/openmcp-project/control-plane-operator/internal/schemes" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components/clusterroles" @@ -39,11 +40,6 @@ import ( "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/kubeconfiggen" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/targetrbac" - "github.com/openmcp-project/control-plane-operator/pkg/utils" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" condApi "k8s.io/apimachinery/pkg/api/meta" @@ -54,6 +50,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/kubeconfiggen" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/targetrbac" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) const ( diff --git a/internal/controller/controlplane_controller_test.go b/internal/controller/controlplane_controller_test.go index fc85114..8d2f874 100644 --- a/internal/controller/controlplane_controller_test.go +++ b/internal/controller/controlplane_controller_test.go @@ -12,12 +12,6 @@ import ( "github.com/openmcp-project/controller-utils/pkg/clientconfig" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/cmd/options" - "github.com/openmcp-project/control-plane-operator/internal/schemes" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/kubeconfiggen" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" - envtestutil "github.com/openmcp-project/control-plane-operator/pkg/utils/envtest" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -33,6 +27,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/envtest" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/cmd/options" + "github.com/openmcp-project/control-plane-operator/internal/schemes" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/kubeconfiggen" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" + envtestutil "github.com/openmcp-project/control-plane-operator/pkg/utils/envtest" ) func TestMain(m *testing.M) { diff --git a/internal/controller/kubeconfigs.go b/internal/controller/kubeconfigs.go index fb4e151..ffe7838 100644 --- a/internal/controller/kubeconfigs.go +++ b/internal/controller/kubeconfigs.go @@ -5,14 +5,15 @@ import ( "errors" "time" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/utils" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) const ( diff --git a/internal/controller/releasechannel_controller.go b/internal/controller/releasechannel_controller.go index 620b203..163d92e 100644 --- a/internal/controller/releasechannel_controller.go +++ b/internal/controller/releasechannel_controller.go @@ -4,8 +4,6 @@ import ( "context" "fmt" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/internal/ocm" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ocmlib "ocm.software/ocm/api/ocm" @@ -15,6 +13,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/predicate" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/internal/ocm" ) type ReleaseChannelReconciler struct { diff --git a/internal/controller/releasechannel_controller_test.go b/internal/controller/releasechannel_controller_test.go index 8cd989b..717169a 100644 --- a/internal/controller/releasechannel_controller_test.go +++ b/internal/controller/releasechannel_controller_test.go @@ -7,14 +7,15 @@ import ( "testing" "time" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/internal/schemes" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/internal/schemes" ) const localOCMRegistryTestDataPath = "../../test/testdata/ocm_registry.tgz" diff --git a/internal/controller/remote_config_builder.go b/internal/controller/remote_config_builder.go index 37cdf91..45236c2 100644 --- a/internal/controller/remote_config_builder.go +++ b/internal/controller/remote_config_builder.go @@ -1,9 +1,10 @@ package controller import ( - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/controller-utils/pkg/clientconfig" "k8s.io/client-go/rest" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) type RemoteConfigBuilder func(target v1beta1.Target) (*rest.Config, clientconfig.ReloadFunc, error) diff --git a/internal/controller/remote_config_builder_test.go b/internal/controller/remote_config_builder_test.go index c72e0f0..56e6859 100644 --- a/internal/controller/remote_config_builder_test.go +++ b/internal/controller/remote_config_builder_test.go @@ -3,11 +3,12 @@ package controller import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/controller-utils/pkg/api" "github.com/openmcp-project/controller-utils/pkg/clientconfig" "github.com/stretchr/testify/assert" "k8s.io/client-go/rest" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func TestNewRemoteConfigBuilder(t *testing.T) { diff --git a/internal/controller/secret_controller.go b/internal/controller/secret_controller.go index 9f79744..4cd2caa 100644 --- a/internal/controller/secret_controller.go +++ b/internal/controller/secret_controller.go @@ -7,8 +7,6 @@ import ( "github.com/openmcp-project/control-plane-operator/pkg/constants" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/utils" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -18,6 +16,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) const ( diff --git a/internal/controller/secret_controller_test.go b/internal/controller/secret_controller_test.go index b70bdc9..6babcd0 100644 --- a/internal/controller/secret_controller_test.go +++ b/internal/controller/secret_controller_test.go @@ -5,7 +5,6 @@ import ( "errors" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/constants" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -16,6 +15,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" "sigs.k8s.io/controller-runtime/pkg/event" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" ) var ( diff --git a/internal/ocm/ocm.go b/internal/ocm/ocm.go index 1d21a5d..e9c23fd 100644 --- a/internal/ocm/ocm.go +++ b/internal/ocm/ocm.go @@ -7,7 +7,6 @@ import ( "os" "strings" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" "ocm.software/ocm/api/ocm" "ocm.software/ocm/api/ocm/extensions/accessmethods/helm" @@ -18,6 +17,8 @@ import ( "ocm.software/ocm/api/tech/oci/identity" "ocm.software/ocm/api/utils/accessobj" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) // Create an ocm.Repository entity out of an url specified in the ocmRegistry parameter. diff --git a/internal/ocm/ocm_test.go b/internal/ocm/ocm_test.go index ae193d5..4145cad 100644 --- a/internal/ocm/ocm_test.go +++ b/internal/ocm/ocm_test.go @@ -5,16 +5,18 @@ import ( "errors" "testing" - "github.com/openmcp-project/control-plane-operator/internal/schemes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/openmcp-project/control-plane-operator/internal/schemes" + testutils "github.com/openmcp-project/control-plane-operator/test/utils" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/stretchr/testify/assert" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func TestGetOCMComponent(t *testing.T) { diff --git a/internal/schemes/schemes.go b/internal/schemes/schemes.go index 7609d65..8e7a6a5 100644 --- a/internal/schemes/schemes.go +++ b/internal/schemes/schemes.go @@ -1,11 +1,12 @@ package schemes import ( - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" crossplanev1beta1 "github.com/crossplane/crossplane/apis/pkg/v1beta1" helmv2 "github.com/fluxcd/helm-controller/api/v2" diff --git a/test/e2e/cp_crossplane_provider_admission_policy_test.go b/test/e2e/cp_crossplane_provider_admission_policy_test.go index caefed1..58c2e61 100644 --- a/test/e2e/cp_crossplane_provider_admission_policy_test.go +++ b/test/e2e/cp_crossplane_provider_admission_policy_test.go @@ -7,9 +7,10 @@ import ( "strings" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "k8s.io/apimachinery/pkg/api/meta" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + xpres "github.com/crossplane-contrib/xp-testing/pkg/resources" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" diff --git a/test/e2e/cp_crossplane_providers_test.go b/test/e2e/cp_crossplane_providers_test.go index c2d200f..199cabe 100644 --- a/test/e2e/cp_crossplane_providers_test.go +++ b/test/e2e/cp_crossplane_providers_test.go @@ -9,8 +9,6 @@ import ( xpres "github.com/crossplane-contrib/xp-testing/pkg/resources" xcommonv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/e2e-framework/klient/k8s" @@ -19,6 +17,9 @@ import ( "sigs.k8s.io/e2e-framework/klient/wait/conditions" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" ) const ( diff --git a/test/e2e/cp_kyverno_test.go b/test/e2e/cp_kyverno_test.go index c535db5..8810928 100644 --- a/test/e2e/cp_kyverno_test.go +++ b/test/e2e/cp_kyverno_test.go @@ -7,7 +7,6 @@ import ( "testing" xpres "github.com/crossplane-contrib/xp-testing/pkg/resources" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -16,6 +15,8 @@ import ( "sigs.k8s.io/e2e-framework/klient/wait/conditions" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) var ( diff --git a/test/e2e/utils_test.go b/test/e2e/utils_test.go index 60467ec..8515b9b 100644 --- a/test/e2e/utils_test.go +++ b/test/e2e/utils_test.go @@ -9,8 +9,6 @@ import ( "time" xpres "github.com/crossplane-contrib/xp-testing/pkg/resources" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" @@ -20,6 +18,9 @@ import ( "sigs.k8s.io/e2e-framework/klient/wait" "sigs.k8s.io/e2e-framework/klient/wait/conditions" "sigs.k8s.io/e2e-framework/pkg/envconf" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) // isControlPlaneReady validates that a v1beta1.ControlPlane was created and is ready From 6069270fc9fa4f9775696aae06847ef081c8d5e2 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:08:18 +0200 Subject: [PATCH 08/22] .gitignore coverage reports --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7ee06d4..4d94a43 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ secret.env test/e2e/testdata/serect.yaml integration-tests.xml + +cover.root.html +api/cover.root.html From 66ad599523be35e7c0fdfbd76fe1f14980ae20ab Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:15:02 +0200 Subject: [PATCH 09/22] update actions --- .github/workflows/ci.yaml | 22 +++++++++++++------- .github/workflows/publish.yaml | 37 +++++++++++++++------------------- .github/workflows/release.yaml | 32 ++++++++++++++++++++++++----- 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dd5a886..e1e8094 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,19 +15,27 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: go.mod - - name: make tidy + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x + + - name: make generate run: | - make tidy + task generate git diff --exit-code - - - name: make verify - run: make verify - - name: make test - run: make test \ No newline at end of file + - name: task validate + run: task validate + + - name: task test + run: task test \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 3c03222..ea2785c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -3,8 +3,7 @@ on: push: tags: - v* - workflow_dispatch: - + workflow_dispatch: permissions: packages: write @@ -23,11 +22,17 @@ jobs: ssh-key: ${{ secrets.PUSH_KEY }} fetch-tags: true fetch-depth: 0 + submodules: recursive + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x - name: Read and validate VERSION id: version run: | - VERSION=$(cat VERSION) + VERSION=$(task version) if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then echo "Invalid version format in VERSION file: $VERSION" exit 1 @@ -43,7 +48,7 @@ jobs: exit 0 - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Context for Buildx id: buildx-context @@ -59,7 +64,7 @@ jobs: - name: Set up Docker Buildx timeout-minutes: 5 - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: version: latest @@ -68,24 +73,14 @@ jobs: with: go-version-file: go.mod - - name: Build the ${{ github.repository }} + - name: Build and Push Images run: | - make prepare-release - make build - - - name: Build Images - run: | - IMAGE_REGISTRY=ghcr.io/openmcp-project make image-build - - - name: setup OCM - uses: open-component-model/ocm-setup-action@main + task build:img:all - - name: Create OCM CTF + - name: Package and Push Helm Charts run: | - ocm add componentversions --create \ - --file ctf component-constructor.yaml \ - --settings settings.yaml -- VERSION=${{ env.version }} + task build:helm:all - - name: Push CTF + - name: Build and Push OCM Component run: | - ocm transfer ctf --overwrite ./ctf ${{ env.OCI_URL }} + task build:ocm:all \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fc0eab4..2a12603 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,11 +19,17 @@ jobs: ssh-key: ${{ secrets.PUSH_KEY }} fetch-tags: true fetch-depth: 0 + submodules: recursive + + - name: Install Task + uses: arduino/setup-task@v2 + with: + version: 3.x - name: Read and validate VERSION id: version run: | - VERSION=$(cat VERSION) + VERSION=$(task version) if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then echo "Invalid version format in VERSION file: $VERSION" exit 1 @@ -63,7 +69,7 @@ jobs: git tag -a "${{ env.version }}" -m "Release ${{ env.version }}" git push origin "${{ env.version }}" - + - name: Build Changelog id: github_release uses: mikepenz/release-changelog-builder-action@v5 @@ -97,7 +103,23 @@ jobs: } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + + - name: Create Git tag for api submodule + if: ${{ env.SKIP != 'true' }} + run: | + AUTHOR_NAME=$(git log -1 --pretty=format:'%an') + AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') + echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>" + + echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV + echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV + + git config user.name "$AUTHOR_NAME" + git config user.email "$AUTHOR_EMAIL" + + git tag -a "api/${{ env.version }}" -m "Release ${{ env.version }}" + git push origin "api/${{ env.version }}" + - name: Create GitHub release if: ${{ env.SKIP != 'true' }} uses: softprops/action-gh-release@v2 @@ -113,9 +135,9 @@ jobs: - name: Push dev VERSION if: ${{ env.SKIP != 'true' }} run: | - echo "${{ env.version }}-dev" > VERSION + task release:set-version -- "${{ env.version }}-dev" git config user.name "${{ env.AUTHOR_NAME }}" git config user.email "${{ env.AUTHOR_EMAIL }}" git add VERSION git commit -m "Update VERSION to ${{ env.version }}-dev" - git push origin main + git push origin main \ No newline at end of file From 99a336a83c4a3b3fc4dfa075d6ba6ba8a1fdf471 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 09:16:26 +0200 Subject: [PATCH 10/22] cleanup --- Taskfile.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 6b6f42b..56b904b 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -45,22 +45,6 @@ includes: GENERATE_DOCS_INDEX: "true" ENVTEST_REQUIRED: "true" ENVTEST_K8S_VERSION: "1.30.0" - - -# tasks: -# build:bin:val:test: -# desc: " Run all tests." -# env: -# ENVTEST_K8S_VERSION: "1.30.0" - -# run: once -# # requires: -# # vars: -# # - CODE_DIRS -# deps: -# - test-envtest-dep -# cmds: -# - 'PROJECT_ROOT="{{.ROOT_DIR2}}" NESTED_MODULES="{{.NESTED_MODULES}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' tasks: test: From 069cf20de9f2af6ed3e8a70878c3353885f3e53f Mon Sep 17 00:00:00 2001 From: moelsayed Date: Wed, 30 Apr 2025 10:16:18 +0200 Subject: [PATCH 11/22] fix task --- Taskfile.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Taskfile.yaml b/Taskfile.yaml index 56b904b..e8c95f2 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -74,6 +74,8 @@ tasks: - '[ "{{.ENVTEST_REQUIRED | default "false"}}" != "true" ]' cmds: - task: tools:envtest + vars: + ENVTEST_REQUIRED: "true" internal: true build-raw: From 930f73dd597ebbba84f003b43e19d7a0edd6e6f6 Mon Sep 17 00:00:00 2001 From: Mohamed Elsayed Date: Thu, 1 May 2025 22:58:13 +0200 Subject: [PATCH 12/22] Update .github/workflows/release.yaml Co-authored-by: Johannes Aubart --- .github/workflows/release.yaml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2a12603..979588d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -104,22 +104,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Git tag for api submodule - if: ${{ env.SKIP != 'true' }} - run: | - AUTHOR_NAME=$(git log -1 --pretty=format:'%an') - AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') - echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>" - - echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV - echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV - - git config user.name "$AUTHOR_NAME" - git config user.email "$AUTHOR_EMAIL" - - git tag -a "api/${{ env.version }}" -m "Release ${{ env.version }}" - git push origin "api/${{ env.version }}" - - name: Create GitHub release if: ${{ env.SKIP != 'true' }} uses: softprops/action-gh-release@v2 From 3fccc5ad0f6af20d55d2a13457167db9ff0190d9 Mon Sep 17 00:00:00 2001 From: Mohamed Elsayed Date: Thu, 1 May 2025 22:58:37 +0200 Subject: [PATCH 13/22] Update Taskfile.yaml Co-authored-by: Johannes Aubart --- Taskfile.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index e8c95f2..ad947a0 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -27,7 +27,6 @@ includes: CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' COMPONENTS: 'control-plane-operator' REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' - GENERATE_DOCS_INDEX: "true" ENVTEST_REQUIRED: "true" ENVTEST_K8S_VERSION: "1.30.0" common: # imported a second time so that overwriting task definitions can call the overwritten task with a 'c:' prefix From 9c54445082ba261b3c52b9344435250d6be16183 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 1 May 2025 23:13:24 +0200 Subject: [PATCH 14/22] update crd location --- config/crd/bases | 1 + ...e.orchestrate.cloud.sap_controlplanes.yaml | 539 ------------------ ...oud.sap_crossplanepackagerestrictions.yaml | 108 ---- ...orchestrate.cloud.sap_releasechannels.yaml | 155 ----- 4 files changed, 1 insertion(+), 802 deletions(-) create mode 120000 config/crd/bases delete mode 100644 config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml delete mode 100644 config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml delete mode 100644 config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml diff --git a/config/crd/bases b/config/crd/bases new file mode 120000 index 0000000..040426e --- /dev/null +++ b/config/crd/bases @@ -0,0 +1 @@ +../../api/crds/manifests \ No newline at end of file diff --git a/config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml b/config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml deleted file mode 100644 index 66e8d58..0000000 --- a/config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml +++ /dev/null @@ -1,539 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.4 - name: controlplanes.core.orchestrate.cloud.sap -spec: - group: core.orchestrate.cloud.sap - names: - kind: ControlPlane - listKind: ControlPlaneList - plural: controlplanes - shortNames: - - cp - singular: controlplane - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=='Ready')].status - name: Ready - type: string - - jsonPath: .status.componentsHealthy - name: Components Healthy - type: integer - - jsonPath: .status.componentsEnabled - name: Components Enabled - type: integer - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: ControlPlane is the Schema for the ControlPlane 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: ControlPlaneSpec defines the desired state of ControlPlane - properties: - btpServiceOperator: - description: |- - Configuration for the BTP Service Operator. More info: - https://github.com/SAP/sap-btp-service-operator - properties: - chart: - description: Optional custom chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - values: - description: Optional additional values that should be passed - to the BTP Service Operator Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of BTP Service Operator to install. - type: string - required: - - version - type: object - certManager: - description: |- - CertManager configures the cert-manager component. More info: - https://cert-manager.io/ - properties: - chart: - description: Optional custom chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - values: - description: Optional additional values that should be passed - to the cert-manager Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of the cert-manager to install. - type: string - required: - - version - type: object - coreRef: - default: - name: default - description: Reference to a core configuration - properties: - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - type: object - x-kubernetes-map-type: atomic - crossplane: - description: Configuration for the Crossplane installation of this - ControlPlane. - properties: - chart: - description: Optional custom Helm chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - providers: - description: List of Crossplane providers to be installed. - items: - description: |- - CrossplaneProviderConfig represents configuration for Crossplane providers in a ControlPlane. - Primarily based on the Crossplane open source API. - properties: - controllerConfigRef: - description: |- - ControllerConfigRef references a ControllerConfig resource that will be - used to configure the packaged controller Deployment. - Deprecated: Use RuntimeConfigReference instead. - properties: - name: - description: Name of the ControllerConfig. - type: string - required: - - name - type: object - name: - description: |- - Name of the provider. - Using a well-known name will automatically configure the "package" field. - type: string - package: - description: |- - Provider package to be installed. - If "name" is set to a well-known value, this field will be configured automatically. - type: string - packagePullPolicy: - default: IfNotPresent - description: |- - Pull policy for the provider. - One of Always, Never, IfNotPresent. - enum: - - Always - - Never - - IfNotPresent - type: string - packagePullSecrets: - description: PackagePullSecrets are named secrets in the - same namespace that can be used to fetch packages from - private registries. - items: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. - properties: - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - type: object - x-kubernetes-map-type: atomic - type: array - runtimeConfigRef: - default: - name: default - description: |- - RuntimeConfigRef references a RuntimeConfig resource that will be used - to configure the package runtime. - properties: - apiVersion: - default: pkg.crossplane.io/v1beta1 - description: API version of the referent. - type: string - kind: - default: DeploymentRuntimeConfig - description: Kind of the referent. - type: string - name: - description: Name of the RuntimeConfig. - type: string - required: - - name - type: object - version: - description: Version of the provider to install. - type: string - required: - - name - - version - type: object - type: array - values: - description: Optional additional values that should be passed - to the Crossplane Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of Crossplane to install. - type: string - required: - - version - type: object - externalSecretsOperator: - description: |- - Configuration for the External Secrets Operator. More info: - https://external-secrets.io - properties: - chart: - description: Optional custom chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - values: - description: Optional additional values that should be passed - to the External Secrets Operator Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of External Secrets Operator to install. - type: string - required: - - version - type: object - flux: - description: |- - Configuration for Flux. More info: - https://fluxcd.io/ - properties: - chart: - description: Optional custom chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - values: - description: Optional additional values that should be passed - to the Flux Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of Flux to install. - type: string - required: - - version - type: object - kyverno: - description: |- - Configuration for Kyverno. More info: - https://kyverno.io/ - properties: - chart: - description: Optional custom chart configuration. - properties: - name: - description: Name of the Helm chart - type: string - repository: - description: Repository is the URL to a Helm repository - type: string - version: - description: Version of the Helm chart, latest version if - not set - type: string - type: object - values: - description: Optional additional values that should be passed - to the Kyverno Helm chart. - x-kubernetes-preserve-unknown-fields: true - version: - description: The Version of Kyverno to install. - type: string - required: - - version - type: object - pullSecrets: - description: Pull secrets which will be used when pulling charts, - providers, etc. - items: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. - properties: - name: - default: "" - description: |- - Name of the referent. - This field is effectively required, but due to backwards compatibility is - allowed to be empty. Instances of this type with an empty value here are - almost certainly wrong. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - type: string - type: object - x-kubernetes-map-type: atomic - type: array - target: - description: Configuration of the ControlPlane target (local or remote - cluster) - properties: - fluxServiceAccount: - description: FluxServiceAccount is a reference to a service account - that should be used by Flux. - properties: - name: - description: Name is the name of the service account. - minLength: 1 - type: string - namespace: - description: Namespace is the namespace of the service account. - minLength: 1 - type: string - overrides: - description: Overrides specifies fields that should be overwritten - when a kubeconfig is generated from this ServiceAccountReference. - properties: - host: - description: Host must be a host string, a host:port pair, - or a URL to the base of the apiserver. - type: string - type: object - required: - - name - - namespace - type: object - kubeconfig: - description: Kubeconfig is an inline kubeconfig. - x-kubernetes-preserve-unknown-fields: true - kubeconfigFile: - description: KubeconfigFile is a path to a file containing a kubeconfig. - type: string - kubeconfigRef: - description: KubeconfigRef is a reference to a Kubernetes secret - that contains a kubeconfig. - properties: - key: - default: kubeconfig - description: The key of the secret to select from. Must be - a valid secret key. - type: string - name: - description: name is unique within a namespace to reference - a secret resource. - type: string - namespace: - description: namespace defines the space within which the - secret name must be unique. - type: string - required: - - key - type: object - x-kubernetes-map-type: atomic - serviceAccount: - description: ServiceAccount references a local service account. - properties: - caData: - description: |- - CAData holds (Base64-)PEM-encoded bytes. - CAData takes precedence over CAFile. - This value is optional. If not provided, the CAData of the in-cluster config will be used. - Providing an empty string means that the operating system's defaults root certificates will be used. - type: string - caFile: - description: |- - CAFile points to a file containing the root certificates for the API server. - This value is optional. If not provided, the value of CAData will be used. - type: string - host: - description: |- - Host must be a host string, a host:port pair, or a URL to the base of the apiserver. - This value is optional. If not provided, the local API server will be used. - type: string - name: - description: |- - Name is the name of the service account. - This value is optional. If not provided, the pod's service account will be used. - type: string - namespace: - description: |- - Namespace is the name of the service account. - This value is optional. If not provided, the pod's service account will be used. - type: string - tokenFile: - description: |- - TokenFile points to a file containing a bearer token (e.g. projected service account token (PSAT) with custom audience) to be used for authentication against the API server. - If provided, all other authentication methods (Basic, client-side TLS, etc.) will be disabled. - type: string - type: object - required: - - fluxServiceAccount - type: object - telemetry: - description: Configuration for the telemetry. - properties: - enabled: - description: Enables or disables telemetry. - type: boolean - type: object - required: - - target - type: object - status: - description: ControlPlaneStatus defines the observed state of ControlPlane - properties: - componentsEnabled: - description: Number of enabled components. - type: integer - componentsHealthy: - description: Number of healthy components. - type: integer - conditions: - description: Current service state of the ControlPlane. - items: - description: Condition contains details for one aspect of the current - state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - namespace: - description: Namespace that contains resources related to the ControlPlane. - type: string - required: - - componentsEnabled - - componentsHealthy - - conditions - - namespace - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml b/config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml deleted file mode 100644 index 516b788..0000000 --- a/config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml +++ /dev/null @@ -1,108 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.4 - name: crossplanepackagerestrictions.core.orchestrate.cloud.sap -spec: - group: core.orchestrate.cloud.sap - names: - kind: CrossplanePackageRestriction - listKind: CrossplanePackageRestrictionList - plural: crossplanepackagerestrictions - singular: crossplanepackagerestriction - scope: Cluster - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: CrossplanePackageRestriction is the Schema for the crossplanepackagerestrictions - 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: CrossplanePackageRestrictionSpec defines the desired state - of CrossplanePackageRestriction - properties: - configurations: - description: |- - PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. - If both Registries and Packages are empty, no packages of this type will be allowed. - properties: - packages: - items: - type: string - type: array - registries: - items: - type: string - type: array - required: - - packages - - registries - type: object - functions: - description: |- - PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. - If both Registries and Packages are empty, no packages of this type will be allowed. - properties: - packages: - items: - type: string - type: array - registries: - items: - type: string - type: array - required: - - packages - - registries - type: object - providers: - description: |- - PackageRestriction restricts a package type (e.g. providers) to certain registries or literal packages. - If both Registries and Packages are empty, no packages of this type will be allowed. - properties: - packages: - items: - type: string - type: array - registries: - items: - type: string - type: array - required: - - packages - - registries - type: object - required: - - configurations - - functions - - providers - type: object - status: - description: CrossplanePackageRestrictionStatus defines the observed state - of CrossplanePackageRestriction - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml b/config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml deleted file mode 100644 index 4aa668a..0000000 --- a/config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml +++ /dev/null @@ -1,155 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.4 - name: releasechannels.core.orchestrate.cloud.sap -spec: - group: core.orchestrate.cloud.sap - names: - kind: ReleaseChannel - listKind: ReleaseChannelList - plural: releasechannels - shortNames: - - rc - singular: releasechannel - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: ReleaseChannel is the Schema for the ReleaseChannel 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: ReleaseChannelSpec defines the desired state of ReleaseChannel - properties: - interval: - default: 15m - description: Interval specifies the timespan when the registry is - checked again - type: string - ocmRegistrySecretKey: - description: |- - Here you must specify the key which contains the tar based ocm registry in the referenced secret. - Required, if ocmRegistrySecretRef is specified. - type: string - ocmRegistrySecretRef: - description: |- - This parameter can be used for a tar based ocm registry in a secret. - The secret referenced here must contain a key where a tar based ocm registry is stored in. - properties: - name: - description: name is unique within a namespace to reference a - secret resource. - type: string - namespace: - description: namespace defines the space within which the secret - name must be unique. - type: string - type: object - x-kubernetes-map-type: atomic - ocmRegistryUrl: - description: Specify a ocm registry url where the releasechannel components - are uploaded - minLength: 1 - type: string - prefixFilter: - description: |- - When specified only components starting with this prefix will be fetched. - Also this prefix will be cut from the componentNames in the status field. - type: string - pullSecretRef: - description: |- - This should be a reference to a secret, which has the `username` and `password` keys. - If specified, will be used when accessing the ocmRegistry specified in ocmRegistryUrl. - properties: - name: - description: name is unique within a namespace to reference a - secret resource. - type: string - namespace: - description: namespace defines the space within which the secret - name must be unique. - type: string - type: object - x-kubernetes-map-type: atomic - required: - - interval - type: object - status: - description: ReleaseChannelStatus defines the observed state of ReleaseChannel - properties: - components: - description: The components which are inside the ocm registry - items: - properties: - name: - description: Name of the component which can be used to install - it via the controlplane CR. - type: string - versions: - description: All available versions for that component. - items: - properties: - dockerRef: - description: if it's a Docker Image, this specifies the - Docker reference for pulling the image - type: string - helmChart: - description: if it's a helm chart, this specifies the - chart name - type: string - helmRepo: - description: if it's a helm chart, this specifies the - helm repo - type: string - version: - description: The version number for that ComponentVersion - type: string - required: - - version - type: object - type: array - required: - - name - - versions - type: object - type: array - type: object - type: object - x-kubernetes-validations: - - message: You can't specify 'ocmRegistryUrl' and 'ocmRegistrySecretRef' at - the same time, either use a remote ocm registry or a secret - rule: (!(has(self.spec.ocmRegistryUrl) && has(self.spec.ocmRegistrySecretRef))) - - message: You need to specify an 'ocmRegistrySecretKey' if you want to use - the 'ocmRegistrySecretRef'. - rule: (!(has(self.spec.ocmRegistrySecretRef) && !has(self.spec.ocmRegistrySecretKey))) - - message: If you specify a 'pullSecretRef' you must specify an 'ocmRegistryUrl' - otherwise the 'pullSecretRef' will not be used. - rule: (!(has(self.spec.pullSecretRef) && !has(self.spec.ocmRegistryUrl))) - served: true - storage: true - subresources: - status: {} From d9a4fc6cf44e138440815507ea21a0125f9b1f38 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 1 May 2025 23:13:43 +0200 Subject: [PATCH 15/22] review comments --- Taskfile.yaml | 15 --------------- docs/README.md | 3 --- 2 files changed, 18 deletions(-) delete mode 100644 docs/README.md diff --git a/Taskfile.yaml b/Taskfile.yaml index ad947a0..2651eb3 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -29,21 +29,6 @@ includes: REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' ENVTEST_REQUIRED: "true" ENVTEST_K8S_VERSION: "1.30.0" - common: # imported a second time so that overwriting task definitions can call the overwritten task with a 'c:' prefix - taskfile: hack/common/Taskfile_controller.yaml - internal: true - aliases: - - c - vars: - NESTED_MODULES: api - API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' - MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' - CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' - COMPONENTS: 'control-plane-operator' - REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' - GENERATE_DOCS_INDEX: "true" - ENVTEST_REQUIRED: "true" - ENVTEST_K8S_VERSION: "1.30.0" tasks: test: diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index a3c6441..0000000 --- a/docs/README.md +++ /dev/null @@ -1,3 +0,0 @@ - -# Documentation Index - From 12401ca8b423f3920fe26cc068ec92cdb11f118c Mon Sep 17 00:00:00 2001 From: moelsayed Date: Mon, 5 May 2025 17:33:57 +0200 Subject: [PATCH 16/22] remove unused test code --- .../controlplane_controller_test.go | 5 - .../kubeconfiggen/generate_test.go | 5 - pkg/utils/envtest/envtest.go | 131 ------------------ pkg/utils/envtest/envtest_test.go | 11 -- 4 files changed, 152 deletions(-) delete mode 100644 pkg/utils/envtest/envtest.go diff --git a/internal/controller/controlplane_controller_test.go b/internal/controller/controlplane_controller_test.go index 8d2f874..fdc4d80 100644 --- a/internal/controller/controlplane_controller_test.go +++ b/internal/controller/controlplane_controller_test.go @@ -3,7 +3,6 @@ package controller import ( "context" "errors" - "log" "os" "testing" "time" @@ -33,13 +32,9 @@ import ( "github.com/openmcp-project/control-plane-operator/internal/schemes" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/kubeconfiggen" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" - envtestutil "github.com/openmcp-project/control-plane-operator/pkg/utils/envtest" ) func TestMain(m *testing.M) { - if err := envtestutil.Install(); err != nil { - log.Fatalln(err) - } os.Exit(m.Run()) } diff --git a/pkg/controlplane/kubeconfiggen/generate_test.go b/pkg/controlplane/kubeconfiggen/generate_test.go index 60def17..e4670a9 100644 --- a/pkg/controlplane/kubeconfiggen/generate_test.go +++ b/pkg/controlplane/kubeconfiggen/generate_test.go @@ -4,13 +4,11 @@ import ( "bytes" "context" "io" - "log" "os" "testing" "time" "github.com/openmcp-project/control-plane-operator/api/v1beta1" - envtestutil "github.com/openmcp-project/control-plane-operator/pkg/utils/envtest" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,9 +30,6 @@ var ( ) func TestMain(m *testing.M) { - if err := envtestutil.Install(); err != nil { - log.Fatalln(err) - } os.Exit(m.Run()) } diff --git a/pkg/utils/envtest/envtest.go b/pkg/utils/envtest/envtest.go deleted file mode 100644 index 6d4206a..0000000 --- a/pkg/utils/envtest/envtest.go +++ /dev/null @@ -1,131 +0,0 @@ -package envtest - -import ( - "bytes" - "errors" - "io/fs" - "os" - "os/exec" - "path/filepath" - "regexp" - "strings" -) - -var ( - errMakefileIsDir = errors.New("expected Makefile to be a file but it is a directory") - errFailedToGetWD = errors.New("failed to get working directory") - errFailedToFindMakefile = errors.New("failed to find Makefile") - errFailedToRunMake = errors.New("failed to run make") - errFailedToRunSetupEnvtest = errors.New("failed to run setup-envtest") - errMakefileNotFound = errors.New("reached fs root and did not find Makefile") - errFailedToReadMakefile = errors.New("failed to read Makefile") - errK8sVersionNotFound = errors.New("value of ENVTEST_K8S_VERSION not found") - - k8sVersionRegexp = regexp.MustCompile(`ENVTEST_K8S_VERSION\s*=\s*(.+)\n`) - - k8sVersionEnvName = "ENVTEST_K8S_VERSION" -) - -// Install uses make to install the envtest dependencies and sets the -// KUBEBUILDER_ASSETS environment variable. -func Install() error { - wd, err := os.Getwd() - if err != nil { - return errors.Join(errFailedToGetWD, err) - } - - makefilePath, err := findMakefile(wd) - if err != nil { - return errors.Join(errFailedToFindMakefile, err) - } - repoDir := filepath.Dir(makefilePath) - - if err := runMakeEnvtest(repoDir); err != nil { - return err - } - - assetsDir, err := runSetupEnvtest(repoDir, makefilePath) - if err != nil { - return err - } - - return os.Setenv("KUBEBUILDER_ASSETS", assetsDir) -} - -func runMakeEnvtest(repoDir string) error { - cmd := exec.Command("make", "envtest") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = repoDir - if err := cmd.Run(); err != nil { - return errors.Join(errFailedToRunMake, err) - } - return nil -} - -func runSetupEnvtest(repoDir, makefilePath string) (string, error) { - k8sVersion, err := readK8sVersion(makefilePath) - if err != nil { - return "", err - } - - binDir := filepath.Join(repoDir, "bin") - binary := filepath.Join(binDir, "setup-envtest") - cmd := exec.Command(binary, "use", k8sVersion, "--bin-dir", binDir, "-p", "path") - stdout := &bytes.Buffer{} - cmd.Stdout = stdout - cmd.Stderr = os.Stderr - cmd.Dir = repoDir - if err := cmd.Run(); err != nil { - return "", errors.Join(errFailedToRunSetupEnvtest, err) - } - return strings.TrimSpace(stdout.String()), nil -} - -func findMakefile(root string) (string, error) { - if !filepath.IsAbs(root) { - var err error - if root, err = filepath.Abs(root); err != nil { - return "", err - } - } - - if root == "/" { - return "", errMakefileNotFound - } - - makefilePath := filepath.Join(root, "Makefile") - finfo, err := os.Stat(makefilePath) - if errors.Is(err, fs.ErrNotExist) { - parent := filepath.Dir(root) - return findMakefile(parent) - } - if err != nil { - return "", err - } - if finfo.IsDir() { - return "", errMakefileIsDir - } - - return makefilePath, nil -} - -func readK8sVersion(makefilePath string) (string, error) { - // try to read environment variables first. - version := os.Getenv("ENVTEST_K8S_VERSION") - if len(version) != 0 { - return version, nil - } - // fall back to reading the makefile! - bytes, err := os.ReadFile(makefilePath) - if err != nil { - return "", errors.Join(errFailedToReadMakefile, err) - } - - match := k8sVersionRegexp.FindSubmatch(bytes) - if match == nil || len(match) != 2 { - return "", errK8sVersionNotFound - } - - return string(match[1]), nil -} diff --git a/pkg/utils/envtest/envtest_test.go b/pkg/utils/envtest/envtest_test.go index 59eeeb2..2e616a0 100644 --- a/pkg/utils/envtest/envtest_test.go +++ b/pkg/utils/envtest/envtest_test.go @@ -1,24 +1,13 @@ package envtest import ( - "path/filepath" "testing" "github.com/stretchr/testify/assert" k8senvtest "sigs.k8s.io/controller-runtime/pkg/envtest" ) -func Test_findMakefile(t *testing.T) { - actual, err := findMakefile(".") - assert.NoError(t, err) - - expected, err := filepath.Abs("../../../Makefile") - assert.NoError(t, err) - assert.Equal(t, expected, actual) -} - func Test_Install(t *testing.T) { - assert.NoError(t, Install()) testEnv := &k8senvtest.Environment{} _, err := testEnv.Start() assert.NoError(t, err) From b56617426804608578ffc0c2b70f084ab2f1370a Mon Sep 17 00:00:00 2001 From: moelsayed Date: Mon, 5 May 2025 17:34:36 +0200 Subject: [PATCH 17/22] add taskfile configuration to enable envtests --- Taskfile.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 2651eb3..de3413a 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -40,16 +40,18 @@ tasks: NESTED_MODULES: api API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' - CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' + CODE_DIRS: '{{.ROOT_DIR}}/... {{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' COMPONENTS: 'control-plane-operator' REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' GENERATE_DOCS_INDEX: "true" ENVTEST_REQUIRED: "true" ENVTEST_K8S_VERSION: "1.30.0" + KUBEBUILDER_ASSETS: + sh: "{{.ROOT_DIR}}/bin/setup-envtest use {{.ENVTEST_K8S_VERSION}} -p path" deps: - test-envtest-dep cmds: - - 'PROJECT_ROOT="{{.ROOT_DIR2}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' + - 'PROJECT_ROOT="{{.ROOT_DIR}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" KUBEBUILDER_ASSETS="{{.KUBEBUILDER_ASSETS}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' test-envtest-dep: desc: " Install the envtest dependency, if marked as required." From 490961d9bc27df3c51349c2d7a5554b8928f38b6 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Mon, 5 May 2025 18:48:56 +0200 Subject: [PATCH 18/22] fix taskfile execution order --- Taskfile.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index de3413a..5a513ea 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -46,12 +46,13 @@ tasks: GENERATE_DOCS_INDEX: "true" ENVTEST_REQUIRED: "true" ENVTEST_K8S_VERSION: "1.30.0" - KUBEBUILDER_ASSETS: - sh: "{{.ROOT_DIR}}/bin/setup-envtest use {{.ENVTEST_K8S_VERSION}} -p path" deps: - test-envtest-dep + # Very hacky way to run the test. We need to have KUBEBUILDER_ASSETS set. If we configure this as a dynamic task variable, + # it fails if the setup-envtest binary is not installed. Unfortunately setting test-envtest-dep as a dependency here doesn't + # work because variables are evaluated before dependencies. cmds: - - 'PROJECT_ROOT="{{.ROOT_DIR}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" KUBEBUILDER_ASSETS="{{.KUBEBUILDER_ASSETS}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' + - export KUBEBUILDER_ASSETS=$({{.ROOT_DIR}}/bin/setup-envtest use {{.ENVTEST_K8S_VERSION}} -p path); sh -c 'PROJECT_ROOT="{{.ROOT_DIR}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' test-envtest-dep: desc: " Install the envtest dependency, if marked as required." From 058519582ddfa73498721a783461a5bbf3bcbddc Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 8 May 2025 11:08:51 +0200 Subject: [PATCH 19/22] use fixed upstream tasks --- Taskfile.yaml | 59 ++------------------------------------------------- hack/common | 2 +- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 5a513ea..d285974 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -13,29 +13,7 @@ includes: shared: taskfile: hack/common/Taskfile_controller.yaml flatten: true - excludes: - - test - - test-envtest-dep - - build:bin:val:test - - build-raw - - build:bin:build-raw - # put task names in here which are overwritten in this file - vars: - NESTED_MODULES: api - API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' - MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' - CODE_DIRS: '{{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' - COMPONENTS: 'control-plane-operator' - REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' - ENVTEST_REQUIRED: "true" - ENVTEST_K8S_VERSION: "1.30.0" - -tasks: - test: - desc: " Run all tests." - run: once - aliases: - - build:bin:val:test + excludes: [] vars: NESTED_MODULES: api API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' @@ -43,38 +21,5 @@ tasks: CODE_DIRS: '{{.ROOT_DIR}}/... {{.ROOT_DIR}}/cmd/... {{.ROOT_DIR}}/internal/... {{.ROOT_DIR}}/test/... {{.ROOT_DIR}}/api/v1beta1/...' COMPONENTS: 'control-plane-operator' REPO_URL: 'https://github.com/openmcp-project/control-plane-operator' - GENERATE_DOCS_INDEX: "true" - ENVTEST_REQUIRED: "true" - ENVTEST_K8S_VERSION: "1.30.0" - deps: - - test-envtest-dep - # Very hacky way to run the test. We need to have KUBEBUILDER_ASSETS set. If we configure this as a dynamic task variable, - # it fails if the setup-envtest binary is not installed. Unfortunately setting test-envtest-dep as a dependency here doesn't - # work because variables are evaluated before dependencies. - cmds: - - export KUBEBUILDER_ASSETS=$({{.ROOT_DIR}}/bin/setup-envtest use {{.ENVTEST_K8S_VERSION}} -p path); sh -c 'PROJECT_ROOT="{{.ROOT_DIR}}" NESTED_MODULES="{{.NESTED_MODULES}}" ENVTEST_K8S_VERSION="{{.ENVTEST_K8S_VERSION}}" {{.TASKFILE_DIR2}}/run-tests.sh {{.CODE_DIRS}}' - - test-envtest-dep: - desc: " Install the envtest dependency, if marked as required." - run: once - status: - - '[ "{{.ENVTEST_REQUIRED | default "false"}}" != "true" ]' - cmds: - - task: tools:envtest - vars: ENVTEST_REQUIRED: "true" - internal: true - - build-raw: - desc: " Build the binary. Opposed to the regular build, this one just builds and skips code generation/validation tasks." - summary: | - This task builds the binary for the current operating system and architecture. - To overwrite this, set the 'OS' and 'ARCH' environment variables. - The binary is saved in the 'bin' folder, as $COMPONENT.$OS-$ARCH. - aliases: - - build:bin:build-raw - cmds: - - for: - var: COMPONENTS - as: COMPONENT - cmd: 'CGO_ENABLED=0 GOOS={{.OS}} GOARCH={{.ARCH}} go build -a -o {{.ROOT_DIR2}}/bin/{{.COMPONENT}}.{{.OS}}-{{.ARCH}} {{.ROOT_DIR2}}/cmd/main.go' \ No newline at end of file + ENVTEST_K8S_VERSION: "1.30.0" \ No newline at end of file diff --git a/hack/common b/hack/common index f9fe558..7a0d273 160000 --- a/hack/common +++ b/hack/common @@ -1 +1 @@ -Subproject commit f9fe558a9ef4029d8268945d3ea86c9130039fdd +Subproject commit 7a0d273d75f6532548ca6b65ded134dbafdf37a1 From 03f5ffeb7a9b4dcd081a0e1ce2df6f7a019ded4e Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 8 May 2025 11:33:42 +0200 Subject: [PATCH 20/22] linter/formater updates --- pkg/controlplane/components/btpso_component.go | 9 +++++---- pkg/controlplane/components/btpso_component_test.go | 3 ++- pkg/controlplane/components/cert_manager_component.go | 7 ++++--- .../components/cert_manager_component_test.go | 3 ++- pkg/controlplane/components/clusterrole_component.go | 9 +++++---- .../components/clusterrole_component_test.go | 3 ++- .../components/clusterroles/clusterroles_test.go | 3 ++- pkg/controlplane/components/common.go | 3 ++- pkg/controlplane/components/crds/crds.go | 5 +++-- pkg/controlplane/components/crds/crds_test.go | 3 ++- pkg/controlplane/components/crossplane_component.go | 9 +++++---- .../components/crossplane_component_test.go | 3 ++- .../crossplanedeploymentruntimeconfig_component.go | 11 ++++++----- ...rossplanedeploymentruntimeconfig_component_test.go | 3 ++- .../components/crossplaneprovider_component.go | 11 ++++++----- .../components/crossplaneprovider_component_test.go | 9 +++++---- pkg/controlplane/components/eso_component.go | 7 ++++--- pkg/controlplane/components/eso_component_test.go | 3 ++- pkg/controlplane/components/flux_component.go | 7 ++++--- pkg/controlplane/components/flux_component_test.go | 3 ++- .../components/generic_object_component.go | 5 +++-- .../components/generic_object_component_test.go | 3 ++- pkg/controlplane/components/kyverno_component.go | 7 ++++--- pkg/controlplane/components/kyverno_component_test.go | 3 ++- pkg/controlplane/components/policies/policies.go | 7 ++++--- pkg/controlplane/components/policies/policies_test.go | 3 ++- pkg/controlplane/components/secret_component.go | 9 +++++---- pkg/controlplane/components/secret_component_test.go | 5 +++-- pkg/controlplane/components/utils_test.go | 7 ++++--- pkg/controlplane/crossplane/policies.go | 3 ++- pkg/controlplane/crossplane/providers.go | 3 ++- pkg/controlplane/crossplane/providers_test.go | 3 ++- pkg/controlplane/kubeconfiggen/generate.go | 5 +++-- pkg/controlplane/kubeconfiggen/generate_test.go | 3 ++- pkg/controlplane/secretresolver/secretresolver.go | 3 ++- .../secretresolver/secretresolver_test.go | 3 ++- pkg/controlplane/secrets/pullsecrets.go | 3 ++- pkg/controlplane/secrets/pullsecrets_test.go | 3 ++- pkg/controlplane/targetrbac/rbac.go | 5 +++-- pkg/controlplane/targetrbac/rbac_test.go | 5 +++-- pkg/juggler/events_test.go | 3 ++- pkg/juggler/fluxcd/component_flux.go | 3 ++- pkg/juggler/fluxcd/flux_manifesto.go | 3 ++- pkg/juggler/fluxcd/flux_manifesto_test.go | 3 ++- pkg/juggler/fluxcd/flux_reconciler.go | 5 +++-- pkg/juggler/fluxcd/flux_reconciler_test.go | 3 ++- pkg/juggler/fluxcd/flux_sources.go | 3 ++- pkg/juggler/fluxcd/flux_sources_test.go | 3 ++- pkg/juggler/hooks/orphans.go | 3 ++- pkg/juggler/juggler_test.go | 3 ++- pkg/juggler/object/fake_test.go | 3 ++- pkg/juggler/object/object_component.go | 3 ++- pkg/juggler/object/object_reconciler.go | 5 +++-- pkg/juggler/object/object_reconciler_test.go | 3 ++- pkg/utils/meta_test.go | 3 ++- pkg/utils/rcontext/rcontext.go | 3 ++- pkg/utils/rcontext/rcontext_test.go | 5 +++-- 57 files changed, 158 insertions(+), 101 deletions(-) diff --git a/pkg/controlplane/components/btpso_component.go b/pkg/controlplane/components/btpso_component.go index 67af07e..b4d0221 100644 --- a/pkg/controlplane/components/btpso_component.go +++ b/pkg/controlplane/components/btpso_component.go @@ -7,16 +7,17 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + rbacv1 "k8s.io/api/rbac/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - rbacv1 "k8s.io/api/rbac/v1" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/btpso_component_test.go b/pkg/controlplane/components/btpso_component_test.go index c25f508..5fe4692 100644 --- a/pkg/controlplane/components/btpso_component_test.go +++ b/pkg/controlplane/components/btpso_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_BTPServiceOperator(t *testing.T) { diff --git a/pkg/controlplane/components/cert_manager_component.go b/pkg/controlplane/components/cert_manager_component.go index a967ba1..dfe55e1 100644 --- a/pkg/controlplane/components/cert_manager_component.go +++ b/pkg/controlplane/components/cert_manager_component.go @@ -7,15 +7,16 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/cert_manager_component_test.go b/pkg/controlplane/components/cert_manager_component_test.go index 4096a5d..3aa4aa8 100644 --- a/pkg/controlplane/components/cert_manager_component_test.go +++ b/pkg/controlplane/components/cert_manager_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_CertManager(t *testing.T) { diff --git a/pkg/controlplane/components/clusterrole_component.go b/pkg/controlplane/components/clusterrole_component.go index 0997cf4..c9deb99 100644 --- a/pkg/controlplane/components/clusterrole_component.go +++ b/pkg/controlplane/components/clusterrole_component.go @@ -5,16 +5,17 @@ import ( "fmt" "strings" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" - "github.com/openmcp-project/control-plane-operator/pkg/utils" "golang.org/x/text/cases" "golang.org/x/text/language" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) var _ object.ObjectComponent = &ClusterRole{} diff --git a/pkg/controlplane/components/clusterrole_component_test.go b/pkg/controlplane/components/clusterrole_component_test.go index 29a8d15..da0cabb 100644 --- a/pkg/controlplane/components/clusterrole_component_test.go +++ b/pkg/controlplane/components/clusterrole_component_test.go @@ -4,11 +4,12 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/controlplane/components/clusterroles/clusterroles_test.go b/pkg/controlplane/components/clusterroles/clusterroles_test.go index 4588001..0bf907f 100644 --- a/pkg/controlplane/components/clusterroles/clusterroles_test.go +++ b/pkg/controlplane/components/clusterroles/clusterroles_test.go @@ -4,8 +4,9 @@ import ( "testing" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func Test_RegisterAsComponents(t *testing.T) { diff --git a/pkg/controlplane/components/common.go b/pkg/controlplane/components/common.go index 9cac226..3dd3266 100644 --- a/pkg/controlplane/components/common.go +++ b/pkg/controlplane/components/common.go @@ -1,8 +1,9 @@ package components import ( - "github.com/openmcp-project/control-plane-operator/pkg/juggler" rbacv1 "k8s.io/api/rbac/v1" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) // TargetComponent is a component that should be installed on the Target (remote/workload) cluster. diff --git a/pkg/controlplane/components/crds/crds.go b/pkg/controlplane/components/crds/crds.go index cb589b0..0e796ac 100644 --- a/pkg/controlplane/components/crds/crds.go +++ b/pkg/controlplane/components/crds/crds.go @@ -6,12 +6,13 @@ import ( "embed" "path" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/yaml" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func RegisterAsComponents(jug *juggler.Juggler, crdFiles embed.FS, enabled bool, names ...string) error { diff --git a/pkg/controlplane/components/crds/crds_test.go b/pkg/controlplane/components/crds/crds_test.go index 59d2d90..2fdf322 100644 --- a/pkg/controlplane/components/crds/crds_test.go +++ b/pkg/controlplane/components/crds/crds_test.go @@ -5,8 +5,9 @@ import ( "testing" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/controlplane/components/crossplane_component.go b/pkg/controlplane/components/crossplane_component.go index cc6159b..5e09300 100644 --- a/pkg/controlplane/components/crossplane_component.go +++ b/pkg/controlplane/components/crossplane_component.go @@ -8,16 +8,17 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + rbacv1 "k8s.io/api/rbac/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - rbacv1 "k8s.io/api/rbac/v1" - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/crossplane_component_test.go b/pkg/controlplane/components/crossplane_component_test.go index ef34eff..65be1b6 100644 --- a/pkg/controlplane/components/crossplane_component_test.go +++ b/pkg/controlplane/components/crossplane_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_Crossplane(t *testing.T) { diff --git a/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component.go b/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component.go index 26e7705..4e2da8f 100644 --- a/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component.go +++ b/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component.go @@ -6,16 +6,17 @@ import ( "strings" crossplanev1beta1 "github.com/crossplane/crossplane/apis/pkg/v1beta1" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" - "github.com/openmcp-project/control-plane-operator/pkg/utils" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) var _ object.ObjectComponent = &CrossplaneDeploymentRuntimeConfig{} diff --git a/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component_test.go b/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component_test.go index aff0e02..cdf34b9 100644 --- a/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component_test.go +++ b/pkg/controlplane/components/crossplanedeploymentruntimeconfig_component_test.go @@ -7,11 +7,12 @@ import ( crossplanev1beta1 "github.com/crossplane/crossplane/apis/pkg/v1beta1" "github.com/google/go-cmp/cmp" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" appsv1 "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func TestCrossplaneDeploymentRuntimConfig(t *testing.T) { diff --git a/pkg/controlplane/components/crossplaneprovider_component.go b/pkg/controlplane/components/crossplaneprovider_component.go index 3867eec..bd3c20f 100644 --- a/pkg/controlplane/components/crossplaneprovider_component.go +++ b/pkg/controlplane/components/crossplaneprovider_component.go @@ -6,17 +6,18 @@ import ( "strings" crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" + "golang.org/x/text/cases" + "golang.org/x/text/language" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - "golang.org/x/text/cases" - "golang.org/x/text/language" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" ) var _ object.ObjectComponent = &CrossplaneProvider{} diff --git a/pkg/controlplane/components/crossplaneprovider_component_test.go b/pkg/controlplane/components/crossplaneprovider_component_test.go index 9ea96c2..a15352b 100644 --- a/pkg/controlplane/components/crossplaneprovider_component_test.go +++ b/pkg/controlplane/components/crossplaneprovider_component_test.go @@ -8,14 +8,15 @@ import ( commonv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/controlplane/components/eso_component.go b/pkg/controlplane/components/eso_component.go index c9c6086..5d9694e 100644 --- a/pkg/controlplane/components/eso_component.go +++ b/pkg/controlplane/components/eso_component.go @@ -6,14 +6,15 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + rbacv1 "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/eso_component_test.go b/pkg/controlplane/components/eso_component_test.go index e8c3f83..bbea706 100644 --- a/pkg/controlplane/components/eso_component_test.go +++ b/pkg/controlplane/components/eso_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_ExternalSecretsOperator(t *testing.T) { diff --git a/pkg/controlplane/components/flux_component.go b/pkg/controlplane/components/flux_component.go index 8b49f2b..9638540 100644 --- a/pkg/controlplane/components/flux_component.go +++ b/pkg/controlplane/components/flux_component.go @@ -6,14 +6,15 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + rbacv1 "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/flux_component_test.go b/pkg/controlplane/components/flux_component_test.go index c7987ac..067a378 100644 --- a/pkg/controlplane/components/flux_component_test.go +++ b/pkg/controlplane/components/flux_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_Flux(t *testing.T) { diff --git a/pkg/controlplane/components/generic_object_component.go b/pkg/controlplane/components/generic_object_component.go index 66998f6..9302e0d 100644 --- a/pkg/controlplane/components/generic_object_component.go +++ b/pkg/controlplane/components/generic_object_component.go @@ -5,12 +5,13 @@ import ( "reflect" "strings" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" "golang.org/x/text/cases" "golang.org/x/text/language" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" ) var _ object.ObjectComponent = &GenericObjectComponent{} diff --git a/pkg/controlplane/components/generic_object_component_test.go b/pkg/controlplane/components/generic_object_component_test.go index 5185ec7..903b153 100644 --- a/pkg/controlplane/components/generic_object_component_test.go +++ b/pkg/controlplane/components/generic_object_component_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func genComponent(enabled, healthy bool, reconcileErr error) *GenericObjectComponent { diff --git a/pkg/controlplane/components/kyverno_component.go b/pkg/controlplane/components/kyverno_component.go index 29701cf..52544df 100644 --- a/pkg/controlplane/components/kyverno_component.go +++ b/pkg/controlplane/components/kyverno_component.go @@ -6,14 +6,15 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" + rbacv1 "k8s.io/api/rbac/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/openmcp-project/control-plane-operator/pkg/juggler/fluxcd" "github.com/openmcp-project/control-plane-operator/pkg/juggler/hooks" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" ) const ( diff --git a/pkg/controlplane/components/kyverno_component_test.go b/pkg/controlplane/components/kyverno_component_test.go index 26f8c1f..90c82ca 100644 --- a/pkg/controlplane/components/kyverno_component_test.go +++ b/pkg/controlplane/components/kyverno_component_test.go @@ -4,8 +4,9 @@ package components import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func Test_Kyverno(t *testing.T) { diff --git a/pkg/controlplane/components/policies/policies.go b/pkg/controlplane/components/policies/policies.go index 093b97f..6d4781a 100644 --- a/pkg/controlplane/components/policies/policies.go +++ b/pkg/controlplane/components/policies/policies.go @@ -3,13 +3,14 @@ package policies import ( "context" + arv1 "k8s.io/api/admissionregistration/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/components" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/crossplane" "github.com/openmcp-project/control-plane-operator/pkg/juggler" - arv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" ) const ( diff --git a/pkg/controlplane/components/policies/policies_test.go b/pkg/controlplane/components/policies/policies_test.go index 491e396..227fc4a 100644 --- a/pkg/controlplane/components/policies/policies_test.go +++ b/pkg/controlplane/components/policies/policies_test.go @@ -4,8 +4,9 @@ import ( "testing" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func Test_RegisterAsComponents(t *testing.T) { diff --git a/pkg/controlplane/components/secret_component.go b/pkg/controlplane/components/secret_component.go index 400fa77..5236d11 100644 --- a/pkg/controlplane/components/secret_component.go +++ b/pkg/controlplane/components/secret_component.go @@ -5,16 +5,17 @@ import ( "errors" "strings" - "github.com/openmcp-project/control-plane-operator/pkg/constants" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" - "github.com/openmcp-project/control-plane-operator/pkg/utils" "golang.org/x/text/cases" "golang.org/x/text/language" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) var ( diff --git a/pkg/controlplane/components/secret_component_test.go b/pkg/controlplane/components/secret_component_test.go index 19c71b3..41e4c29 100644 --- a/pkg/controlplane/components/secret_component_test.go +++ b/pkg/controlplane/components/secret_component_test.go @@ -5,8 +5,6 @@ import ( "context" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/constants" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -14,6 +12,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/controlplane/components/utils_test.go b/pkg/controlplane/components/utils_test.go index e9b8942..98b89ff 100644 --- a/pkg/controlplane/components/utils_test.go +++ b/pkg/controlplane/components/utils_test.go @@ -7,6 +7,10 @@ import ( "testing" "github.com/fluxcd/pkg/apis/meta" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" "github.com/openmcp-project/control-plane-operator/pkg/juggler" @@ -14,9 +18,6 @@ import ( "github.com/openmcp-project/control-plane-operator/pkg/juggler/object" "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/openmcp-project/control-plane-operator/pkg/utils/rcontext" - "github.com/stretchr/testify/assert" - corev1 "k8s.io/api/core/v1" - "sigs.k8s.io/controller-runtime/pkg/client" ) var ( diff --git a/pkg/controlplane/crossplane/policies.go b/pkg/controlplane/crossplane/policies.go index 3167502..65ce946 100644 --- a/pkg/controlplane/crossplane/policies.go +++ b/pkg/controlplane/crossplane/policies.go @@ -9,13 +9,14 @@ import ( crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" crossplanev1beta "github.com/crossplane/crossplane/apis/pkg/v1beta1" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" arv1 "k8s.io/api/admissionregistration/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) type PackageType string diff --git a/pkg/controlplane/crossplane/providers.go b/pkg/controlplane/crossplane/providers.go index 15f4bc7..eac152a 100644 --- a/pkg/controlplane/crossplane/providers.go +++ b/pkg/controlplane/crossplane/providers.go @@ -5,9 +5,10 @@ import ( "strings" crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" + "k8s.io/apimachinery/pkg/types" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/utils" - "k8s.io/apimachinery/pkg/types" ) const ( diff --git a/pkg/controlplane/crossplane/providers_test.go b/pkg/controlplane/crossplane/providers_test.go index e420df2..70d806a 100644 --- a/pkg/controlplane/crossplane/providers_test.go +++ b/pkg/controlplane/crossplane/providers_test.go @@ -4,11 +4,12 @@ import ( "testing" crossplanev1 "github.com/crossplane/crossplane/apis/pkg/v1" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func TestReconcileProvider(t *testing.T) { diff --git a/pkg/controlplane/kubeconfiggen/generate.go b/pkg/controlplane/kubeconfiggen/generate.go index 2a72d28..1443134 100644 --- a/pkg/controlplane/kubeconfiggen/generate.go +++ b/pkg/controlplane/kubeconfiggen/generate.go @@ -7,8 +7,6 @@ import ( "os" "time" - corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/internal/schemes" authenticationv1 "k8s.io/api/authentication/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -16,6 +14,9 @@ import ( clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" + + corev1beta1 "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/internal/schemes" ) var ( diff --git a/pkg/controlplane/kubeconfiggen/generate_test.go b/pkg/controlplane/kubeconfiggen/generate_test.go index e4670a9..21b0030 100644 --- a/pkg/controlplane/kubeconfiggen/generate_test.go +++ b/pkg/controlplane/kubeconfiggen/generate_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -18,6 +17,8 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) var ( diff --git a/pkg/controlplane/secretresolver/secretresolver.go b/pkg/controlplane/secretresolver/secretresolver.go index c4f3780..781514d 100644 --- a/pkg/controlplane/secretresolver/secretresolver.go +++ b/pkg/controlplane/secretresolver/secretresolver.go @@ -4,9 +4,10 @@ import ( "context" "strings" - "github.com/openmcp-project/control-plane-operator/pkg/constants" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" ) type ResolveFunc func(urlType UrlSecretType) (*corev1.LocalObjectReference, error) diff --git a/pkg/controlplane/secretresolver/secretresolver_test.go b/pkg/controlplane/secretresolver/secretresolver_test.go index 74e1c6c..31a73f4 100644 --- a/pkg/controlplane/secretresolver/secretresolver_test.go +++ b/pkg/controlplane/secretresolver/secretresolver_test.go @@ -4,13 +4,14 @@ import ( "context" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/constants" "github.com/stretchr/testify/assert" assert2 "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" ) var ( diff --git a/pkg/controlplane/secrets/pullsecrets.go b/pkg/controlplane/secrets/pullsecrets.go index 4126f69..5b15749 100644 --- a/pkg/controlplane/secrets/pullsecrets.go +++ b/pkg/controlplane/secrets/pullsecrets.go @@ -3,10 +3,11 @@ package secrets import ( "context" - "github.com/openmcp-project/control-plane-operator/pkg/constants" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" ) // AvailablePullSecrets returns a list of secrets that are labeled with `constants.LabelCopyToCP` diff --git a/pkg/controlplane/secrets/pullsecrets_test.go b/pkg/controlplane/secrets/pullsecrets_test.go index 0fcbdd8..e88c4e3 100644 --- a/pkg/controlplane/secrets/pullsecrets_test.go +++ b/pkg/controlplane/secrets/pullsecrets_test.go @@ -5,7 +5,6 @@ import ( "errors" "testing" - "github.com/openmcp-project/control-plane-operator/pkg/constants" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -13,6 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" + + "github.com/openmcp-project/control-plane-operator/pkg/constants" ) var ( diff --git a/pkg/controlplane/targetrbac/rbac.go b/pkg/controlplane/targetrbac/rbac.go index 0d9b289..5641392 100644 --- a/pkg/controlplane/targetrbac/rbac.go +++ b/pkg/controlplane/targetrbac/rbac.go @@ -5,14 +5,15 @@ import ( "errors" "fmt" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/utils" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) var ( diff --git a/pkg/controlplane/targetrbac/rbac_test.go b/pkg/controlplane/targetrbac/rbac_test.go index 1a568dd..bb02937 100644 --- a/pkg/controlplane/targetrbac/rbac_test.go +++ b/pkg/controlplane/targetrbac/rbac_test.go @@ -6,8 +6,6 @@ import ( "errors" "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/utils" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" @@ -16,6 +14,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) func TestApply(t *testing.T) { diff --git a/pkg/juggler/events_test.go b/pkg/juggler/events_test.go index a117f51..32635e4 100644 --- a/pkg/juggler/events_test.go +++ b/pkg/juggler/events_test.go @@ -4,10 +4,11 @@ import ( "testing" "time" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/tools/record" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func TestObjectEventRecorder_Event(t *testing.T) { diff --git a/pkg/juggler/fluxcd/component_flux.go b/pkg/juggler/fluxcd/component_flux.go index b83aaf8..c08cb4d 100644 --- a/pkg/juggler/fluxcd/component_flux.go +++ b/pkg/juggler/fluxcd/component_flux.go @@ -3,8 +3,9 @@ package fluxcd import ( "context" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) type FluxComponent interface { diff --git a/pkg/juggler/fluxcd/flux_manifesto.go b/pkg/juggler/fluxcd/flux_manifesto.go index 11d8bab..f831092 100644 --- a/pkg/juggler/fluxcd/flux_manifesto.go +++ b/pkg/juggler/fluxcd/flux_manifesto.go @@ -6,10 +6,11 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" fluxmeta "github.com/fluxcd/pkg/apis/meta" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/juggler/fluxcd/flux_manifesto_test.go b/pkg/juggler/fluxcd/flux_manifesto_test.go index acfe801..5c1980b 100644 --- a/pkg/juggler/fluxcd/flux_manifesto_test.go +++ b/pkg/juggler/fluxcd/flux_manifesto_test.go @@ -6,9 +6,10 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" fluxmeta "github.com/fluxcd/pkg/apis/meta" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func TestHelmReleaseManifesto_GetHealthiness(t *testing.T) { diff --git a/pkg/juggler/fluxcd/flux_reconciler.go b/pkg/juggler/fluxcd/flux_reconciler.go index 336b86f..f442d33 100644 --- a/pkg/juggler/fluxcd/flux_reconciler.go +++ b/pkg/juggler/fluxcd/flux_reconciler.go @@ -8,12 +8,13 @@ import ( "strings" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/utils" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) const ( diff --git a/pkg/juggler/fluxcd/flux_reconciler_test.go b/pkg/juggler/fluxcd/flux_reconciler_test.go index 939b25e..4d33b3d 100644 --- a/pkg/juggler/fluxcd/flux_reconciler_test.go +++ b/pkg/juggler/fluxcd/flux_reconciler_test.go @@ -10,12 +10,13 @@ import ( helmv2 "github.com/fluxcd/helm-controller/api/v2" sourcev1 "github.com/fluxcd/source-controller/api/v1" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var errBoom = errors.New("boom") diff --git a/pkg/juggler/fluxcd/flux_sources.go b/pkg/juggler/fluxcd/flux_sources.go index b06f5c6..41f42b3 100644 --- a/pkg/juggler/fluxcd/flux_sources.go +++ b/pkg/juggler/fluxcd/flux_sources.go @@ -6,10 +6,11 @@ import ( fluxmeta "github.com/fluxcd/pkg/apis/meta" sourcev1 "github.com/fluxcd/source-controller/api/v1" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var ( diff --git a/pkg/juggler/fluxcd/flux_sources_test.go b/pkg/juggler/fluxcd/flux_sources_test.go index 4874a33..9bd42bb 100644 --- a/pkg/juggler/fluxcd/flux_sources_test.go +++ b/pkg/juggler/fluxcd/flux_sources_test.go @@ -6,9 +6,10 @@ import ( fluxmeta "github.com/fluxcd/pkg/apis/meta" sourcev1 "github.com/fluxcd/source-controller/api/v1" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) func TestHelmRepositoryAdapter_GetHealthiness(t *testing.T) { diff --git a/pkg/juggler/hooks/orphans.go b/pkg/juggler/hooks/orphans.go index 779e325..d65b5cf 100644 --- a/pkg/juggler/hooks/orphans.go +++ b/pkg/juggler/hooks/orphans.go @@ -4,10 +4,11 @@ import ( "context" "fmt" - "github.com/openmcp-project/control-plane-operator/pkg/utils" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) // checkForResources checks if there are any resources of the given GroupVersionKind remaining in the cluster diff --git a/pkg/juggler/juggler_test.go b/pkg/juggler/juggler_test.go index 706958b..762ad6a 100644 --- a/pkg/juggler/juggler_test.go +++ b/pkg/juggler/juggler_test.go @@ -6,9 +6,10 @@ import ( "reflect" "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "k8s.io/client-go/tools/record" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/go-logr/logr" "github.com/go-logr/logr/testr" "github.com/stretchr/testify/assert" diff --git a/pkg/juggler/object/fake_test.go b/pkg/juggler/object/fake_test.go index 3c4e25a..92323e1 100644 --- a/pkg/juggler/object/fake_test.go +++ b/pkg/juggler/object/fake_test.go @@ -5,10 +5,11 @@ import ( "reflect" "strings" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var fakeFilterLabel = "fake.object.component/managed" diff --git a/pkg/juggler/object/object_component.go b/pkg/juggler/object/object_component.go index d1b9412..0eae9f9 100644 --- a/pkg/juggler/object/object_component.go +++ b/pkg/juggler/object/object_component.go @@ -3,9 +3,10 @@ package object import ( "context" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) // ObjectComponent is an interface for manageable components, specifically for plain client.Objects. diff --git a/pkg/juggler/object/object_reconciler.go b/pkg/juggler/object/object_reconciler.go index d142b5c..782da1c 100644 --- a/pkg/juggler/object/object_reconciler.go +++ b/pkg/juggler/object/object_reconciler.go @@ -6,12 +6,13 @@ import ( "reflect" "github.com/go-logr/logr" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" - "github.com/openmcp-project/control-plane-operator/pkg/utils" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" + "github.com/openmcp-project/control-plane-operator/pkg/utils" ) const ( diff --git a/pkg/juggler/object/object_reconciler_test.go b/pkg/juggler/object/object_reconciler_test.go index 0eac7fa..cd58e4a 100644 --- a/pkg/juggler/object/object_reconciler_test.go +++ b/pkg/juggler/object/object_reconciler_test.go @@ -16,11 +16,12 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" - "github.com/openmcp-project/control-plane-operator/pkg/juggler" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" + + "github.com/openmcp-project/control-plane-operator/pkg/juggler" ) var errBoom = errors.New("boom") diff --git a/pkg/utils/meta_test.go b/pkg/utils/meta_test.go index cfbffe8..c6f07f4 100644 --- a/pkg/utils/meta_test.go +++ b/pkg/utils/meta_test.go @@ -3,10 +3,11 @@ package utils import ( "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" "gotest.tools/v3/assert" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" ) func TestSetLabel(t *testing.T) { diff --git a/pkg/utils/rcontext/rcontext.go b/pkg/utils/rcontext/rcontext.go index 1792d4e..1352c79 100644 --- a/pkg/utils/rcontext/rcontext.go +++ b/pkg/utils/rcontext/rcontext.go @@ -4,9 +4,10 @@ import ( "context" "github.com/fluxcd/pkg/apis/meta" + corev1 "k8s.io/api/core/v1" + "github.com/openmcp-project/control-plane-operator/api/v1beta1" "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" - corev1 "k8s.io/api/core/v1" ) type tenantNamespaceKey struct{} diff --git a/pkg/utils/rcontext/rcontext_test.go b/pkg/utils/rcontext/rcontext_test.go index c186544..82ed945 100644 --- a/pkg/utils/rcontext/rcontext_test.go +++ b/pkg/utils/rcontext/rcontext_test.go @@ -4,11 +4,12 @@ import ( "reflect" "testing" - "github.com/openmcp-project/control-plane-operator/api/v1beta1" - "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" "github.com/stretchr/testify/assert" "golang.org/x/net/context" corev1 "k8s.io/api/core/v1" + + "github.com/openmcp-project/control-plane-operator/api/v1beta1" + "github.com/openmcp-project/control-plane-operator/pkg/controlplane/secretresolver" ) func TestTenantNamespace(t *testing.T) { From fa93c2412c9b68fca109dc94c0ee4c3373ec1119 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 8 May 2025 11:39:16 +0200 Subject: [PATCH 21/22] update golangci-lint config --- .golangci.yaml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 083aa42..e99b1eb 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,8 +1,24 @@ +version: "2" run: concurrency: 4 - timeout: 10m - -issues: - exclude-files: - - "zz_generated.*\\.go$" - - "tmp/.*" +linters: + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - zz_generated.*\.go$ + - tmp/.* + - third_party$ + - builtin$ + - examples$ +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From 1f11e52de24508633b5aa8107a990224c83ab6e1 Mon Sep 17 00:00:00 2001 From: moelsayed Date: Thu, 8 May 2025 12:31:02 +0200 Subject: [PATCH 22/22] more fixes --- .../crds/core.orchestrate.cloud.sap_controlplanes.yaml | 0 ...e.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml | 0 .../crds/core.orchestrate.cloud.sap_releasechannels.yaml | 0 cmd/{ => control-plane-operator}/main.go | 0 internal/ocm/ocm.go | 2 +- pkg/controlplane/crossplane/policies.go | 2 +- pkg/juggler/juggler.go | 4 ++-- 7 files changed, 4 insertions(+), 4 deletions(-) rename cmd/{ => control-plane-operator}/embedded/crds/core.orchestrate.cloud.sap_controlplanes.yaml (100%) rename cmd/{ => control-plane-operator}/embedded/crds/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml (100%) rename cmd/{ => control-plane-operator}/embedded/crds/core.orchestrate.cloud.sap_releasechannels.yaml (100%) rename cmd/{ => control-plane-operator}/main.go (100%) diff --git a/cmd/embedded/crds/core.orchestrate.cloud.sap_controlplanes.yaml b/cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_controlplanes.yaml similarity index 100% rename from cmd/embedded/crds/core.orchestrate.cloud.sap_controlplanes.yaml rename to cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_controlplanes.yaml diff --git a/cmd/embedded/crds/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml b/cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml similarity index 100% rename from cmd/embedded/crds/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml rename to cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml diff --git a/cmd/embedded/crds/core.orchestrate.cloud.sap_releasechannels.yaml b/cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_releasechannels.yaml similarity index 100% rename from cmd/embedded/crds/core.orchestrate.cloud.sap_releasechannels.yaml rename to cmd/control-plane-operator/embedded/crds/core.orchestrate.cloud.sap_releasechannels.yaml diff --git a/cmd/main.go b/cmd/control-plane-operator/main.go similarity index 100% rename from cmd/main.go rename to cmd/control-plane-operator/main.go diff --git a/internal/ocm/ocm.go b/internal/ocm/ocm.go index e9c23fd..faeed7e 100644 --- a/internal/ocm/ocm.go +++ b/internal/ocm/ocm.go @@ -207,5 +207,5 @@ func GetOCMComponent( } } - return v1beta1.ComponentVersion{}, fmt.Errorf("Component %s with version %s not found.", componentName, version) + return v1beta1.ComponentVersion{}, fmt.Errorf("component %s with version %s not found", componentName, version) } diff --git a/pkg/controlplane/crossplane/policies.go b/pkg/controlplane/crossplane/policies.go index 65ce946..d80b7bd 100644 --- a/pkg/controlplane/crossplane/policies.go +++ b/pkg/controlplane/crossplane/policies.go @@ -211,7 +211,7 @@ func ReconcileDeploymentConfigRuntimeProtectionPolicy(avp *arv1.ValidatingAdmiss func ReconcileDeploymentConfigRuntimeProtectionPolicyBinding(policyName string, avpd *arv1.ValidatingAdmissionPolicyBinding) { - avpd.ObjectMeta.Name = policyName + avpd.Name = policyName avpd.Spec = arv1.ValidatingAdmissionPolicyBindingSpec{ ValidationActions: []arv1.ValidationAction{arv1.Deny}, diff --git a/pkg/juggler/juggler.go b/pkg/juggler/juggler.go index 0e77ee6..2b24ab9 100644 --- a/pkg/juggler/juggler.go +++ b/pkg/juggler/juggler.go @@ -226,11 +226,11 @@ func (am *Juggler) reconcileComponent(ctx context.Context, component Component) } // Resource is not healthy - if !observation.ResourceHealthiness.Healthy { + if !observation.Healthy { return ComponentResult{ Component: component, Result: StatusUnhealthy, - Message: observation.ResourceHealthiness.Message, + Message: observation.Message, } }