Skip to content

Commit 2fb6829

Browse files
author
Zibi Mandziejewicz
committed
initial commit
0 parents  commit 2fb6829

File tree

114 files changed

+10377
-0
lines changed

Some content is hidden

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

114 files changed

+10377
-0
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.git/
2+
3+
build/
4+
.github/
5+
.vscode/
6+
docs/
7+
hack/
8+
makefiles/
9+
config/
10+
skaffold.yaml

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
go.sum binary
2+
api/v1/zz_generated.*.go binary
3+
docs/design/backup/*.svg binary

.github/workflows/ci.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
image-build:
8+
name: Image Build
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Set up QEMU
14+
uses: docker/setup-qemu-action@v3
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v3
17+
with:
18+
platforms: linux/amd64,linux/arm64
19+
- name: Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Setup Skaffold
26+
uses: heypigeonhq/setup-skaffold@v1.0.0
27+
with:
28+
version: 2.14.1
29+
- name: Build images
30+
run: |
31+
mkdir build
32+
skaffold build --file-output=build/images.json
33+
- name: Archive image tags
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: images
37+
path: build/images.json
38+
39+
verify:
40+
name: Verify
41+
runs-on: ubuntu-latest
42+
env:
43+
CODECOV_FILE: build/coverage.xml
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
- name: Setup Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: '1.24'
51+
- name: Generate
52+
run: make generate format
53+
- name: No changed files
54+
run: git diff --name-status --exit-code
55+
- name: Lint
56+
run: make lint
57+
- name: Integration test
58+
run: make integration-test coverage
59+
- name: Archive coverage report
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: coverage
63+
path: ${{ env.CODECOV_FILE }}
64+
65+
e2e:
66+
name: E2E Test
67+
if: github.actor!= 'dependabot-preview[bot]'
68+
needs:
69+
- verify
70+
- image-build
71+
runs-on: ubuntu-latest
72+
env:
73+
CODECOV_FILE: build/coverage.e2e.xml
74+
SKAFFOLD_NAMESPACE: sandbox
75+
SKAFFOLD_RUN_ID: e2e-test
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
- name: Setup Skaffold
80+
uses: heypigeonhq/setup-skaffold@v1.0.0
81+
with:
82+
version: 2.14.1
83+
- name: Create Kind cluster
84+
uses: helm/kind-action@v1
85+
- name: Bootstrap
86+
run: |
87+
kustomize build --enable-helm config/bootstrap | kubectl apply -f -
88+
kubectl wait deployment/cert-manager-webhook \
89+
--namespace cert-manager \
90+
--for=condition=Available \
91+
--timeout=5m
92+
kubectl get namespace sandbox 2>/dev/null || kubectl create namespace sandbox
93+
mkdir build/
94+
skaffold config set kind-disable-load true
95+
- name: Download image tags
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: images
99+
path: build
100+
- name: Deploy
101+
run: skaffold deploy --profile e2e --build-artifacts=build/images.json
102+
- name: Run E2E tests
103+
run: skaffold verify --namespace sandbox --build-artifacts=build/images.json
104+
- name: Fetch coverage
105+
run: make fetch-coverage
106+
- name: Archive coverage report
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: coverage-e2e
110+
path: ${{ env.CODECOV_FILE }}
111+
112+
coverage:
113+
name: Coverage Report
114+
if: github.actor!= 'dependabot-preview[bot]'
115+
needs:
116+
- verify
117+
- e2e
118+
runs-on: ubuntu-latest
119+
steps:
120+
- name: Download coverage report
121+
uses: actions/download-artifact@v4
122+
with:
123+
name: coverage
124+
- name: Download E2E coverage report
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: coverage-e2e
128+
- name: Upload coverage reports to Codecov
129+
uses: codecov/codecov-action@v5
130+
with:
131+
token: ${{ secrets.CODECOV_TOKEN }}
132+
files: coverage.xml,coverage.e2e.xml

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
build/
2+
go.work.sum
3+
coverage.xml
4+
build.json
5+
*.env
6+
7+
# editor and IDE paraphernalia
8+
.idea/
9+
.vscode/
10+
11+
# Binaries for programs and plugins
12+
*.exe
13+
*.exe~
14+
*.dll
15+
*.so
16+
*.dylib
17+
*.test
18+
__debug_bin
19+
testbin/
20+
build.json
21+
.DS_Store
22+
23+
# Test binary, build with `go test -c`
24+
*.swp
25+
*.swo
26+
*~

.golangci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "2"
2+
run:
3+
concurrency: 4
4+
modules-download-mode: readonly
5+
tests: true
6+
linters:
7+
exclusions:
8+
generated: lax
9+
paths:
10+
- third_party$
11+
- builtin$
12+
- examples$
13+
issues:
14+
max-issues-per-linter: 0
15+
max-same-issues: 0

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG BASE_IMAGE=gcr.io/distroless/base-debian12:nonroot
4+
5+
FROM golang:1.24 AS build
6+
7+
WORKDIR /app
8+
COPY . .
9+
10+
ARG SKAFFOLD_GO_GCFLAGS
11+
ARG GOFLAGS
12+
ARG GOMODCACHE=/go/pkg/mod
13+
ARG GOCACHE=/root/.cache/go-build
14+
RUN --mount=type=cache,target=${GOMODCACHE} \
15+
--mount=type=cache,target=${GOCACHE} \
16+
mkdir -p /etc/etcd/bin && \
17+
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /etc/etcd/bin/ ./cmd/... && \
18+
go test -o /etc/etcd/bin/etcd-e2e-test -c ./e2e
19+
20+
FROM $BASE_IMAGE
21+
COPY --from=build /etc/etcd/bin /etc/etcd/bin
22+
23+
ENV GOTRACEBACK=all
24+
ENV PATH=${PATH}:/etc/etcd/bin
25+
ENTRYPOINT [ "/etc/etcd/bin/etcd-operator" ]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Agoda Company Pte Ltd.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# controller-gen args
2+
CONTROLLER_GEN_VERSION = v0.17.1
3+
CONTROLLER_GEN_ARGS := \
4+
paths={./api/...,./pkg/...} \
5+
crd \
6+
object:headerFile=hack/boilerplate.go.txt \
7+
rbac:roleName=etcd-operator \
8+
output:crd:artifacts:config=config/crd
9+
10+
CRDOC_ARGS := \
11+
--resources=config/crd \
12+
--output=docs/api.md
13+
14+
# deployment namespace
15+
SKAFFOLD_NAMESPACE ?= fleet
16+
17+
# explicit package path for coverage
18+
GOCOVERPKG := gitlab.agodadev.io/fleet/etcd/pkg/...
19+
GOTESTARGS := -test.timeout=30m
20+
GOMUTESTARGS := ./pkg
21+
GOLANGCILINT_VERSION := v2.1.6
22+
23+
# pod selector for coverage
24+
FETCH_COVERAGE_SELECTOR := app=etcd-operator
25+
26+
include makefiles/go.mk
27+
include makefiles/controller.mk
28+
include makefiles/d2.mk
29+
30+
.PHONY: generate fetch-coverage
31+
32+
generate: config/rbac/role.yaml config/rbac/sidecar-role.yaml config/e2e/role.yaml config/e2e/test-role.yaml
33+
34+
fetch-coverage: $(GOCOVERDIR)
35+
GOCOVERDIR=$(GOCOVERDIR) \
36+
SKAFFOLD_NAMESPACE=$(SKAFFOLD_NAMESPACE) \
37+
SKAFFOLD_RUN_ID=$(SKAFFOLD_RUN_ID) \
38+
makefiles/scripts/skaffold/fetch-coverage app=etcd-operator
39+
40+
.PHONY: config/rbac/role.yaml config/rbac/sidecar-role.yaml config/e2e/role.yaml config/e2e/test-role.yaml
41+
42+
config/rbac/role.yaml:
43+
$(CONTROLLER_GEN) > config/rbac/role.yaml \
44+
paths=./pkg/... \
45+
rbac:roleName=etcd-operator \
46+
output:rbac:stdout
47+
48+
config/rbac/sidecar-role.yaml:
49+
$(CONTROLLER_GEN) > config/rbac/sidecar-role.yaml \
50+
paths=./pkg/sidecar \
51+
rbac:roleName=etcd-sidecar \
52+
output:rbac:stdout
53+
54+
config/e2e/role.yaml: config/rbac/role.yaml
55+
mkdir -p config/e2e
56+
yq -r '.kind = "Role" | .rules = .rules' config/rbac/role.yaml >config/e2e/role.yaml
57+
58+
config/e2e/test-role.yaml:
59+
$(CONTROLLER_GEN) \
60+
paths=./e2e/... \
61+
rbac:roleName=etcd-test \
62+
output:rbac:stdout | \
63+
yq -r '.kind = "Role" | .rules = .rules' > config/e2e/test-role.yaml

0 commit comments

Comments
 (0)