Skip to content

Commit f26e4f5

Browse files
committed
move to operator sdk v4 + refacto + add unitest
1 parent 7e47a67 commit f26e4f5

Some content is hidden

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

48 files changed

+1348
-1109
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY go.sum go.sum
1212
RUN go mod download
1313

1414
# Copy the go source
15-
COPY cmd/main.go main.go
15+
COPY cmd/main.go cmd/main.go
1616
COPY api/ api/
1717
COPY controllers/ controllers/
1818
COPY internal/ internal/
@@ -23,7 +23,7 @@ COPY internal/ internal/
2323
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2424
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2525
# 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
26+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
2727

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

Makefile

Lines changed: 5 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.11.1
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

PROJECT

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,59 @@
1-
# Code generated by tool. DO NOT EDIT.
2-
# This file is used to track the info used to scaffold your project
3-
# and allow the plugins properly work.
4-
# More info: https://book.kubebuilder.io/reference/project-config.html
5-
domain: onyxia.sh
6-
layout:
7-
- go.kubebuilder.io/v3
8-
plugins:
9-
manifests.sdk.operatorframework.io/v2: {}
10-
scorecard.sdk.operatorframework.io/v2: {}
11-
projectName: s3-operator
12-
repo: github.com/InseeFrLab/s3-operator
13-
resources:
14-
- api:
15-
crdVersion: v1
16-
namespaced: true
17-
controller: true
18-
domain: onyxia.sh
19-
group: s3.onyxia.sh
20-
kind: Bucket
21-
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
22-
version: v1alpha1
23-
- api:
24-
crdVersion: v1
25-
namespaced: true
26-
controller: true
27-
domain: onyxia.sh
28-
group: s3.onyxia.sh
29-
kind: Policy
30-
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
31-
version: v1alpha1
32-
- api:
33-
crdVersion: v1
34-
namespaced: true
35-
controller: true
36-
domain: onyxia.sh
37-
group: s3.onyxia.sh
38-
kind: Path
39-
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
40-
version: v1alpha1
41-
version: "3"
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
5+
domain: onyxia.sh
6+
layout:
7+
- go.kubebuilder.io/v4
8+
plugins:
9+
manifests.sdk.operatorframework.io/v2: {}
10+
scorecard.sdk.operatorframework.io/v2: {}
11+
projectName: s3-operator
12+
repo: github.com/InseeFrLab/s3-operator
13+
resources:
14+
- api:
15+
crdVersion: v1
16+
namespaced: true
17+
controller: true
18+
domain: onyxia.sh
19+
group: s3.onyxia.sh
20+
kind: Bucket
21+
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
22+
version: v1alpha1
23+
- api:
24+
crdVersion: v1
25+
namespaced: true
26+
controller: true
27+
domain: onyxia.sh
28+
group: s3.onyxia.sh
29+
kind: Policy
30+
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
31+
version: v1alpha1
32+
- api:
33+
crdVersion: v1
34+
namespaced: true
35+
controller: true
36+
domain: onyxia.sh
37+
group: s3.onyxia.sh
38+
kind: Path
39+
path: github.com/InseeFrLab/s3-operator/api/v1alpha1
40+
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
59+
version: "3"

api/v1alpha1/bucket_types.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,17 @@ type BucketList struct {
7777
Items []Bucket `json:"items"`
7878
}
7979

80-
func init() {
81-
SchemeBuilder.Register(&Bucket{}, &BucketList{})
82-
}
8380

8481
type Quota struct {
8582
// Default quota to apply, mandatory
8683
// +kubebuilder:validation:Required
8784
Default int64 `json:"default"`
88-
85+
8986
// Optional override quota, to be used by cluster admin.
9087
// +kubebuilder:validation:Optional
9188
Override int64 `json:"override,omitempty"`
9289
}
90+
91+
func init() {
92+
SchemeBuilder.Register(&Bucket{}, &BucketList{})
93+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import (
2727
_ "k8s.io/client-go/plugin/pkg/client/auth"
2828

2929
s3v1alpha1 "github.com/InseeFrLab/s3-operator/api/v1alpha1"
30-
bucketControllers "github.com/InseeFrLab/s3-operator/controllers/bucket"
31-
pathControllers "github.com/InseeFrLab/s3-operator/controllers/path"
32-
policyControllers "github.com/InseeFrLab/s3-operator/controllers/policy"
33-
s3InstanceControllers "github.com/InseeFrLab/s3-operator/controllers/s3instance"
34-
userControllers "github.com/InseeFrLab/s3-operator/controllers/user"
30+
bucketControllers "github.com/InseeFrLab/s3-operator/internal/controller/bucket"
31+
pathControllers "github.com/InseeFrLab/s3-operator/internal/controller/path"
32+
policyControllers "github.com/InseeFrLab/s3-operator/internal/controller/policy"
33+
s3InstanceControllers "github.com/InseeFrLab/s3-operator/internal/controller/s3instance"
34+
userControllers "github.com/InseeFrLab/s3-operator/internal/controller/user"
3535

3636
"go.uber.org/zap/zapcore"
3737
"k8s.io/apimachinery/pkg/runtime"
@@ -64,7 +64,6 @@ func (flags *ArrayFlags) Set(value string) error {
6464

6565
func init() {
6666
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
67-
6867
utilruntime.Must(s3v1alpha1.AddToScheme(scheme))
6968
//+kubebuilder:scaffold:scheme
7069
}

0 commit comments

Comments
 (0)