Skip to content

Commit 2cf7aea

Browse files
feat: Merge code from cloud-orchestration/mcp-operator (#2)
* merge code from cloud-orchestration/mcp-operator * delete config files * fix .golangci.yaml * Switch to github.com/openmcp-project/controller-utils * switch to github.com/openmcp-project/control-plane-operator * rename module * remove hack submodule * cleanup * add ci action * add release action * remove CODEOWNERS * restore LICENSES * fix: link * fix(helm): image.repository value of Helm values * fix: typo * remove redundant headers --------- Co-authored-by: Maximilian Techritz <[email protected]>
1 parent 73d1177 commit 2cf7aea

File tree

526 files changed

+72377
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

526 files changed

+72377
-5
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug
4+
labels: kind/bug
5+
6+
---
7+
8+
**What happened**:
9+
10+
**What you expected to happen**:
11+
12+
**How to reproduce it (as minimally and precisely as possible)**:
13+
14+
**Anything else we need to know**:
15+
16+
**Environment**:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Enhancement Request
3+
about: Suggest an enhancement
4+
labels: kind/enhancement
5+
6+
---
7+
8+
**What would you like to be added**:
9+
10+
**Why is this needed**:

.github/pull_request_template.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**What this PR does / why we need it**:
2+
3+
**Which issue(s) this PR fixes**:
4+
Fixes #
5+
6+
**Special notes for your reviewer**:

.github/workflows/ci.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ci
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- master
8+
- main
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-24.04
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: go.mod
23+
24+
- name: make tidy
25+
run: |
26+
make tidy
27+
git diff --exit-code
28+
29+
- name: make verify
30+
run: make verify
31+
32+
- name: make test
33+
run: make test

.github/workflows/release.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Versioned Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write # we need this to be able to push tags
10+
11+
jobs:
12+
release_tag:
13+
name: Release version
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
ssh-key: ${{ secrets.PUSH_KEY }}
20+
fetch-tags: true
21+
fetch-depth: 0
22+
23+
- name: Read and validate VERSION
24+
id: version
25+
run: |
26+
VERSION=$(cat VERSION)
27+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev)?$ ]]; then
28+
echo "Invalid version format in VERSION file: $VERSION"
29+
exit 1
30+
fi
31+
echo "New version: $VERSION"
32+
echo "version=$VERSION" >> $GITHUB_ENV
33+
34+
- name: Skip release if version is a dev version
35+
if: contains(env.version, '-dev')
36+
run: |
37+
echo "Skipping development version release: ${{ env.version }}"
38+
echo "SKIP=true" >> $GITHUB_ENV
39+
exit 0
40+
41+
- name: Check if VERSION is already tagged
42+
id: check_tag
43+
run: |
44+
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
45+
echo "Tag ${{ env.version }} already exists. Skipping release."
46+
echo "SKIP=true" >> $GITHUB_ENV
47+
exit 0
48+
fi
49+
echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
50+
51+
- name: Create Git tag
52+
if: ${{ env.SKIP != 'true' }}
53+
run: |
54+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
55+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
56+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
57+
58+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
59+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
60+
61+
git config user.name "$AUTHOR_NAME"
62+
git config user.email "$AUTHOR_EMAIL"
63+
64+
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
65+
git push origin "${{ env.version }}"
66+
67+
- name: Create GitHub release
68+
if: ${{ env.SKIP != 'true' }}
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ env.version }}
72+
name: Release ${{ env.version }}
73+
body: "Automated release for version ${{ env.version }}"
74+
draft: false
75+
prerelease: false
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Push dev VERSION
80+
if: ${{ env.SKIP != 'true' }}
81+
run: |
82+
echo "${{ env.version }}-dev" > VERSION
83+
git config user.name "${{ env.AUTHOR_NAME }}"
84+
git config user.email "${{ env.AUTHOR_EMAIL }}"
85+
git add VERSION
86+
git commit -m "Update VERSION to ${{ env.version }}-dev"
87+
git push origin main

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin/
9+
Dockerfile.cross
10+
11+
# Test binary, build with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Kubernetes Generated files - skip generated files, except for vendored files
18+
19+
!vendor/**/zz_generated.*
20+
21+
# editor and IDE paraphernalia
22+
.idea
23+
.vscode
24+
*.swp
25+
*.swo
26+
*~
27+
28+
tmp
29+
go.work*
30+
components/
31+
!**/components/
32+
/**/cover.html
33+
/**/cover.*.html
34+
35+
*.tmp

