Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: "1.20"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
version: v1.51.1
2 changes: 1 addition & 1 deletion .github/workflows/kustomize-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
uses: actions/checkout@v3
- uses: imranismail/setup-kustomize@v1
with:
kustomize-version: 4.5.2
kustomize-version: 5.0.0
- run: |
./hack/validate-kustomize.sh
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: "1.20"
- run: make test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.19 as builder
FROM --platform=$BUILDPLATFORM golang:1.20 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
43 changes: 27 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APINETLET_IMG ?= apinetlet:latest
KIND_CLUSTER_NAME ?= kind

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.2
ENVTEST_K8S_VERSION = 1.26.1

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -51,33 +51,30 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: addlicense
addlicense: ## Add license headers to all go files.
find . -name '*.go' -exec go run github.com/google/addlicense -c 'OnMetal authors' {} +
.PHONY: add-license
add-license: addlicense ## Add license headers to all go files.
find . -name '*.go' -exec $(ADDLICENSE) -c 'OnMetal authors' {} +

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
fmt: goimports ## Run goimports against code.
$(GOIMPORTS) -w .

.PHONY: checklicense
checklicense: ## Check that every file has a license header present.
find . -name '*.go' -exec go run github.com/google/addlicense -check -c 'OnMetal authors' {} +
.PHONY: check-license
check-license: addlicense ## Check that every file has a license header present.
find . -name '*.go' -exec $(ADDLICENSE) -check -c 'OnMetal authors' {} +

.PHONY: lint
lint: ## Run golangci-lint against code.
golangci-lint run ./...

.PHONY: check
check: manifests generate addlicense lint test
check: manifests generate add-license fmt lint test ## Lint and run tests.

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
.PHONY: test
test: envtest generate fmt checklicense ## Run tests.
test: envtest generate fmt check-license ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

.PHONY: check
check: lint test ## Lint and run tests.

##@ Build

.PHONY: build-onmetal-api-net
Expand Down Expand Up @@ -238,10 +235,14 @@ $(LOCALBIN):
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
ADDLICENSE ?= $(LOCALBIN)/addlicense
GOIMPORTS ?= $(LOCALBIN)/goimports

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.2
CONTROLLER_TOOLS_VERSION ?= v0.9.0
KUSTOMIZE_VERSION ?= v5.0.0
CONTROLLER_TOOLS_VERSION ?= v0.11.3
ADDLICENSE_VERSION ?= v1.1.0
GOIMPORTS_VERSION ?= v0.5.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand All @@ -253,6 +254,11 @@ $(KUSTOMIZE): $(LOCALBIN)
fi
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

.PHONY: addlicense
addlicense: $(ADDLICENSE) ## Download addlicense locally if necessary.
$(ADDLICENSE): $(LOCALBIN)
test -s $(LOCALBIN)/addlicense || GOBIN=$(LOCALBIN) go install github.com/google/addlicense@$(ADDLICENSE_VERSION)

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
Expand All @@ -262,3 +268,8 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

.PHONY: goimports
goimports: $(GOIMPORTS) ## Download goimports locally if necessary.
$(GOIMPORTS): $(LOCALBIN)
test -s $(LOCALBIN)/goimports || GOBIN=$(LOCALBIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)
8 changes: 3 additions & 5 deletions apinetlet/controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/onmetal/controller-utils/modutils"
onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/testutils/envtestutils"
"github.com/onmetal/onmetal-api/testutils/envtestutils/apiserver"
envtestutils "github.com/onmetal/onmetal-api/utils/envtest"
"github.com/onmetal/onmetal-api/utils/envtest/apiserver"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -61,8 +61,6 @@ const (
)

func TestControllers(t *testing.T) {
_, reporterConfig := GinkgoConfiguration()
reporterConfig.SlowSpecThreshold = 10 * time.Second
SetDefaultConsistentlyPollingInterval(pollingInterval)
SetDefaultEventuallyPollingInterval(pollingInterval)
SetDefaultEventuallyTimeout(eventuallyTimeout)
Expand Down Expand Up @@ -105,7 +103,7 @@ var _ = BeforeSuite(func() {
SetClient(k8sClient)

apiSrv, err := apiserver.New(cfg, apiserver.Options{
MainPath: "github.com/onmetal/onmetal-api/onmetal-apiserver/cmd/apiserver",
MainPath: "github.com/onmetal/onmetal-api/cmd/onmetal-apiserver",
BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod},
ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()},
Host: testEnvExt.APIServiceInstallOptions.LocalServingHost,
Expand Down
2 changes: 1 addition & 1 deletion apinetlet/controllers/loadbalancer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/predicates"
"github.com/onmetal/onmetal-api/utils/predicates"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions apinetlet/controllers/loadbalancer_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -33,7 +33,7 @@ import (
)

var _ = Describe("LoadBalancerController", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns := SetupTest(ctx)

It("should allocate a public ip", func() {
Expand Down
2 changes: 1 addition & 1 deletion apinetlet/controllers/natgateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/predicates"
"github.com/onmetal/onmetal-api/utils/predicates"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions apinetlet/controllers/natgateway_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -33,7 +33,7 @@ import (
)

var _ = Describe("NATGatewayController", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns := SetupTest(ctx)

It("should allocate a public ip", func() {
Expand Down
2 changes: 1 addition & 1 deletion apinetlet/controllers/network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1"
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/predicates"
"github.com/onmetal/onmetal-api/utils/predicates"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
4 changes: 2 additions & 2 deletions apinetlet/controllers/network_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
onmetalapinetv1alpha1 "github.com/onmetal/onmetal-api-net/api/v1alpha1"
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -32,7 +32,7 @@ import (
)

var _ = Describe("NetworkController", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns := SetupTest(ctx)
const vni int32 = 4

Expand Down
2 changes: 1 addition & 1 deletion apinetlet/controllers/virtualip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/apiutils/predicates"
"github.com/onmetal/onmetal-api/utils/predicates"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
4 changes: 2 additions & 2 deletions apinetlet/controllers/virtualip_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
apinetletv1alpha1 "github.com/onmetal/onmetal-api-net/apinetlet/api/v1alpha1"
commonv1alpha1 "github.com/onmetal/onmetal-api/api/common/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/api/networking/v1alpha1"
"github.com/onmetal/onmetal-api/testutils"
. "github.com/onmetal/onmetal-api/utils/testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -30,7 +30,7 @@ import (
)

var _ = Describe("VirtualIPController", func() {
ctx := testutils.SetupContext()
ctx := SetupContext()
ns := SetupTest(ctx)

It("should allocate a public ip", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: networks.apinet.api.onmetal.de
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
controller-gen.kubebuilder.io/version: v0.11.3
creationTimestamp: null
name: publicips.apinet.api.onmetal.de
spec:
Expand Down
Loading