Skip to content

Commit 18afc2f

Browse files
Eneman DonatienEneman Donatien
authored andcommitted
[ENH] ✨ add s3instance object + update deps + unitest + chart in repo + refacto
1 parent a683dec commit 18afc2f

File tree

103 files changed

+9516
-2033
lines changed

Some content is hidden

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

103 files changed

+9516
-2033
lines changed

.github/workflows/ci-chart.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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/[email protected]
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/[email protected]
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/[email protected]
48+
49+
- name: Configure Git
50+
run: |
51+
git config user.name "$GITHUB_ACTOR"
52+
git config user.email "[email protected]"
53+
54+
- name: Run chart-releaser
55+
uses: helm/[email protected]
56+
with:
57+
charts_dir: deploy/charts
58+
skip_existing: true
59+
env:
60+
CR_TOKEN: "${{ secrets.CR_TOKEN }}"
Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,69 @@
1-
on: [push]
2-
name: build
3-
jobs:
4-
build:
1+
name: Docker 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+
lint-docker:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- uses: hadolint/[email protected]
23+
with:
24+
dockerfile: Dockerfile
25+
26+
build-docker:
527
outputs:
628
version: ${{ steps.get_version.outputs.VERSION }}
729
runs-on: ubuntu-latest
830
steps:
931
- name: Checkout code
1032
uses: actions/checkout@v4
33+
1134
- name: Docker meta
1235
id: docker_meta
13-
uses: crazy-max/ghaction-docker-meta@v5.1.0
36+
uses: docker/metadata-action@v5
1437
with:
1538
images: inseefrlab/s3-operator # list of Docker images to use as base name for tags
39+
tags: |
40+
type=ref,event=branch
41+
type=ref,event=pr
42+
type=semver,pattern={{version}}
43+
type=semver,pattern={{major}}.{{minor}}
44+
1645
- name: Set up QEMU
1746
uses: docker/setup-qemu-action@v3
47+
1848
- name: Set up Docker Buildx
1949
uses: docker/setup-buildx-action@v3
50+
2051
- name: Login to DockerHub
2152
if: github.event_name != 'pull_request'
2253
uses: docker/login-action@v3
2354
with:
2455
username: ${{ secrets.DOCKERHUB_USERNAME }}
2556
password: ${{ secrets.DOCKERHUB_TOKEN }}
57+
2658
- name: Build and push
27-
uses: docker/build-push-action@v5
59+
uses: docker/build-push-action@v6
2860
with:
2961
context: .
3062
file: ./Dockerfile
3163
push: ${{ github.event_name != 'pull_request' }}
32-
# Use tags computed before and also latest if on master
64+
# Use tags computed before
3365
tags: |
3466
${{ steps.docker_meta.outputs.tags }}
35-
${{ github.ref == 'refs/heads/main' && 'inseefrlab/s3-operator:latest' || '' }}
3667
labels: ${{ steps.docker_meta.outputs.labels }}
3768
platforms: linux/amd64,linux/arm64
3869
- name: Image digest

.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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ Dockerfile.cross
2424
*.swp
2525
*.swo
2626
*~
27-
.vscode
27+
.vscode
28+
29+
values-local.yaml

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.22 as builder
2+
FROM golang:1.23 as builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -12,16 +12,17 @@ COPY go.sum go.sum
1212
RUN go mod download
1313

1414
# Copy the go source
15-
COPY main.go main.go
15+
COPY cmd/main.go cmd/main.go
1616
COPY api/ api/
17-
COPY controllers/ controllers/
17+
COPY internal/ internal/
18+
1819

1920
# Build
2021
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2122
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2223
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2324
# 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 main.go
25+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
2526

2627
# Use distroless as minimal base image to package the manager binary
2728
# Refer to https://github.com/GoogleContainerTools/distroless for more details

LICENSE

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
MIT License
1+
Copyright 2023.
22

3-
Copyright (c) 2023 InseeFrLab
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
46

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:
7+
http://www.apache.org/licenses/LICENSE-2.0
118

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

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ endif
4848

4949
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51-
OPERATOR_SDK_VERSION ?= v1.32.0
51+
OPERATOR_SDK_VERSION ?= v1.39.1
5252

5353
# Image URL to use all building/pushing image targets
5454
IMG ?= controller:latest
5555
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
56-
ENVTEST_K8S_VERSION = 1.26.0
56+
ENVTEST_K8S_VERSION = 1.32.0
5757

5858
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
5959
ifeq (,$(shell go env GOBIN))
@@ -113,11 +113,11 @@ test: manifests generate fmt vet envtest ## Run tests.
113113

114114
.PHONY: build
115115
build: manifests generate fmt vet ## Build manager binary.
116-
go build -o bin/manager main.go
116+
go build -o bin/manager cmd/main.go
117117

118118
.PHONY: run
119119
run: manifests generate fmt vet ## Run a controller from your host.
120-
go run ./main.go
120+
go run ./cmd/main.go
121121

122122
# If you wish built the manager image targeting other platforms you can use the --platform flag.
123123
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
@@ -184,7 +184,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
184184

185185
## Tool Versions
186186
KUSTOMIZE_VERSION ?= v3.8.7
187-
CONTROLLER_TOOLS_VERSION ?= v0.14.0
187+
CONTROLLER_TOOLS_VERSION ?= v0.17.1
188188

189189
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
190190
.PHONY: kustomize
@@ -279,3 +279,7 @@ catalog-build: opm ## Build a catalog image.
279279
.PHONY: catalog-push
280280
catalog-push: ## Push a catalog image.
281281
$(MAKE) docker-push IMG=$(CATALOG_IMG)
282+
283+
.PHONY: go-unittest
284+
go-unittest: ## Build the bundle image.
285+
go test -v ./...

PROJECT

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# More info: https://book.kubebuilder.io/reference/project-config.html
55
domain: onyxia.sh
66
layout:
7-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
88
plugins:
99
manifests.sdk.operatorframework.io/v2: {}
1010
scorecard.sdk.operatorframework.io/v2: {}
@@ -38,4 +38,22 @@ resources:
3838
kind: Path
3939
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
4040
version: v1alpha1
41+
- api:
42+
crdVersion: v1
43+
namespaced: true
44+
controller: true
45+
domain: onyxia.sh
46+
group: s3.onyxia.sh
47+
kind: S3instance
48+
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
49+
version: v1alpha1
50+
- api:
51+
crdVersion: v1
52+
namespaced: true
53+
controller: true
54+
domain: onyxia.sh
55+
group: s3.onyxia.sh
56+
kind: S3User
57+
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
58+
version: v1alpha1
4159
version: "3"

0 commit comments

Comments
 (0)