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
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Proposed Changes

-
-
-

Fixes #
16 changes: 0 additions & 16 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ categories:
labels:
- 'feature'
- 'enhancement'
- 'compute'
- 'networking'
- 'storage'
- 'api-change'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
Expand All @@ -35,18 +31,6 @@ version-resolver:
exclude-labels:
- 'skip-changelog'
autolabeler:
- label: 'api-change'
files:
- '/apis/*'
- label: 'compute'
files:
- '/controllers/compute/*'
- label: 'storage'
files:
- '/controllers/storage/*'
- label: 'networking'
files:
- '/controllers/networking/*'
- label: 'documentation'
files:
- '*.md'
Expand Down
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.17'
go-version: 1.19
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.43.0
version: v1.49.0
1 change: 1 addition & 0 deletions .github/workflows/kustomize-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

jobs:
kustomize-validation:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
Expand Down
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.17'
go-version: 1.19
- run: make test
21 changes: 21 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
run:
timeout: 3m

linters:
enable:
- revive
- ineffassign
- misspell
- goimports
- importas

severity:
default-severity: error

linters-settings:
revive:
severity: error
rules:
- name: exported
- name: if-return
disabled: true
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.17 as builder
FROM --platform=$BUILDPLATFORM golang:1.19.0 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
64 changes: 36 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"

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

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -38,8 +39,8 @@ help: ## Display this help.
##@ Development

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/onmetal-api-net/crd/bases output:rbac:artifacts:config=config/onmetal-api-net/rbac
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/onmetal-api-net/crd/bases output:rbac:artifacts:config=config/proxyonmetal-api-net/rbac
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:rbac:artifacts:config=config/onmetal-api-net/rbac
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:rbac:artifacts:config=config/proxyonmetal-api-net/rbac

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand All @@ -60,10 +61,9 @@ lint: ## Run golangci-lint against code.
check: manifests generate addlicense lint test

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: manifests generate fmt checklicense ## Run tests.
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out
.PHONY: test
test: envtest generate fmt checklicense ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

check: lint test ## Lint and run tests.

Expand Down Expand Up @@ -96,26 +96,34 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -

##@ Tools

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2)
## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.0

KUSTOMIZE = $(shell pwd)/bin/kustomize
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.4.1)

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
1 change: 0 additions & 1 deletion config/onmetal-api-net/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
1 change: 0 additions & 1 deletion config/proxyonmetal-api-net/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
26 changes: 11 additions & 15 deletions controllers/networking/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import (
"testing"
"time"

"github.com/onmetal/controller-utils/buildutils"
"github.com/onmetal/controller-utils/modutils"
"github.com/onmetal/onmetal-api-net/allocator"
. "github.com/onmetal/onmetal-api-net/controllers/networking"
"github.com/onmetal/onmetal-api-net/internal/apiserverbin"

"github.com/onmetal/controller-utils/modutils"
networkingv1alpha1 "github.com/onmetal/onmetal-api/apis/networking/v1alpha1"
"github.com/onmetal/onmetal-api/envtestutils"
"github.com/onmetal/onmetal-api/envtestutils/apiserver"
Expand Down Expand Up @@ -99,21 +98,18 @@ var _ = BeforeSuite(func() {
SetClient(k8sClient)

apiSrv, err := apiserver.New(cfg, apiserver.Options{
Command: []string{apiserverbin.Path},
ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()},
Host: testEnvExt.APIServiceInstallOptions.LocalServingHost,
Port: testEnvExt.APIServiceInstallOptions.LocalServingPort,
CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir,
MainPath: "github.com/onmetal/onmetal-api/cmd/apiserver",
BuildOptions: []buildutils.BuildOption{buildutils.ModModeMod},
ETCDServers: []string{testEnv.ControlPlane.Etcd.URL.String()},
Host: testEnvExt.APIServiceInstallOptions.LocalServingHost,
Port: testEnvExt.APIServiceInstallOptions.LocalServingPort,
CertDir: testEnvExt.APIServiceInstallOptions.LocalServingCertDir,
})
Expect(err).NotTo(HaveOccurred())

ctx, cancel := context.WithCancel(context.Background())
DeferCleanup(cancel)
go func() {
defer GinkgoRecover()
err := apiSrv.Start(ctx)
Expect(err).NotTo(HaveOccurred())
}()
By("starting the onmetal-api aggregated api server")
Expect(apiSrv.Start()).To(Succeed())
DeferCleanup(apiSrv.Stop)

Expect(envtestutils.WaitUntilAPIServicesReadyWithTimeout(apiServiceTimeout, testEnvExt, k8sClient, scheme.Scheme)).To(Succeed())
})
Expand Down
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
module github.com/onmetal/onmetal-api-net

go 1.17
go 1.19

require (
github.com/go-logr/logr v1.2.3
github.com/golang/mock v1.6.0
github.com/google/addlicense v1.0.0
github.com/onmetal/controller-utils v0.6.0
github.com/onmetal/onmetal-api v0.0.13-0.20220624135223-c6078a32b572
github.com/onmetal/controller-utils v0.6.3
github.com/onmetal/onmetal-api v0.0.13-0.20220824093154-5a28b83e9d98
github.com/onmetal/poollet v0.0.0-20220622125814-30ac89d67f0b
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/onsi/gomega v1.20.0
github.com/spf13/pflag v1.0.5
inet.af/netaddr v0.0.0-20210903134321-85fa6c94624e
k8s.io/api v0.24.1
k8s.io/apimachinery v0.24.1
k8s.io/client-go v0.24.1
sigs.k8s.io/controller-runtime v0.12.2-0.20220525133844-d15de977569f
k8s.io/api v0.24.3
k8s.io/apimachinery v0.24.3
k8s.io/client-go v0.24.3
sigs.k8s.io/controller-runtime v0.12.3
)

require (
Expand Down Expand Up @@ -61,35 +61,35 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0 // indirect
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.24.1 // indirect
k8s.io/component-base v0.24.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.3 // indirect
k8s.io/component-base v0.24.3 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-aggregator v0.24.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/kube-aggregator v0.24.3 // indirect
k8s.io/kube-openapi v0.0.0-20220401212409-b28bf2818661 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading