Skip to content

Commit 4ad1def

Browse files
authored
Merge pull request #1 from datum-cloud/feat/initdns
feat: dns apis and controllers
2 parents 851233e + a4517ca commit 4ad1def

137 files changed

Lines changed: 11923 additions & 1 deletion

File tree

Some content is hidden

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

.devcontainer/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "Kubebuilder DevContainer",
3+
"image": "golang:1.24",
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+

.devcontainer/post-install.sh

Lines changed: 23 additions & 0 deletions
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

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore everything by default and re-include only needed files
3+
**
4+
5+
# Re-include Go source files (but not *_test.go)
6+
!**/*.go
7+
**/*_test.go
8+
9+
# Re-include Go module files
10+
!go.mod
11+
!go.sum

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Run linter
21+
uses: golangci/golangci-lint-action@v8
22+
with:
23+
version: v2.4.0

.github/workflows/publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
# Trigger on push
5+
push:
6+
# Trigger on all pull requests
7+
pull_request:
8+
# Trigger when a release is published
9+
release:
10+
types: ['published']
11+
12+
jobs:
13+
publish-container-image:
14+
permissions:
15+
id-token: write
16+
contents: read
17+
packages: write
18+
attestations: write
19+
uses: datum-cloud/actions/.github/workflows/publish-docker.yaml@v1.5.1
20+
with:
21+
image-name: dns-operator
22+
secrets: inherit
23+
24+
publish-kustomize-bundles:
25+
permissions:
26+
id-token: write
27+
contents: read
28+
packages: write
29+
uses: datum-cloud/actions/.github/workflows/publish-kustomize-bundle.yaml@v1.5.1
30+
with:
31+
bundle-name: ghcr.io/datum-cloud/dns-operator-kustomize
32+
bundle-path: config
33+
secrets: inherit

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Running Tests
21+
run: |
22+
go mod tidy
23+
make test

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
*.so
99
*.dylib
1010

11+
bin/
12+
vendor/
13+
dist/
14+
dev/
15+
.go-version
16+
config/**/charts
17+
1118
# Test binary, built with `go test -c`
1219
*.test
1320

.golangci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: "2"
2+
run:
3+
allow-parallel-runners: true
4+
linters:
5+
default: none
6+
enable:
7+
- copyloopvar
8+
- dupl
9+
- errcheck
10+
- ginkgolinter
11+
- goconst
12+
- gocyclo
13+
- govet
14+
- ineffassign
15+
- lll
16+
- misspell
17+
- nakedret
18+
- prealloc
19+
- revive
20+
- staticcheck
21+
- unconvert
22+
- unparam
23+
- unused
24+
settings:
25+
revive:
26+
rules:
27+
- name: comment-spacings
28+
- name: import-shadowing
29+
gocyclo:
30+
min-complexity: 70
31+
exclusions:
32+
generated: lax
33+
rules:
34+
- linters:
35+
- lll
36+
path: api/*
37+
- linters:
38+
- dupl
39+
- lll
40+
path: internal/*
41+
paths:
42+
- third_party$
43+
- builtin$
44+
- examples$
45+
formatters:
46+
enable:
47+
- gofmt
48+
- goimports
49+
exclusions:
50+
generated: lax
51+
paths:
52+
- third_party$
53+
- builtin$
54+
- examples$

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build the manager binary
2+
FROM golang:1.24 AS builder
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
WORKDIR /workspace
7+
# Copy the Go Modules manifests
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
# cache deps before building and copying source so that we don't need to re-download as much
11+
# and so that source changes don't invalidate our downloaded layer
12+
RUN go mod download
13+
14+
# Copy the Go source (relies on .dockerignore to filter)
15+
COPY . .
16+
17+
# Build
18+
# the GOARCH has no default value to allow the binary to be built according to the host where the command
19+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
20+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
21+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
22+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
23+
24+
# Use distroless as minimal base image to package the manager binary
25+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
26+
FROM gcr.io/distroless/static:nonroot
27+
WORKDIR /
28+
COPY --from=builder /workspace/manager .
29+
USER 65532:65532
30+
31+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)