Skip to content

Commit

Permalink
Upgrade to latest version of kubebuilder (#29)
Browse files Browse the repository at this point in the history
* controller: move custom logic to another file

This makes it easier to upgrade kubebuilder, as kubebuilder upgrade
requires to manually update the file or regenerate them with the CLI and
integrating our own change in them.

* misc: upgrade to latest version of kubebuilder

- Stop using operator-sdk, as we don't use any of the additional feature
  and it makes it harder to upgrade
- Switch to go/v4 plugin[1]: this change a bit the layout of the
  project. go/v4 is the only supported version and ensure that we will
  support newer version of Go and Kubernetes.
- Enabling the pprof endpoint is now directly part of the manager
- Namespace cannot be specified anymore. This makes the controller watch
  for the CRD in all namespaces. Future changes are needed to support
  managing multiple clusters from the same controller.
- Upgrade gohbase to the latest version available.

[1] https://book.kubebuilder.io/migration/v3vsv4#tldr-of-the-new-gov4-plugin

* controller: fix some linting warning

* cmd/main: add back the --namespace flag
  • Loading branch information
dethi authored Apr 12, 2024
1 parent ba2220b commit 43a961b
Show file tree
Hide file tree
Showing 49 changed files with 8,350 additions and 8,108 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
bin/*
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
*~

testbin/*
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
run:
deadline: 5m
allow-parallel-runners: true

issues:
# 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
linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.21 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand All @@ -12,16 +12,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/controller/ internal/controller/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

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

0 comments on commit 43a961b

Please sign in to comment.