Skip to content

Commit 73990a3

Browse files
Merge remote-tracking branch 'origin/main' into setCRD
2 parents 43b11d6 + 3f6eab0 commit 73990a3

File tree

89 files changed

+2427
-1500
lines changed

Some content is hidden

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

89 files changed

+2427
-1500
lines changed

.custom-gcl.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file configures golangci-lint with module plugins.
2+
# When you run 'make lint', it will automatically build a custom golangci-lint binary
3+
# with all the plugins listed below.
4+
#
5+
# See: https://golangci-lint.run/plugins/module-plugins/
6+
version: v2.8.0
7+
plugins:
8+
# logcheck validates structured logging calls and parameters (e.g., balanced key-value pairs)
9+
- module: "sigs.k8s.io/logtools"
10+
import: "sigs.k8s.io/logtools/logcheck/gclplugin"
11+
version: latest

.devcontainer/devcontainer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "Kubebuilder DevContainer",
3+
"image": "golang:1.25",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
6+
"moby": false,
7+
"dockerDefaultAddressPool": "base=172.30.0.0/16,size=24"
8+
},
9+
"ghcr.io/devcontainers/features/git:1": {},
10+
"ghcr.io/devcontainers/features/common-utils:2": {
11+
"upgradePackages": true
12+
}
13+
},
14+
"runArgs": [
15+
"--privileged",
16+
"--init"
17+
],
18+
"customizations": {
19+
"vscode": {
20+
"settings": {
21+
"terminal.integrated.profiles.linux": {
22+
"bash": {
23+
"path": "/bin/bash"
24+
}
25+
},
26+
"terminal.integrated.defaultProfile.linux": "bash"
27+
},
28+
"extensions": [
29+
"ms-kubernetes-tools.vscode-kubernetes-tools",
30+
"ms-azuretools.vscode-docker"
31+
]
32+
}
33+
},
34+
"remoteEnv": {
35+
"GO111MODULE": "on"
36+
},
37+
"onCreateCommand": "bash .devcontainer/post-install.sh"
38+
}

