Skip to content

Commit

Permalink
Bump CAPI to v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
haijianyang committed Sep 5, 2023
1 parent 2badee5 commit f16702a
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 415 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v2
- name: Calculate go version
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ env.go_version }}

- run: make lint

- run: make test

- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 8 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ jobs:
fi
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install go
uses: actions/setup-go@v2
- name: Calculate go version
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: ${{ env.go_version }}

- name: Login docker
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.6
1.20.6
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linters:
- bidichk
- contextcheck
- cyclop
- depguard
- dupl
- durationcheck
- errname
Expand Down Expand Up @@ -85,8 +86,6 @@ linters-settings:
alias: ctrlmgr
- pkg: sigs.k8s.io/controller-runtime/pkg/controller/controllerutil
alias: ctrlutil
- pkg: sigs.k8s.io/controller-runtime/pkg/log
alias: ctrllog
# CAPI
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
alias: capiv1
Expand All @@ -104,9 +103,9 @@ linters-settings:
- pkg: github.com/smartxworks/cluster-api-provider-elf/api/v1beta1
alias: capev1
staticcheck:
go: "1.19"
go: "1.20"
stylecheck:
go: "1.19"
go: "1.20"
issues:
max-same-issues: 0
max-issues-per-linter: 0
Expand Down Expand Up @@ -169,6 +168,7 @@ issues:

run:
timeout: 10m
go: "1.20"
skip-files:
- "zz_generated.*\\.go$"
allow-parallel-runners: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.19.6 as builder
FROM golang:1.20.6 as builder
WORKDIR /workspace

# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
Expand Down
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ SHELL := /usr/bin/env bash

.DEFAULT_GOAL := help

#
# Go.
#
GO_VERSION ?= 1.20.6

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -95,19 +100,19 @@ kustomize: ## Download kustomize locally if necessary.

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.11.3)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0)

GINKGO := $(shell pwd)/bin/ginkgo
ginkgo: ## Download ginkgo locally if necessary.
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.9.2)
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.11.0)

KIND := $(shell pwd)/bin/kind
kind: ## Download kind locally if necessary.
$(call go-get-tool,$(KIND),sigs.k8s.io/kind@v0.17.0)
$(call go-get-tool,$(KIND),sigs.k8s.io/kind@v0.20.0)

GOLANGCI_LINT := $(shell pwd)/bin/golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.1)
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3)

