Skip to content

Commit a89038d

Browse files
Eneman DonatienEneman Donatien
authored andcommitted
[ENH] ✨ refacto + update dependencies move to operator sdk v4 + refacto + add unitest
1 parent a665eba commit a89038d

File tree

142 files changed

+9919
-5618
lines changed

Some content is hidden

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

142 files changed

+9919
-5618
lines changed

.dockerignore

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

.github/workflows/ci-chart.yaml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,60 @@
1-
name: Release Helm
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
jobs:
9-
release_helm:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
15-
- name: Install Helm on Runner
16-
uses: azure/setup-helm@v4.2.0
17-
18-
- name: Lint Chart
19-
run: helm lint .
20-
21-
- name: Configure Git
22-
run: |
23-
git config user.name "$GITHUB_ACTOR"
24-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
25-
26-
- name: Run chart-releaser
27-
uses: helm/chart-releaser-action@v1.6.0
28-
with:
29-
charts_dir: deploy/charts
30-
skip_existing: true
31-
env:
32-
CR_TOKEN: "${{ secrets.CR_TOKEN }}"
1+
name: Helm CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
paths-ignore:
8+
- 'docs/**'
9+
tags:
10+
- "*"
11+
pull_request:
12+
paths-ignore:
13+
- 'docs/**'
14+
15+
jobs:
16+
17+
helm-lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Install Helm on Runner
24+
uses: azure/setup-helm@v4.2.0
25+
26+
- name: Lint Chart
27+
run: helm lint .
28+
29+
helm-unitest:
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Install Helm on Runner
35+
uses: azure/setup-helm@v4.2.0
36+
37+
- name: Lint Chart
38+
run: echo "TODO"
39+
40+
release_helm:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Install Helm on Runner
47+
uses: azure/setup-helm@v4.2.0
48+
49+
- name: Configure Git
50+
run: |
51+
git config user.name "$GITHUB_ACTOR"
52+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
53+
54+
- name: Run chart-releaser
55+
uses: helm/chart-releaser-action@v1.6.0
56+
with:
57+
charts_dir: deploy/charts
58+
skip_existing: true
59+
env:
60+
CR_TOKEN: "${{ secrets.CR_TOKEN }}"
Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
name: build
1+
name: Docker CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
paths-ignore:
8+
- 'docs/**'
9+
tags:
10+
- "*"
11+
pull_request:
12+
paths-ignore:
13+
- 'docs/**'
14+
15+
jobs:
416

5-
jobs:
6-
build:
17+
lint-docker:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- uses: hadolint/hadolint-action@v3.1.0
23+
with:
24+
dockerfile: Dockerfile
25+
26+
build-docker:
727
outputs:
828
version: ${{ steps.get_version.outputs.VERSION }}
929
runs-on: ubuntu-latest

.github/workflows/ci-go.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Golang CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
paths-ignore:
8+
- 'docs/**'
9+
tags:
10+
- "*"
11+
pull_request:
12+
paths-ignore:
13+
- 'docs/**'
14+
15+
jobs:
16+
17+
go:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: '1.23.x'
26+
- name: Install dependencies
27+
run: go mod download
28+
- name: Test with Go
29+
run: go test -v ./... -coverprofile cover.out
30+
- name: Upload Go test results
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: coverage
34+
path: cover.out
35+
- name: Build
36+
run: go build -v ./...
37+
- name: 'Upload Artifact'
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: manager
41+
path: ./bin/manager

.github/workflows/release.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: Upload Release Asset
8+
9+
jobs:
10+
upload-release-assets:
11+
name: Upload Release Asset
12+
needs: build-go
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Download a single artifact
18+
uses: actions/download-artifact@v4
19+
with:
20+
name: manager
21+
- name: Create Release
22+
id: create_release
23+
uses: actions/create-release@v1
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
with:
27+
tag_name: ${{ github.ref }}
28+
release_name: Release ${{ github.ref }}
29+
draft: false
30+
prerelease: false
31+
- name: Upload Release Asset
32+
id: upload-release-asset
33+
uses: actions/upload-release-asset@v1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
with:
37+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
38+
asset_path: bin/manager
39+
asset_name: s3-operator
40+
asset_content_type: application/x-executable

.gitignore

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

Dockerfile

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

LICENSE

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
MIT License
2-
3-
Copyright (c) 2023 InseeFrLab
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.
1+
Copyright 2023.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

0 commit comments

Comments
 (0)