Skip to content

Commit aa9ef7b

Browse files
authored
Initialise Project (#2)
feat: Initialize project Signed-off-by: Samuel Torres <[email protected]>
1 parent 1e2fa36 commit aa9ef7b

File tree

4,415 files changed

+1347144
-2
lines changed

Some content is hidden

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

4,415 files changed

+1347144
-2
lines changed

Diff for: .devcontainer/devcontainer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Kubebuilder DevContainer",
3+
"image": "golang:1.22",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
6+
"ghcr.io/devcontainers/features/git:1": {}
7+
},
8+
9+
"runArgs": ["--network=host"],
10+
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"terminal.integrated.shell.linux": "/bin/bash"
15+
},
16+
"extensions": [
17+
"ms-kubernetes-tools.vscode-kubernetes-tools",
18+
"ms-azuretools.vscode-docker"
19+
]
20+
}
21+
},
22+
23+
"onCreateCommand": "bash .devcontainer/post-install.sh"
24+
}
25+

Diff for: .devcontainer/post-install.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -x
3+
4+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
5+
chmod +x ./kind
6+
mv ./kind /usr/local/bin/kind
7+
8+
curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64
9+
chmod +x kubebuilder
10+
mv kubebuilder /usr/local/bin/
11+
12+
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
13+
curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
14+
chmod +x kubectl
15+
mv kubectl /usr/local/bin/kubectl
16+
17+
docker network create -d=bridge --subnet=172.19.0.0/24 kind
18+
19+
kind version
20+
kubebuilder version
21+
docker --version
22+
go version
23+
kubectl version --client

Diff for: .dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore build and test binaries.
3+
bin/

Diff for: .github/.dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
9+
- package-ecosystem: "docker"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"

Diff for: .github/workflows/publish-chart.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish Chart
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish-chart:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
16+
attestations: write
17+
packages: write
18+
env:
19+
REGISTRY: ghcr.io
20+
CHART_DIR: charts
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
- name: Install Helm
25+
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
26+
with:
27+
version: v3.12.0
28+
- name: Login to GHCR
29+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Package chart
35+
id: package
36+
run: |
37+
helm package ${{ env.CHART_DIR }}/x-pdb
38+
echo "chart_file=$(ls *.tgz)" >> $GITHUB_OUTPUT
39+
- name: Push chart to GHCR
40+
id: push
41+
run: |
42+
helm push ${{ steps.package.outputs.chart_file }} oci://${{ env.REGISTRY }}/${{ github.repository }}/charts |& tee helm-push-output.log
43+
DIGEST=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log)
44+
echo "image=${{ env.REGISTRY }}/${{ github.repository }}/charts/${{ steps.package.outputs.chart_file }}" >> $GITHUB_OUTPUT
45+
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
46+
- name: Attest
47+
uses: actions/attest-build-provenance@c4fbc648846ca6f503a13a2281a5e7b98aa57202 # v2.0.1
48+
id: attest
49+
with:
50+
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}/charts/x-pdb
51+
subject-digest: ${{ steps.push.outputs.digest }}
52+
push-to-registry: true
53+
- name: Publish Helm charts to GH Pages
54+
uses: stefanprodan/helm-gh-pages@0ad2bb377311d61ac04ad9eb6f252fb68e207260 # v1.7.0
55+
with:
56+
token: ${{ secrets.GITHUB_TOKEN }}
57+
charts_dir: ${{ env.CHART_DIR }}

