Skip to content

Commit dbb3b6e

Browse files
authored
refactor(operator)!: Migrate project layout to kubebuilder go/v4 (#14447)
1 parent d78b7ab commit dbb3b6e

File tree

108 files changed

+2145
-1859
lines changed

Some content is hidden

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

108 files changed

+2145
-1859
lines changed

‎operator/.bingo/Variables.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ $(KIND): $(BINGO_DIR)/kind.mod
7777
@echo "(re)installing $(GOBIN)/kind-v0.23.0"
7878
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kind.mod -o=$(GOBIN)/kind-v0.23.0 "sigs.k8s.io/kind"
7979

80-
KUSTOMIZE := $(GOBIN)/kustomize-v4.5.7
80+
KUSTOMIZE := $(GOBIN)/kustomize-v5.4.3
8181
$(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
8282
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
83-
@echo "(re)installing $(GOBIN)/kustomize-v4.5.7"
84-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v4.5.7 "sigs.k8s.io/kustomize/kustomize/v4"
83+
@echo "(re)installing $(GOBIN)/kustomize-v5.4.3"
84+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v5.4.3 "sigs.k8s.io/kustomize/kustomize/v5"
8585

8686
OPERATOR_SDK := $(GOBIN)/operator-sdk-v1.37.0
8787
$(OPERATOR_SDK): $(BINGO_DIR)/operator-sdk.mod

‎operator/.bingo/kustomize.mod

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.17
3+
go 1.22.5
44

5-
exclude sigs.k8s.io/kustomize/api v0.2.0
6-
7-
exclude sigs.k8s.io/kustomize/cmd/config v0.2.0
8-
9-
require sigs.k8s.io/kustomize/kustomize/v4 v4.5.7
5+
require sigs.k8s.io/kustomize/kustomize/v5 v5.4.3

‎operator/.bingo/kustomize.sum

Lines changed: 58 additions & 413 deletions
Large diffs are not rendered by default.

‎operator/.bingo/operator-sdk.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.22.8
3+
go 1.22.5
44

55
require github.com/operator-framework/operator-sdk v1.37.0 // cmd/operator-sdk

‎operator/.bingo/variables.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ JSONNETFMT="${GOBIN}/jsonnetfmt-v0.20.0"
2828

2929
KIND="${GOBIN}/kind-v0.23.0"
3030

31-
KUSTOMIZE="${GOBIN}/kustomize-v4.5.7"
31+
KUSTOMIZE="${GOBIN}/kustomize-v5.4.3"
3232

3333
OPERATOR_SDK="${GOBIN}/operator-sdk-v1.37.0"
3434

‎operator/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ FROM golang:1.22.8 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
6-
COPY apis/ apis/
6+
COPY api/ api/
77
COPY go.mod go.mod
88
COPY go.sum go.sum
99
# cache deps before building and copying source so that we don't need to re-download as much
1010
# and so that source changes don't invalidate our downloaded layer
1111
RUN go mod download
1212

1313
# Copy the go source
14-
COPY main.go main.go
15-
COPY controllers/ controllers/
14+
COPY cmd/loki-operator/main.go cmd/loki-operator/main.go
1615
COPY internal/ internal/
1716

1817
# Build
19-
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -mod=readonly -a -o manager main.go
18+
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -mod=readonly -a -o manager cmd/loki-operator/main.go
2019

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

‎operator/Dockerfile.cross

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ FROM --platform=linux/amd64 $BUILD_IMAGE as builder
88
COPY --from=goenv /goarch /goarm /
99
WORKDIR /workspace
1010
# Copy the Go Modules manifests
11-
COPY apis/ apis/
11+
COPY api/ api/
1212
COPY go.mod go.mod
1313
COPY go.sum go.sum
1414
# cache deps before building and copying source so that we don't need to re-download as much
1515
# and so that source changes don't invalidate our downloaded layer
1616
RUN go mod download
1717

1818
# Copy the go source
19-
COPY main.go main.go
20-
COPY controllers/ controllers/
19+
COPY cmd/loki-operator/main.go cmd/loki-operator/main.go
2120
COPY internal/ internal/
2221

2322
# Build
24-
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager main.go
23+
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager cmd/loki-operator/main.go
2524

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

‎operator/Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ deps: go.mod go.sum
126126
go mod verify
127127

128128
.PHONY: deps-api
129-
deps-api: apis/loki/go.mod apis/loki/go.sum
130-
@cd ./apis/loki/ && go mod tidy
131-
@cd ./apis/loki/ && go mod download
132-
@cd ./apis/loki/ && go mod verify
129+
deps-api: api/loki/go.mod api/loki/go.sum
130+
@cd ./api/loki/ && go mod tidy
131+
@cd ./api/loki/ && go mod download
132+
@cd ./api/loki/ && go mod verify
133133

134134
.PHONY: cli
135135
cli: deps bin/loki-broker ## Build loki-broker CLI binary
@@ -138,7 +138,7 @@ bin/loki-broker: $(GO_FILES) | generate
138138

139139
.PHONY: manager
140140
manager: deps generate ## Build manager binary
141-
go build -o bin/manager main.go
141+
go build -o bin/manager ./cmd/loki-operator/main.go
142142

143143
.PHONY: size-calculator
144144
size-calculator: deps generate ## Build size-calculator binary
@@ -163,7 +163,7 @@ test: $(GO_FILES)
163163

164164
.PHONY: test-unit-api
165165
test-unit-api: $(GO_FILES)
166-
@cd ./apis/loki/ && go test ./... -coverprofile cover.out
166+
@cd ./api/loki/ && go test ./... -coverprofile cover.out
167167

168168
.PHONY: test-unit-prometheus
169169
test-unit-prometheus: $(PROMTOOL) ## Run prometheus unit tests
@@ -237,7 +237,7 @@ quickstart-cleanup: $(KIND) ## Cleanup for quickstart set up
237237

238238
.PHONY: run
239239
run: generate manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
240-
go run ./main.go
240+
go run ./cmd/loki-operator/main.go
241241

242242
.PHONY: install
243243
install: manifests $(KUSTOMIZE) ## Install CRDs into a cluster
@@ -312,17 +312,17 @@ oci-push-calculator: ## Push the calculator image
312312
$(OCI_RUNTIME) push $(CALCULATOR_IMG)
313313

314314
##@ Website
315-
TYPES_TARGET := $(shell find apis/loki -type f -iname "*_types.go")
315+
TYPES_TARGET := $(shell find api/loki -type f -iname "*_types.go")
316316
docs/operator/api.md: $(TYPES_TARGET) $(GEN_CRD_API_REFERENCE_DOCS)
317317
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/apis/loki/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
318318
sed -i 's/+docs:/ docs:/' $@
319319
sed -i 's/+parent:/ parent:/' $@
320320
sed -i 's/##/\n##/' $@
321321
sed -i 's/+newline/\n/' $@
322322

323-
FEATURE_GATES_TARGET := $(shell find apis/config -type f -iname "*_types.go")
323+
FEATURE_GATES_TARGET := $(shell find api/config -type f -iname "*_types.go")
324324
docs/operator/feature-gates.md: $(FEATURE_GATES_TARGET) $(GEN_CRD_API_REFERENCE_DOCS)
325-
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/apis/config/v1/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
325+
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir "github.com/grafana/loki/operator/api/config/v1/" -config "$(PWD)/config/docs/config.json" -template-dir "$(PWD)/config/docs/templates" -out-file "$(PWD)/$@"
326326
sed -i 's/title: "API"/title: "Feature Gates"/' $@
327327
sed -i 's/+docs:/ docs:/' $@
328328
sed -i 's/+parent:/ parent:/' $@

‎operator/PROJECT

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
componentConfig: true
22
domain: grafana.com
33
layout:
4-
- go.kubebuilder.io/v3
4+
- go.kubebuilder.io/v4
55
multigroup: true
66
plugins:
77
manifests.sdk.operatorframework.io/v2: {}
@@ -16,7 +16,7 @@ resources:
1616
domain: grafana.com
1717
group: loki
1818
kind: LokiStack
19-
path: github.com/grafana/loki/operator/apis/loki/v1beta1
19+
path: github.com/grafana/loki/operator/api/loki/v1beta1
2020
version: v1beta1
2121
- api:
2222
crdVersion: v1
@@ -25,7 +25,7 @@ resources:
2525
domain: grafana.com
2626
group: loki
2727
kind: LokiStack
28-
path: github.com/grafana/loki/operator/apis/loki/v1
28+
path: github.com/grafana/loki/operator/api/loki/v1
2929
version: v1
3030
webhooks:
3131
conversion: true
@@ -38,7 +38,7 @@ resources:
3838
domain: grafana.com
3939
group: loki
4040
kind: AlertingRule
41-
path: github.com/grafana/loki/operator/apis/loki/v1
41+
path: github.com/grafana/loki/operator/api/loki/v1
4242
version: v1
4343
webhooks:
4444
conversion: true
@@ -51,7 +51,7 @@ resources:
5151
domain: grafana.com
5252
group: loki
5353
kind: AlertingRule
54-
path: github.com/grafana/loki/operator/apis/loki/v1beta1
54+
path: github.com/grafana/loki/operator/api/loki/v1beta1
5555
version: v1beta1
5656
webhooks:
5757
validation: true
@@ -63,7 +63,7 @@ resources:
6363
domain: grafana.com
6464
group: loki
6565
kind: RecordingRule
66-
path: github.com/grafana/loki/operator/apis/loki/v1
66+
path: github.com/grafana/loki/operator/api/loki/v1
6767
version: v1
6868
webhooks:
6969
validation: true
@@ -76,7 +76,7 @@ resources:
7676
domain: grafana.com
7777
group: loki
7878
kind: RecordingRule
79-
path: github.com/grafana/loki/operator/apis/loki/v1beta1
79+
path: github.com/grafana/loki/operator/api/loki/v1beta1
8080
version: v1beta1
8181
webhooks:
8282
validation: true
@@ -88,7 +88,7 @@ resources:
8888
domain: grafana.com
8989
group: loki
9090
kind: RulerConfig
91-
path: github.com/grafana/loki/operator/apis/loki/v1
91+
path: github.com/grafana/loki/operator/api/loki/v1
9292
version: v1
9393
- api:
9494
crdVersion: v1
@@ -97,6 +97,6 @@ resources:
9797
domain: grafana.com
9898
group: loki
9999
kind: RulerConfig
100-
path: github.com/grafana/loki/operator/apis/loki/v1beta1
100+
path: github.com/grafana/loki/operator/api/loki/v1beta1
101101
version: v1beta1
102102
version: "3"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎operator/bundle/community-openshift/bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LABEL operators.operatorframework.io.bundle.channels.v1=alpha
99
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
1010
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-unknown
1111
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
12-
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
12+
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4
1313

1414
# Labels for testing.
1515
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1

0 commit comments

Comments
 (0)