## --------------------------------------
## Linting and fixing linter errors
Expand Down Expand Up @@ -255,3 +260,13 @@ docker-push-manifest: ## Push the fat manifest docker image.
docker manifest create --amend $(CONTROLLER_IMG):$(IMAGE_TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(IMAGE_TAG)~g")
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${IMAGE_TAG} ${CONTROLLER_IMG}-$${arch}:${IMAGE_TAG}; done
docker manifest push --purge ${CONTROLLER_IMG}:${IMAGE_TAG}


## --------------------------------------
## Helpers
## --------------------------------------

##@ helpers:

go-version: ## Print the go version we use to compile our binaries and images
@echo $(GO_VERSION)
Empty file added __debug_bin3897299062
Empty file.
1 change: 0 additions & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ spec:
containers:
- args:
- --leader-elect
- --logtostderr
- --v=4
image: docker.io/smartxworks/cape-ip-manager:latest
imagePullPolicy: IfNotPresent
Expand Down
1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
6 changes: 4 additions & 2 deletions controllers/elfmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
capiutil "sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/controller"
ctrlutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -70,7 +71,7 @@ type ElfMachineReconciler struct {
*capecontext.ControllerContext
}

func AddMachineControllerToManager(ctx *capecontext.ControllerManagerContext, mgr ctrlmgr.Manager) error {
func AddMachineControllerToManager(ctx *capecontext.ControllerManagerContext, mgr ctrlmgr.Manager, options controller.Options) error {
var (
controlledType = &capev1.ElfMachine{}
controlledTypeName = reflect.TypeOf(controlledType).Elem().Name()
Expand All @@ -90,7 +91,8 @@ func AddMachineControllerToManager(ctx *capecontext.ControllerManagerContext, mg

return ctrl.NewControllerManagedBy(mgr).
For(controlledType).
WithOptions(controller.Options{MaxConcurrentReconciles: ctx.MaxConcurrentReconciles}).
WithOptions(options).
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ctx.WatchFilterValue)).
Complete(reconciler)
}

Expand Down
8 changes: 0 additions & 8 deletions controllers/elfmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package controllers
import (
"bytes"
goctx "context"
"flag"
"fmt"
"time"

Expand Down Expand Up @@ -59,13 +58,6 @@ var _ = Describe("ElfMachineReconciler", func() {
ctx := goctx.Background()

BeforeEach(func() {
// set log
if err := flag.Set("logtostderr", "false"); err != nil {
_ = fmt.Errorf("Error setting logtostderr flag")
}
if err := flag.Set("v", "6"); err != nil {
_ = fmt.Errorf("Error setting v flag")
}
logBuffer = new(bytes.Buffer)
klog.SetOutput(logBuffer)

Expand Down
23 changes: 20 additions & 3 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package controllers

import (
"flag"
"fmt"
"os"
"testing"
Expand All @@ -25,7 +26,9 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
capecontext "github.com/smartxworks/cluster-api-provider-elf/pkg/context"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"

ipamutil "github.com/smartxworks/cluster-api-provider-elf-static-ip/pkg/ipam/util"
Expand Down Expand Up @@ -55,12 +58,26 @@ func TestMain(m *testing.M) {
}

func setup() {
// set log
klog.InitFlags(nil)
if err := flag.Set("logtostderr", "false"); err != nil {
_ = fmt.Errorf("Error setting logtostderr flag")
}
if err := flag.Set("v", "6"); err != nil {
_ = fmt.Errorf("Error setting v flag")
}
if err := flag.Set("alsologtostderr", "false"); err != nil {
_ = fmt.Errorf("Error setting alsologtostderr flag")
}

testEnv = helpers.NewTestEnvironment()

// Set kubeconfig.
os.Setenv("KUBECONFIG", testEnv.Kubeconfig)

if err := AddMachineControllerToManager(testEnv.GetContext(), testEnv.Manager); err != nil {
controllerOpts := controller.Options{MaxConcurrentReconciles: 10}

if err := AddMachineControllerToManager(testEnv.GetContext(), testEnv.Manager, controllerOpts); err != nil {
panic(fmt.Sprintf("unable to setup ElfMachine controller: %v", err))
}

Expand All @@ -80,7 +97,7 @@ func teardown() {
}
}

func newCtrlContexts(objs ...runtime.Object) *capecontext.ControllerContext {
func newCtrlContexts(objs ...client.Object) *capecontext.ControllerContext {
ctrlMgrContext := fake.NewControllerManagerContext(objs...)
ctrlContext := &capecontext.ControllerContext{
ControllerManagerContext: ctrlMgrContext,
Expand Down
74 changes: 38 additions & 36 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
module github.com/smartxworks/cluster-api-provider-elf-static-ip

go 1.19
go 1.20

require (
github.com/metal3-io/ip-address-manager/api v1.4.1
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
sigs.k8s.io/controller-runtime v0.14.6
github.com/metal3-io/ip-address-manager/api v1.5.0
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
sigs.k8s.io/controller-runtime v0.15.2
)

require (
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.7
github.com/onsi/ginkgo/v2 v2.12.0
github.com/onsi/gomega v1.27.10
github.com/pkg/errors v0.9.1
github.com/smartxworks/cluster-api-provider-elf v1.2.8
golang.org/x/mod v0.10.0
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apiserver v0.26.1
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/cluster-api v1.4.3
github.com/smartxworks/cluster-api-provider-elf v1.3.0-beta.1
github.com/spf13/pflag v1.0.5
golang.org/x/mod v0.12.0
k8s.io/apiextensions-apiserver v0.27.2
k8s.io/apiserver v0.27.2
k8s.io/component-base v0.27.2
k8s.io/klog/v2 v2.90.1
k8s.io/utils v0.0.0-20230209194617-a36077c30491
sigs.k8s.io/cluster-api v1.5.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coredns/caddy v1.1.0 // indirect
github.com/coredns/corefile-migration v1.0.20 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand All @@ -57,47 +59,47 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/smartxworks/cloudtower-go-sdk/v2 v2.0.0-sks1.1-rc.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/cobra v1.7.0 // indirect
go.mongodb.org/mongo-driver v1.11.6 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
golang.org/x/tools v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/cluster-bootstrap v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/cluster-bootstrap v0.27.2 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit f16702a

Please sign in to comment.