Skip to content

Commit

Permalink
project: kubebuilder layout v3 -> v4
Browse files Browse the repository at this point in the history
We have no good reason to get stuck on layout v3 and
make our time harder when consuming upcoming changes and fixes.

Most of the changes here stem from the fact we change
the path of the API package.
We also consume as much as possible from the new Makefile features.

done using https://book.kubebuilder.io/migration/migration_guide_gov3_to_gov4

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Jan 27, 2025
1 parent b11e8b5 commit 643c760
Show file tree
Hide file tree
Showing 118 changed files with 447 additions and 303 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Kubebuilder DevContainer",
"image": "docker.io/golang:1.23",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/git:1": {}
},

"runArgs": ["--network=host"],

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-azuretools.vscode-docker"
]
}
},

"onCreateCommand": "bash .devcontainer/post-install.sh"
}

23 changes: 23 additions & 0 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -x

curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
mv ./kind /usr/local/bin/kind

curl -L -o kubebuilder https://go.kubebuilder.io/dl/latest/linux/amd64
chmod +x kubebuilder
mv kubebuilder /usr/local/bin/

KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
curl -LO "https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/kubectl

docker network create -d=bridge --subnet=172.19.0.0/24 kind

kind version
kubebuilder version
docker --version
go version
kubectl version --client
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ jobs:
go-version: ${{ env.GOLANG_VERSION }}

- name: Run Linter
run: make golangci-lint
run: make lint
29 changes: 0 additions & 29 deletions .github/workflows/golangci-lint.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
bin/*
testbin/*
Dockerfile.cross

# Test binary, build with `go test -c`
# Test binary, built with `go test -c`
*.test

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

# Kubernetes Generated files - skip generated files, except for vendored files
# Go workspace file
go.work

# Kubernetes Generated files - skip generated files, except for vendored files
!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
Expand Down
36 changes: 31 additions & 5 deletions .golangci.yaml → .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,40 @@ run:
concurrency: 4
timeout: 5m
tests: true
skip-dirs:
modules-download-mode: vendor
issues:
exclude-dirs:
- vendor
- test/utils/k8simported
modules-download-mode: vendor
- pkg/version
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
- path: "api/*"
linters:
- lll
- path: "internal/*"
linters:
- dupl
- lll
- path: "test/e2e/serial/*"
linters:
- dupl
- lll
- path: "test/utils/*"
linters:
- dupl
- lll
linters:
disable-all: true
enable:
- errcheck
# - errcheck
- bodyclose
- exportloopref
# - copyloopvar
- depguard
- gosimple
- govet
- ineffassign
Expand All @@ -25,8 +49,10 @@ linters:
- unused
- wastedassign
- whitespace
- depguard
linters-settings:
revive:
rules:
- name: comment-spacings
misspell:
locale: US
ignore-words:
Expand Down
6 changes: 3 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ is derived by the controller-gen/operator-sdk/kubebuilder tooling.

The master source is the set of annotated go types.

The main content is `api/numaresourcesoperator` whose subfolders hold the versioned api:
The main content is `api` whose subfolders hold the versioned api:
`v1alpha1`, `v1`...

The top-level api packages (`api/numaresourcesoperator/v1`) should have minimal deps: they
The top-level api packages (`api/v1`) should have minimal deps: they
should depend only on
1. stdlib
2. other API packages (e.g. k8s, ocp)

We add helper packages which build on top of api packages and provide utilities: they sit in
`api/numaresources/$VERSION/helper/$HELPER/...` and these packages *can* have more dependencies.
`api/$VERSION/helper/$HELPER/...` and these packages *can* have more dependencies.

NOTE: helper packages can depend on top-level api packages, but top-level api packages **must not**
depend on helpers. Keep the top-level dependencies minimal and controlled!
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.bundle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.36.1
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
Expand Down
Loading

0 comments on commit 643c760

Please sign in to comment.