Skip to content

Commit 60b0a78

Browse files
feat: merge code from CoLa/quota-operator (#2)
* merge code from CoLa/quota-operator * rename module * remove unused config * fix .golangci.yaml * add hack/common * add ci and release actions * cleanup * chore: remove CODEOWNERS --------- Co-authored-by: Maximilian Techritz <[email protected]>
1 parent 08eb374 commit 60b0a78

File tree

93 files changed

+5056
-3
lines changed

Some content is hidden

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

93 files changed

+5056
-3
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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**:
7+
8+
**Release note**:
9+
<!-- Write your release note:
10+
1. Enter your release note in the below block.
11+
2. If no release note is required, just write "NONE" within the block.
12+
13+
Format of block header: <category> <target_group>
14+
Possible values:
15+
- category: breaking|feature|bugfix|doc|other
16+
- target_group: user|operator|developer|dependency
17+
-->
18+
```feature user
19+
20+
```

.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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
34+
*.tmp
35+
36+
# add later again
37+
blueprints/
38+
components/

.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/.*"

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
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: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
PROJECT_FULL_NAME := quota-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 ?= quota-operator
29+
API_CODE_DIRS := $(REPO_ROOT)/api/...
30+
ROOT_CODE_DIRS := $(REPO_ROOT)/cmd/... $(REPO_ROOT)/pkg/...
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 api/crds/manifests/
46+
@rm -rf config/crd/bases/
47+
@echo "> Generating CRD Manifests"
48+
@$(CONTROLLER_GEN) crd paths="$(REPO_ROOT)/api/..." output:crd:artifacts:config=api/crds/manifests
49+
@$(CONTROLLER_GEN) crd paths="$(REPO_ROOT)/api/..." output:crd:artifacts:config=config/crd/bases
50+
51+
.PHONY: generate
52+
generate: generate-code manifests format ## Generates code (DeepCopy stuff, CRDs), documentation index, and runs formatter.
53+
54+
.PHONY: generate-code
55+
generate-code: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. Also fetches external APIs.
56+
@echo "> Generating DeepCopy Methods"
57+
@$(CONTROLLER_GEN) object paths="$(REPO_ROOT)/api/..."
58+
59+
.PHONY: format
60+
format: goimports ## Formats the imports.
61+
@FORMATTER=$(FORMATTER) $(REPO_ROOT)/hack/common/format.sh $(API_CODE_DIRS) $(ROOT_CODE_DIRS)
62+
63+
.PHONY: verify
64+
verify: golangci-lint goimports ## Runs linter, 'go vet', and checks if the formatter has been run.
65+
@( echo "> Verifying api module ..." && \
66+
pushd $(REPO_ROOT)/api &>/dev/null && \
67+
go vet $(API_CODE_DIRS) && \
68+
$(LINTER) run -c $(REPO_ROOT)/.golangci.yaml $(API_CODE_DIRS) && \
69+
popd &>/dev/null )
70+
@( echo "> Verifying root module ..." && \
71+
pushd $(REPO_ROOT) &>/dev/null && \
72+
go vet $(ROOT_CODE_DIRS) && \
73+
$(LINTER) run -c $(REPO_ROOT)/.golangci.yaml $(ROOT_CODE_DIRS) && \
74+
popd &>/dev/null )
75+
@test "$(SKIP_FORMATTING_CHECK)" = "true" || \
76+
( echo "> Checking for unformatted files ..." && \
77+
FORMATTER=$(FORMATTER) $(REPO_ROOT)/hack/common/format.sh --verify $(API_CODE_DIRS) $(ROOT_CODE_DIRS) )
78+
79+
.PHONY: test
80+
test: ## Run tests.
81+
go test $(ROOT_CODE_DIRS) -coverprofile cover.out
82+
go tool cover --html=cover.out -o cover.html
83+
go tool cover -func cover.out | tail -n 1

PROJECT

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
5+
domain: openmcp.cloud
6+
layout:
7+
- go.kubebuilder.io/v4
8+
projectName: quota-operator
9+
repo: github.com/openmcp-project/quota-operator
10+
resources:
11+
- api:
12+
crdVersion: v1
13+
namespaced: true
14+
controller: true
15+
domain: openmcp.cloud
16+
kind: QuotaIncrease
17+
path: github.com/openmcp-project/quota-operator/api/v1alpha1
18+
version: v1alpha1
19+
version: "3"

0 commit comments

Comments
 (0)