Skip to content

Commit b8448fa

Browse files
feat: first commit
0 parents  commit b8448fa

File tree

100 files changed

+8648
-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.

100 files changed

+8648
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: release-pullrequest
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
package-amd64:
13+
runs-on: buildjet-2vcpu-ubuntu-2204
14+
permissions:
15+
packages: write
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v4
24+
with:
25+
images: ${{ env.REGISTRY }}/${{ github.repository }}
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
- name: Login to CR
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Build docker image and push
38+
id: docker_build_amd64
39+
uses: docker/build-push-action@v4
40+
with:
41+
push: false
42+
platforms: linux/amd64
43+
labels: ${{ steps.meta.outputs.labels }}
44+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
45+
46+
package-arm64:
47+
runs-on: buildjet-4vcpu-ubuntu-2204-arm
48+
permissions:
49+
packages: write
50+
contents: read
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v3
54+
55+
- name: Docker meta
56+
id: meta
57+
uses: docker/metadata-action@v4
58+
with:
59+
images: ${{ env.REGISTRY }}/${{ github.repository }}
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v2
63+
64+
- name: Login to CR
65+
uses: docker/login-action@v2
66+
with:
67+
registry: ${{ env.REGISTRY }}
68+
username: ${{ github.repository_owner }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Build docker image and push
72+
id: docker_build_arm64
73+
uses: docker/build-push-action@v4
74+
with:
75+
push: false
76+
platforms: linux/arm64
77+
labels: ${{ steps.meta.outputs.labels }}
78+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true

.github/workflows/release-tag.yaml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: release-tag
2+
3+
on:
4+
push:
5+
tags: [ '[0-9]+.[0-9]+.[0-9]+' ]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
10+
jobs:
11+
package-amd64:
12+
runs-on: buildjet-2vcpu-ubuntu-2204
13+
permissions:
14+
packages: write
15+
contents: read
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Docker meta
21+
id: meta
22+
uses: docker/metadata-action@v4
23+
with:
24+
images: ${{ env.REGISTRY }}/${{ github.repository }}
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Login to CR
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.repository_owner }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build docker image and push
37+
id: docker_build_amd64
38+
uses: docker/build-push-action@v4
39+
with:
40+
push: true
41+
platforms: linux/amd64
42+
labels: ${{ steps.meta.outputs.labels }}
43+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
44+
45+
- name: Export digest
46+
run: |
47+
mkdir -p /tmp/digests
48+
digest="${{ steps.docker_build_amd64.outputs.digest }}"
49+
touch "/tmp/digests/${digest#sha256:}"
50+
51+
- name: Upload digest
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: digests
55+
path: /tmp/digests/*
56+
if-no-files-found: error
57+
retention-days: 1
58+
59+
package-arm64:
60+
runs-on: buildjet-2vcpu-ubuntu-2204-arm
61+
permissions:
62+
packages: write
63+
contents: read
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
68+
- name: Docker meta
69+
id: meta
70+
uses: docker/metadata-action@v4
71+
with:
72+
images: ${{ env.REGISTRY }}/${{ github.repository }}
73+
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@v2
76+
77+
- name: Login to CR
78+
uses: docker/login-action@v2
79+
with:
80+
registry: ${{ env.REGISTRY }}
81+
username: ${{ github.repository_owner }}
82+
password: ${{ secrets.GITHUB_TOKEN }}
83+
84+
- name: Build docker image and push
85+
id: docker_build_arm64
86+
uses: docker/build-push-action@v4
87+
with:
88+
push: true
89+
platforms: linux/arm64
90+
labels: ${{ steps.meta.outputs.labels }}
91+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
92+
93+
- name: Export digest
94+
run: |
95+
mkdir -p /tmp/digests
96+
digest="${{ steps.docker_build_arm64.outputs.digest }}"
97+
touch "/tmp/digests/${digest#sha256:}"
98+
99+
- name: Upload digest
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: digests
103+
path: /tmp/digests/*
104+
if-no-files-found: error
105+
retention-days: 1
106+
107+
merge:
108+
runs-on: buildjet-2vcpu-ubuntu-2204
109+
needs:
110+
- package-amd64
111+
- package-arm64
112+
permissions:
113+
packages: write
114+
contents: read
115+
steps:
116+
- name: Download digests
117+
uses: actions/download-artifact@v3
118+
with:
119+
name: digests
120+
path: /tmp/digests
121+
122+
- name: Set up Docker Buildx
123+
uses: docker/setup-buildx-action@v2
124+
125+
- name: Docker meta
126+
id: meta
127+
uses: docker/metadata-action@v4
128+
with:
129+
images: ${{ env.REGISTRY }}/${{ github.repository }}
130+
131+
- name: Login to CR
132+
uses: docker/login-action@v2
133+
with:
134+
registry: ${{ env.REGISTRY }}
135+
username: ${{ github.repository_owner }}
136+
password: ${{ secrets.GITHUB_TOKEN }}
137+
138+
- name: Create manifest list and push
139+
working-directory: /tmp/digests
140+
run: |
141+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
142+
$(printf '${{ env.REGISTRY }}/${{ github.repository }}@sha256:%s ' *)
143+
144+
- name: Inspect image
145+
run: |
146+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.meta.outputs.version }}

.github/workflows/test.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Test and coverage
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-go@v5
11+
with:
12+
go-version: 'stable'
13+
- name: Gather dependencies
14+
run: go mod download
15+
- name: Run coverage
16+
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
17+
- name: Upload coverage to Codecov
18+
uses: codecov/codecov-action@v4
19+
with:
20+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Intellij
2+
.idea/**/workspace.xml
3+
.idea/**/tasks.xml
4+
.idea/**/encodings.xml
5+
.idea/**/compiler.xml
6+
.idea/**/misc.xml
7+
.idea/**/modules.xml
8+
.idea/**/vcs.xml
9+
10+
## File-based project format:
11+
*.iws
12+
*.iml
13+
.idea/
14+
15+
# Binaries for programs and plugins
16+
*.exe
17+
*.exe~
18+
*.dll
19+
*.so
20+
*.dylib
21+
*.dat
22+
*.DS_Store
23+
**/bin/**
24+
25+
# Test binary, built with `go test -c`
26+
*.test
27+
28+
# Output of the go coverage tool, specifically when used with LiteIDE
29+
*.out
30+
31+
# Goreleaser builds
32+
**/dist/**
33+
34+
# This is my wip ideas folder
35+
experiments/**
36+
37+
# Dotenv files
38+
.env
39+
**/*.env
40+
41+
# Secrets files
42+
**/password.txt
43+
**/token.txt
44+
45+
# Crossplane stuffs
46+
/.cache
47+
/.work
48+
/_output
49+
cover.out
50+
/vendor
51+
/.vendor-new
52+
.tool-versions
53+
**/*.xpkg
54+
.vscode

.ko.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
builds:
2+
- id: composition-dynamic-controller-v2
3+
#main: main.go
4+
dir: .
5+
env:
6+
- CGO_ENABLED=0
7+
ldflags:
8+
- -s -w
9+
- -extldflags "-static"
10+
defaultPlatforms:
11+
- linux/arm64
12+
#- linux/amd64

Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build environment
2+
# -----------------
3+
FROM golang:1.22.3-bullseye as builder
4+
LABEL stage=builder
5+
6+
ARG DEBIAN_FRONTEND=noninteractive
7+
8+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9+
# hadolint ignore=DL3008
10+
RUN apt-get update && apt-get install -y ca-certificates openssl git tzdata && \
11+
update-ca-certificates && \
12+
rm -rf /var/lib/apt/lists/*
13+
14+
WORKDIR /src
15+
16+
COPY go.mod go.mod
17+
COPY go.sum go.sum
18+
# cache deps before building and copying source so that we don't need to re-download as much
19+
# and so that source changes don't invalidate our downloaded layer
20+
RUN go mod download
21+
22+
# COPY apis/ apis/
23+
COPY internal/ internal/
24+
COPY main.go main.go
25+
26+
# Build
27+
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o /bin/controller ./main.go && \
28+
strip /bin/controller
29+
30+
# Deployment environment
31+
# ----------------------
32+
FROM gcr.io/distroless/static:nonroot
33+
34+
# COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
35+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
36+
37+
COPY --from=builder /bin/controller /bin/controller
38+
39+
USER nonroot:nonroot
40+
41+
ENTRYPOINT ["/bin/controller"]

0 commit comments

Comments
 (0)