Diff for: .github/workflows/publish.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
workflow_dispatch:
9+
inputs:
10+
tag:
11+
description: 'image tag prefix'
12+
default: 'rc'
13+
required: true
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
id-token: write
20+
contents: read
21+
attestations: write
22+
packages: write
23+
env:
24+
REGISTRY: ghcr.io
25+
IMAGE_NAME: ${{ github.repository }}
26+
steps:
27+
- name: Checkout Code
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
- name: Prepare
30+
id: prep
31+
run: |
32+
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
33+
if [[ $GITHUB_REF == refs/tags/* ]]; then
34+
VERSION=${GITHUB_REF/refs\/tags\//}
35+
fi
36+
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
37+
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
42+
- name: Login to GHCR
43+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
- name: Generate images meta
49+
id: meta
50+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
51+
with:
52+
images: |
53+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=raw,value=${{ steps.prep.outputs.VERSION }}
56+
- name: Build and push
57+
id: build-push
58+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0
59+
with:
60+
provenance: true
61+
sbom: true
62+
push: true
63+
platforms: linux/amd64,linux/arm64
64+
labels: ${{ steps.meta.outputs.labels }}
65+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.prep.outputs.VERSION }}
66+
outputs: "type=registry,push=true"
67+
- name: Attest
68+
uses: actions/attest-build-provenance@c4fbc648846ca6f503a13a2281a5e7b98aa57202 # v2.0.1
69+
id: attest
70+
with:
71+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
subject-digest: ${{ steps.build-push.outputs.digest }}
73+
push-to-registry: true

Diff for: .github/workflows/release.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'version to release, e.g. v1.5.13'
8+
required: true
9+
default: 'v0.1.0'
10+
source_ref:
11+
description: 'source ref to publish from. E.g.: main or release-x.y'
12+
required: true
13+
default: 'main'
14+
15+
jobs:
16+
release:
17+
name: Create Release
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
fetch-depth: 0
25+
ref: ${{ github.event.inputs.source_ref }}
26+
- name: Create Release
27+
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
28+
with:
29+
tag_name: ${{ github.event.inputs.version }}
30+
target_commitish: ${{ github.event.inputs.source_ref }}
31+
generate_release_notes: true
32+
body: |
33+
Image: `${{ env.IMAGE_NAME }}:${{ github.event.inputs.version }}`
34+
env:
35+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Diff for: .github/workflows/test.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "**"
9+
pull_request:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
steps:
21+
- name: Checkout Code
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
- name: Setup Golang
24+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
25+
with:
26+
go-version-file: go.mod
27+
- uses: bufbuild/buf-action@v1
28+
name: Buf check proto
29+
id: run-check-proto
30+
with:
31+
breaking: false
32+
pr_comment: false
33+
- name: Lint
34+
id: run-lint
35+
run: make lint
36+
- name: Run Go tests
37+
id: run-tests
38+
run: make test
39+
- name: Run E2E tests
40+
id: run-e2e-tests
41+
run: |
42+
make multi-cluster
43+
make deploy-e2e
44+
make e2e

Diff for: .gitignore

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

Diff for: .golangci.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
run:
2+
timeout: 5m
3+
allow-parallel-runners: true
4+
5+
issues:
6+
# don't skip warning about doc comments
7+
# don't exclude the default set of lint
8+
exclude-use-default: false
9+
# restore some of the defaults
10+
# (fill in the rest as needed)
11+
exclude-rules:
12+
- path: "api/*"
13+
linters:
14+
- lll
15+
- path: "internal/*"
16+
linters:
17+
- dupl
18+
- lll
19+
linters:
20+
disable-all: true
21+
enable:
22+
- dupl
23+
- errcheck
24+
- copyloopvar
25+
- ginkgolinter
26+
- goconst
27+
- gocyclo
28+
- gofmt
29+
- goimports
30+
- gosimple
31+
- govet
32+
- ineffassign
33+
- lll
34+
- misspell
35+
- nakedret
36+
- prealloc
37+
- revive
38+
- staticcheck
39+
- typecheck
40+
- unconvert
41+
- unparam
42+
- unused
43+
44+
linters-settings:
45+
revive:
46+
rules:
47+
- name: comment-spacings

Diff for: Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.23.3-alpine3.20 AS builder
2+
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
WORKDIR /workspace
7+
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
COPY vendor/ vendor/
11+
RUN go mod verify
12+
13+
COPY api/ api/
14+
COPY cmd/controller cmd/controller
15+
COPY internal/ internal/
16+
COPY pkg/ pkg/
17+
18+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o x-pdb cmd/controller/main.go
19+
20+
FROM gcr.io/distroless/static:nonroot
21+
WORKDIR /
22+
COPY --from=builder /workspace/x-pdb .
23+
USER 65532:65532
24+
ENTRYPOINT ["/x-pdb"]

0 commit comments

Comments
 (0)