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..979588d 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,7 @@ jobs: } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - name: Create GitHub release if: ${{ env.SKIP != 'true' }} uses: softprops/action-gh-release@v2 @@ -113,9 +119,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 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 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/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..e99b1eb --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,24 @@ +version: "2" +run: + concurrency: 4 +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$ 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: [] 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/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/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..d285974 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,25 @@ +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: [] + vars: + NESTED_MODULES: api + API_DIRS: '{{.ROOT_DIR}}/api/v1beta1/...' + MANIFEST_OUT: '{{.ROOT_DIR}}/api/crds/manifests' + 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' + ENVTEST_REQUIRED: "true" + ENVTEST_K8S_VERSION: "1.30.0" \ No newline at end of file diff --git a/config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml similarity index 99% rename from config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml rename to api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml index 66e8d58..d34ba8a 100644 --- a/config/crd/bases/core.orchestrate.cloud.sap_controlplanes.yaml +++ b/api/crds/manifests/core.orchestrate.cloud.sap_controlplanes.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.17.3 name: controlplanes.core.orchestrate.cloud.sap spec: group: core.orchestrate.cloud.sap diff --git a/config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml similarity index 98% rename from config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml rename to api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml index 516b788..467d2db 100644 --- a/config/crd/bases/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml +++ b/api/crds/manifests/core.orchestrate.cloud.sap_crossplanepackagerestrictions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.17.3 name: crossplanepackagerestrictions.core.orchestrate.cloud.sap spec: group: core.orchestrate.cloud.sap diff --git a/config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml b/api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml similarity index 99% rename from config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml rename to api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml index 4aa668a..04893c9 100644 --- a/config/crd/bases/core.orchestrate.cloud.sap_releasechannels.yaml +++ b/api/crds/manifests/core.orchestrate.cloud.sap_releasechannels.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.4 + controller-gen.kubebuilder.io/version: v0.17.3 name: releasechannels.core.orchestrate.cloud.sap spec: group: core.orchestrate.cloud.sap 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/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/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/hack/common b/hack/common new file mode 160000 index 0000000..7a0d273 --- /dev/null +++ b/hack/common @@ -0,0 +1 @@ +Subproject commit 7a0d273d75f6532548ca6b65ded134dbafdf37a1 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 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..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" @@ -12,12 +11,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,12 +26,15 @@ 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" ) func TestMain(m *testing.M) { - if err := envtestutil.Install(); err != nil { - log.Fatalln(err) - } os.Exit(m.Run()) } 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..faeed7e 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. @@ -206,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/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/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..d80b7bd 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 @@ -210,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/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 60def17..21b0030 100644 --- a/pkg/controlplane/kubeconfiggen/generate_test.go +++ b/pkg/controlplane/kubeconfiggen/generate_test.go @@ -4,13 +4,10 @@ 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" @@ -20,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 ( @@ -32,9 +31,6 @@ var ( ) func TestMain(m *testing.M) { - if err := envtestutil.Install(); err != nil { - log.Fatalln(err) - } os.Exit(m.Run()) } 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.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, } } 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/envtest/envtest.go b/pkg/utils/envtest/envtest.go deleted file mode 100644 index 5665f0c..0000000 --- a/pkg/utils/envtest/envtest.go +++ /dev/null @@ -1,123 +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`) -) - -// 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) { - 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) 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) { 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