.golangci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
run:
2+
concurrency: 4
3+
timeout: 10m
4+
5+
issues:
6+
exclude-files:
7+
- "zz_generated.*\\.go$"
8+
- "tmp/.*"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Code of Conduct
44

5-
All members of the project community must abide by the [SAP Open Source Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md).
5+
All members of the project community must abide by the [SAP Open Source Code of Conduct](https://github.com/openmcp-project/.github/blob/main/CODE_OF_CONDUCT.md).
66
Only by respecting each other we can develop a productive, collaborative community.
77
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [[email protected]](mailto:[email protected]) (SAP Open Source Program Office). All complaints will be reviewed and investigated promptly and fairly.
88

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# NOTE: This Dockerfile is used by the pipeline, but not for the 'make image' command, which uses the Dockerfile template in hack/common instead.
2+
# Use distroless as minimal base image to package the component binary
3+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
4+
FROM gcr.io/distroless/static:nonroot@sha256:6ec5aa99dc335666e79dc64e4a6c8b89c33a543a1967f20d360922a80dd21f02
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
ARG COMPONENT
8+
WORKDIR /
9+
COPY bin/$COMPONENT-$TARGETOS.$TARGETARCH /$COMPONENT
10+
USER nonroot:nonroot
11+
12+
ENTRYPOINT ["/$COMPONENT"]

Makefile

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
PROJECT_FULL_NAME := mcp-operator
2+
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
3+
EFFECTIVE_VERSION := $(shell $(REPO_ROOT)/hack/common/get-version.sh)
4+
5+
COMMON_MAKEFILE ?= $(REPO_ROOT)/hack/common/Makefile
6+
ifneq (,$(wildcard $(COMMON_MAKEFILE)))
7+
include $(COMMON_MAKEFILE)
8+
endif
9+
10+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
11+
ifeq (,$(shell go env GOBIN))
12+
GOBIN=$(shell go env GOPATH)/bin
13+
else
14+
GOBIN=$(shell go env GOBIN)
15+
endif
16+
17+
# CONTAINER_TOOL defines the container tool to be used for building images.
18+
# Be aware that the target commands are only tested with Docker which is
19+
# scaffolded by default. However, you might want to replace it to use other
20+
# tools. (i.e. podman)
21+
CONTAINER_TOOL ?= docker
22+
23+
# Setting SHELL to bash allows bash commands to be executed by recipes.
24+
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
25+
SHELL = /usr/bin/env bash -o pipefail
26+
.SHELLFLAGS = -ec
27+
28+
COMPONENTS ?= mcp-operator
29+
API_CODE_DIRS := $(REPO_ROOT)/api/constants/... $(REPO_ROOT)/api/errors/... $(REPO_ROOT)/api/install/... $(REPO_ROOT)/api/v1alpha1/... $(REPO_ROOT)/api/core/v1alpha1/...
30+
ROOT_CODE_DIRS := $(REPO_ROOT)/cmd/... $(REPO_ROOT)/internal/... $(REPO_ROOT)/test/...
31+
32+
##@ General
33+
34+
ifndef HELP_TARGET
35+
.PHONY: help
36+
help: ## Display this help.
37+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\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)
38+
endif
39+
40+
##@ Development
41+
42+
.PHONY: manifests
43+
manifests: controller-gen ## Generate CustomResourceDefinition objects.
44+
@echo "> Remove existing CRD manifests"
45+
rm -rf config/crd/bases/
46+
rm -rf config/webhook/manifests/
47+
rm -rf api/crds/manifests/
48+
@echo "> Generating CRD Manifests"
49+
@$(CONTROLLER_GEN) crd paths="$(REPO_ROOT)/api/core/v1alpha1/..." output:crd:artifacts:config=config/crd/bases
50+
@$(CONTROLLER_GEN) crd paths="$(REPO_ROOT)/api/core/v1alpha1/..." output:crd:artifacts:config=api/crds/manifests
51+
@$(CONTROLLER_GEN) webhook paths="$(REPO_ROOT)/api/..."
52+
53+
.PHONY: generate
54+
generate: generate-code manifests generate-docs format ## Generates code (DeepCopy stuff, CRDs), documentation index, and runs formatter.
55+
56+
.PHONY: generate-code
57+
generate-code: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. Also fetches external APIs.
58+
@echo "> Fetching External APIs"
59+
@go run $(REPO_ROOT)/hack/external-apis/main.go
60+
@echo "> Generating DeepCopy Methods"
61+
@$(CONTROLLER_GEN) object paths="$(REPO_ROOT)/api/core/v1alpha1/..."
62+
63+
.PHONY: format
64+
format: goimports ## Formats the imports.
65+
@FORMATTER=$(FORMATTER) $(REPO_ROOT)/hack/common/format.sh $(API_CODE_DIRS) $(ROOT_CODE_DIRS)
66+
67+
.PHONY: verify
68+
verify: golangci-lint jq goimports ## Runs linter, 'go vet', and checks if the formatter has been run.
69+
@test "$(SKIP_DOCS_INDEX_CHECK)" = "true" || \
70+
( echo "> Verify documentation index ..." && \
71+
JQ=$(JQ) $(REPO_ROOT)/hack/common/verify-docs-index.sh )
72+
@( echo "> Verifying api module ..." && \
73+
pushd $(REPO_ROOT)/api &>/dev/null && \
74+
go vet $(API_CODE_DIRS) && \
75+
$(LINTER) run -c $(REPO_ROOT)/.golangci.yaml $(API_CODE_DIRS) && \
76+
popd &>/dev/null )
77+
@( echo "> Verifying root module ..." && \
78+
pushd $(REPO_ROOT) &>/dev/null && \
79+
go vet $(ROOT_CODE_DIRS) && \
80+
$(LINTER) run -c $(REPO_ROOT)/.golangci.yaml $(ROOT_CODE_DIRS) && \
81+
popd &>/dev/null )
82+
@test "$(SKIP_FORMATTING_CHECK)" = "true" || \
83+
( echo "> Checking for unformatted files ..." && \
84+
FORMATTER=$(FORMATTER) $(REPO_ROOT)/hack/common/format.sh --verify $(API_CODE_DIRS) $(ROOT_CODE_DIRS) )
85+
86+
.PHONY: test
87+
test: #envtest ## Run tests.
88+
# KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(ROOT_CODE_DIRS) -coverprofile cover.out
89+
@( echo "> Test root module ..." && \
90+
pushd $(REPO_ROOT) &>/dev/null && \
91+
go test $(ROOT_CODE_DIRS) -coverprofile cover.root.out && \
92+
go tool cover --html=cover.root.out -o cover.root.html && \
93+
go tool cover -func cover.root.out | tail -n 1 && \
94+
popd &>/dev/null )
95+
96+
@( echo "> Test api module ..." && \
97+
pushd $(REPO_ROOT)/api &>/dev/null && \
98+
go test $(API_CODE_DIRS) -coverprofile cover.api.out && \
99+
go tool cover --html=cover.api.out -o cover.api.html && \
100+
go tool cover -func cover.api.out | tail -n 1 && \
101+
popd &>/dev/null )
102+
103+
##@ Build Dependencies
104+
105+
## Location to install dependencies to
106+
LOCALBIN ?= $(REPO_ROOT)/bin
107+
108+
# Tool Binaries
109+
ENVTEST ?= $(LOCALBIN)/setup-envtest
110+
111+
# Tool Versions
112+
SETUP_ENVTEST_VERSION ?= release-0.16
113+
114+
ifndef LOCALBIN_TARGET
115+
.PHONY: localbin
116+
localbin:
117+
@test -d $(LOCALBIN) || mkdir -p $(LOCALBIN)
118+
endif
119+
120+
.PHONY: envtest
121+
envtest: localbin ## Download envtest-setup locally if necessary.
122+
@test -s $(LOCALBIN)/setup-envtest && test -s $(LOCALBIN)/setup-envtest_version && cat $(LOCALBIN)/setup-envtest_version | grep -q $(SETUP_ENVTEST_VERSION) || \
123+
( echo "Installing setup-envtest $(SETUP_ENVTEST_VERSION) ..."; \
124+
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VERSION) && \
125+
echo $(SETUP_ENVTEST_VERSION) > $(LOCALBIN)/setup-envtest_version )
126+
127+
##@ Local Setup
128+
129+
DISABLE_AUTHENTICATION ?= true
130+
DISABLE_AUTHORIZATION ?= true
131+
DISABLE_CLOUDORCHESTRATOR ?= true
132+
DISABLE_MANAGEDCONTROLPLANE ?= false
133+
DISABLE_APISERVER ?= true
134+
DISABLE_LANDSCAPER ?= true
135+
LOCAL_GOARCH ?= $(shell go env GOARCH)
136+
137+
.PHONY: dev-local
138+
dev-local: dev-clean image-build-local dev-cluster load-image helm-install-local ## All-in-one command for creating a fresh local setup.
139+
140+
.PHONY: dev-clean
141+
dev-clean: ## Removes the kind cluster for local setup.
142+
$(KIND) delete cluster --name=$(PROJECT_FULL_NAME)-dev
143+
144+
.PHONY: dev-cluster
145+
dev-cluster: ## Creates a kind cluster for running a local setup.
146+
$(KIND) create cluster --name=$(PROJECT_FULL_NAME)-dev
147+
148+
.PHONY: load-image
149+
load-image: ## Loads the image into the local setup kind cluster.
150+
$(KIND) load docker-image local/mcp-operator:${EFFECTIVE_VERSION}-linux-$(LOCAL_GOARCH) --name=$(PROJECT_FULL_NAME)-dev
151+
152+
.PHONY: helm-install-local
153+
helm-install-local: ## Installs the MCP Operator into the local setup kind cluster by using its helm chart.
154+
helm upgrade --install $(PROJECT_FULL_NAME) charts/$(PROJECT_FULL_NAME)/ --set image.repository=local/mcp-operator --set image.tag=${EFFECTIVE_VERSION}-linux-$(LOCAL_GOARCH) --set image.pullPolicy=Never \
155+
--set authentication.disabled=$(DISABLE_AUTHENTICATION) \
156+
--set authorization.disabled=$(DISABLE_AUTHORIZATION) \
157+
--set cloudOrchestrator.disabled=$(DISABLE_CLOUDORCHESTRATOR) \
158+
--set managedcontrolplane.disabled=$(DISABLE_MANAGEDCONTROLPLANE) \
159+
--set apiserver.disabled=$(DISABLE_APISERVER) \
160+
--set landscaper.disabled=$(DISABLE_LANDSCAPER)
161+
162+
.PHONY: install
163+
install: manifests ## Install CRDs into the K8s cluster specified in ~/.kube/config (or $KUBECONFIG). Usually not required, as the MCP Operator installs the CRDs on its own.
164+
$(KUBECTL) apply -f config/crd/bases
165+

0 commit comments

Comments
 (0)