Skip to content

Commit da18fac

Browse files
committed
CI Workflows and Operator SDK init
Signed-off-by: Lucifergene <[email protected]>
1 parent cd0ddc9 commit da18fac

Some content is hidden

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

51 files changed

+2555
-2
lines changed

.dockerignore

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

.github/workflows/main.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
on:
2+
pull_request:
3+
branches: [ main ]
4+
push:
5+
branches: [ main ]
6+
7+
name: build-test-lint
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: 1.21
18+
cache: true
19+
check-latest: true
20+
- name: Set up ko
21+
uses: ko-build/[email protected]
22+
env:
23+
KO_DOCKER_REPO: quay.io/avik6028
24+
- name: Lint
25+
run: make lint
26+
- name: Build
27+
env:
28+
auth_token: ${{ secrets.QUAY_AUTH_TOKEN }}
29+
run: |
30+
echo "${auth_token}" | ko login quay.io --username ${{ secrets.QUAY_USER_NAME }} --password-stdin
31+
make container-build
32+
- name: Test
33+
run: make test
34+
- name: Push
35+
env:
36+
auth_token: ${{ secrets.QUAY_AUTH_TOKEN }}
37+
run: |
38+
echo "${auth_token}" | ko login quay.io --username ${{ secrets.QUAY_USER_NAME }} --password-stdin
39+
make container-push
40+
41+

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@
77
*.dll
88
*.so
99
*.dylib
10+
bin
11+
testbin/
12+
13+
# OS specific files
14+
**/.DS_Store
1015

1116
# Test binary, built with `go test -c`
1217
*.test
1318

1419
# Output of the go coverage tool, specifically when used with LiteIDE
1520
*.out
1621

22+
# Kubernetes Generated files - skip generated files, except for vendored files
23+
24+
!vendor/**/zz_generated.*
25+
1726
# Dependency directories (remove the comment below to include it)
1827
# vendor/
1928

2029
# Go workspace file
2130
go.work
2231
go.work.sum
32+
33+
# Output directory for tests
34+
_output/

.golangci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
run:
2+
deadline: 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+
- exportloopref
25+
- goconst
26+
- gocyclo
27+
- gofmt
28+
- goimports
29+
- gosimple
30+
- govet
31+
- ineffassign
32+
- lll
33+
- misspell
34+
- nakedret
35+
- prealloc
36+
- staticcheck
37+
- typecheck
38+
- unconvert
39+
- unparam
40+
- unused

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.background": "#590941",
4+
"titleBar.activeBackground": "#7C0C5B",
5+
"titleBar.activeForeground": "#FFFBFE"
6+
}
7+
}

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Build the manager binary
2+
FROM golang:1.20 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
15+
COPY cmd/main.go cmd/main.go
16+
COPY api/ api/
17+
COPY internal/controller/ internal/controller/
18+
19+
# Build
20+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
21+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
22+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
23+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
25+
26+
# Use distroless as minimal base image to package the manager binary
27+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
28+
FROM gcr.io/distroless/static:nonroot
29+
WORKDIR /
30+
COPY --from=builder /workspace/manager .
31+
USER 65532:65532
32+
33+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)