.devcontainer/post-install.sh

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
echo "===================================="
5+
echo "Kubebuilder DevContainer Setup"
6+
echo "===================================="
7+
8+
# Verify running as root (required for installing to /usr/local/bin and /etc)
9+
if [ "$(id -u)" -ne 0 ]; then
10+
echo "ERROR: This script must be run as root"
11+
exit 1
12+
fi
13+
14+
echo ""
15+
echo "Detecting system architecture..."
16+
# Detect architecture using uname
17+
MACHINE=$(uname -m)
18+
case "${MACHINE}" in
19+
x86_64)
20+
ARCH="amd64"
21+
;;
22+
aarch64|arm64)
23+
ARCH="arm64"
24+
;;
25+
*)
26+
echo "WARNING: Unsupported architecture ${MACHINE}, defaulting to amd64"
27+
ARCH="amd64"
28+
;;
29+
esac
30+
echo "Architecture: ${ARCH}"
31+
32+
echo ""
33+
echo "------------------------------------"
34+
echo "Setting up bash completion..."
35+
echo "------------------------------------"
36+
37+
BASH_COMPLETIONS_DIR="/usr/share/bash-completion/completions"
38+
39+
# Enable bash-completion in root's .bashrc (devcontainer runs as root)
40+
if ! grep -q "source /usr/share/bash-completion/bash_completion" ~/.bashrc 2>/dev/null; then
41+
echo 'source /usr/share/bash-completion/bash_completion' >> ~/.bashrc
42+
echo "Added bash-completion to .bashrc"
43+
fi
44+
45+
echo ""
46+
echo "------------------------------------"
47+
echo "Installing development tools..."
48+
echo "------------------------------------"
49+
50+
# Install kind
51+
if ! command -v kind &> /dev/null; then
52+
echo "Installing kind..."
53+
curl -Lo /usr/local/bin/kind "https://kind.sigs.k8s.io/dl/latest/kind-linux-${ARCH}"
54+
chmod +x /usr/local/bin/kind
55+
echo "kind installed successfully"
56+
fi
57+
58+
# Generate kind bash completion
59+
if command -v kind &> /dev/null; then
60+
if kind completion bash > "${BASH_COMPLETIONS_DIR}/kind" 2>/dev/null; then
61+
echo "kind completion installed"
62+
else
63+
echo "WARNING: Failed to generate kind completion"
64+
fi
65+
fi
66+
67+
# Install kubebuilder
68+
if ! command -v kubebuilder &> /dev/null; then
69+
echo "Installing kubebuilder..."
70+
curl -Lo /usr/local/bin/kubebuilder "https://go.kubebuilder.io/dl/latest/linux/${ARCH}"
71+
chmod +x /usr/local/bin/kubebuilder
72+
echo "kubebuilder installed successfully"
73+
fi
74+
75+
# Generate kubebuilder bash completion
76+
if command -v kubebuilder &> /dev/null; then
77+
if kubebuilder completion bash > "${BASH_COMPLETIONS_DIR}/kubebuilder" 2>/dev/null; then
78+
echo "kubebuilder completion installed"
79+
else
80+
echo "WARNING: Failed to generate kubebuilder completion"
81+
fi
82+
fi
83+
84+
# Install kubectl
85+
if ! command -v kubectl &> /dev/null; then
86+
echo "Installing kubectl..."
87+
KUBECTL_VERSION=$(curl -Ls https://dl.k8s.io/release/stable.txt)
88+
curl -Lo /usr/local/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl"
89+
chmod +x /usr/local/bin/kubectl
90+
echo "kubectl installed successfully"
91+
fi
92+
93+
# Generate kubectl bash completion
94+
if command -v kubectl &> /dev/null; then
95+
if kubectl completion bash > "${BASH_COMPLETIONS_DIR}/kubectl" 2>/dev/null; then
96+
echo "kubectl completion installed"
97+
else
98+
echo "WARNING: Failed to generate kubectl completion"
99+
fi
100+
fi
101+
102+
# Generate Docker bash completion
103+
if command -v docker &> /dev/null; then
104+
if docker completion bash > "${BASH_COMPLETIONS_DIR}/docker" 2>/dev/null; then
105+
echo "docker completion installed"
106+
else
107+
echo "WARNING: Failed to generate docker completion"
108+
fi
109+
fi
110+
111+
echo ""
112+
echo "------------------------------------"
113+
echo "Configuring Docker environment..."
114+
echo "------------------------------------"
115+
116+
# Wait for Docker to be ready
117+
echo "Waiting for Docker to be ready..."
118+
for i in {1..30}; do
119+
if docker info >/dev/null 2>&1; then
120+
echo "Docker is ready"
121+
break
122+
fi
123+
if [ "$i" -eq 30 ]; then
124+
echo "WARNING: Docker not ready after 30s"
125+
fi
126+
sleep 1
127+
done
128+
129+
# Create kind network (ignore if already exists)
130+
if ! docker network inspect kind >/dev/null 2>&1; then
131+
if docker network create kind >/dev/null 2>&1; then
132+
echo "Created kind network"
133+
else
134+
echo "WARNING: Failed to create kind network (may already exist)"
135+
fi
136+
fi
137+
138+
echo ""
139+
echo "------------------------------------"
140+
echo "Verifying installations..."
141+
echo "------------------------------------"
142+
kind version
143+
kubebuilder version
144+
kubectl version --client
145+
docker --version
146+
go version
147+
148+
echo ""
149+
echo "===================================="
150+
echo "DevContainer ready!"
151+
echo "===================================="
152+
echo "All development tools installed successfully."
153+
echo "You can now start building Kubernetes operators."

.github/release-drafter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
filter-by-commitish: true
12
name-template: 'v$RESOLVED_VERSION'
23
tag-template: 'v$RESOLVED_VERSION'
34
categories:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Create Release Branch
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.0"
7+
8+
jobs:
9+
create-release-branch:
10+
name: Create release branch
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v6
16+
- name: Create release branch
17+
run: |
18+
TAG="${GITHUB_REF#refs/tags/}"
19+
# Extract major.minor from tag (e.g. v0.1.0 -> release-v0.1)
20+
BRANCH="release-${TAG%.*}"
21+
git switch -c "${BRANCH}"
22+
git push origin "${BRANCH}"

.github/workflows/release-drafter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- release-**
78
pull_request_target:
89
types: [ opened, reopened, synchronize ]
910
workflow_dispatch:
@@ -20,8 +21,10 @@ jobs:
2021
runs-on: ubuntu-latest
2122
steps:
2223
# Drafts your next Release notes as Pull Requests are merged into "main"
24+
# or a release branch
2325
- uses: release-drafter/release-drafter@v6
2426
with:
2527
config-name: release-drafter.yml
28+
commitish: ${{ github.ref_name }}
2629
env:
2730
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.golangci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ linters:
2222
- unconvert
2323
- unparam
2424
- unused
25+
- logcheck
2526
settings:
27+
custom:
28+
logcheck:
29+
type: "module"
30+
description: Checks Go logging calls for Kubernetes logging conventions.
2631
revive:
2732
rules:
2833
- name: comment-spacings

0 commit comments

Comments
 (0)