Skip to content

Commit

Permalink
bump dependencies (#241)
Browse files Browse the repository at this point in the history
* bump all go dependencies

* bump go version to 1.21

* bump envoy to v1.27.0

* bump promtail version to 2.9.0

* bump helm version to 3.12.3

* bump golangci-lint to v1.54.2

* fix manager settings

* fix linting issues

* fix linting issues
  • Loading branch information
dergeberl authored Oct 4, 2023
1 parent df409c4 commit 5474434
Show file tree
Hide file tree
Showing 22 changed files with 250 additions and 204 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ linters:
disable-all: true
enable:
- bodyclose
- depguard
- dogsled
- goconst
- gocritic
Expand Down Expand Up @@ -94,6 +93,7 @@ linters:
# - goerr113 # we have some dynamic errors
# - exhaustive # missing switch case statements
# - asciicheck
# - depguard
# - errcheck # Disabled since it detects defers that do not check errors. This is a standard pattern.
# see https://github.com/kisielk/errcheck/issues/55
# - scopelint
Expand Down
10 changes: 5 additions & 5 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
VERSION 0.6
FROM golang:1.20
FROM golang:1.21
ARG DOCKER_REPO=ghcr.io/stackitcloud/yawol/
ARG BINPATH=/usr/local/bin/
ARG GOCACHE=/go-cache

ARG ENVOY_VERSION=v1.24.7
ARG PROMTAIL_VERSION=2.7.5
ARG HELM_VERSION=3.12.0
ARG GOLANGCI_LINT_VERSION=v1.52.2
ARG ENVOY_VERSION=v1.27.0
ARG PROMTAIL_VERSION=2.9.0
ARG HELM_VERSION=3.12.3
ARG GOLANGCI_LINT_VERSION=v1.54.2
ARG PACKER_VERSION=1.9
ARG TERRAFORM_VERSION=1.4.6

Expand Down
41 changes: 22 additions & 19 deletions cmd/yawol-cloud-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/cache"

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
Expand All @@ -27,6 +27,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -137,9 +138,10 @@ func main() {
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

targetMgr, err := ctrl.NewManager(getConfigFromKubeconfigOrDie(targetKubeconfig), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
},
LeaderElection: targetEnableLeaderElection,
LeaderElectionReleaseOnCancel: true,
LeaderElectionID: "4c878ae2.stackit.cloud",
Expand All @@ -154,10 +156,11 @@ func main() {
}

controlMgr, err := ctrl.NewManager(getConfigFromKubeconfigOrDie(controlKubeconfig), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: "0",
Scheme: scheme,
Cache: cache.Options{
Namespaces: []string{*infrastructureDefaults.Namespace},
DefaultNamespaces: map[string]cache.Config{
*infrastructureDefaults.Namespace: {},
},
},
LeaderElection: controlEnableLeaderElection,
LeaderElectionReleaseOnCancel: true,
Expand Down Expand Up @@ -301,31 +304,31 @@ func getInfrastructureDefaultsFromEnvOrDie() targetcontroller.InfrastructureDefa
}

var flavorID *string
if flavorID = pointer.String(os.Getenv(EnvFlavorID)); *flavorID == "" {
if flavorID = ptr.To(os.Getenv(EnvFlavorID)); *flavorID == "" {
flavorID = nil
}
var flavorName *string
if flavorName = pointer.String(os.Getenv(EnvFlavorName)); *flavorName == "" {
if flavorName = ptr.To(os.Getenv(EnvFlavorName)); *flavorName == "" {
flavorName = nil
}
var flavorSearch *string
if flavorSearch = pointer.String(os.Getenv(EnvFlavorSearch)); *flavorSearch == "" {
if flavorSearch = ptr.To(os.Getenv(EnvFlavorSearch)); *flavorSearch == "" {
flavorSearch = nil
}
if flavorID == nil && flavorName == nil && flavorSearch == nil {
panic("could not read one of envs [" + EnvFlavorID + "," + EnvFlavorName + "," + EnvFlavorSearch + "]")
}

var imageID *string
if imageID = pointer.String(os.Getenv(EnvImageID)); *imageID == "" {
if imageID = ptr.To(os.Getenv(EnvImageID)); *imageID == "" {
imageID = nil
}
var imageName *string
if imageName = pointer.String(os.Getenv(EnvImageName)); *imageName == "" {
if imageName = ptr.To(os.Getenv(EnvImageName)); *imageName == "" {
imageName = nil
}
var imageSearch *string
if imageSearch = pointer.String(os.Getenv(EnvImageSearch)); *imageSearch == "" {
if imageSearch = ptr.To(os.Getenv(EnvImageSearch)); *imageSearch == "" {
imageSearch = nil
}
if imageID == nil && imageName == nil && imageSearch == nil {
Expand All @@ -349,10 +352,10 @@ func getInfrastructureDefaultsFromEnvOrDie() targetcontroller.InfrastructureDefa
}

return targetcontroller.InfrastructureDefaults{
AuthSecretName: pointer.String(authSecretName),
FloatingNetworkID: pointer.String(floatingNetworkID),
NetworkID: pointer.String(networkID),
Namespace: pointer.String(clusterNamespace),
AuthSecretName: ptr.To(authSecretName),
FloatingNetworkID: ptr.To(floatingNetworkID),
NetworkID: ptr.To(networkID),
Namespace: ptr.To(clusterNamespace),
FlavorRef: &yawolv1beta1.OpenstackFlavorRef{
FlavorID: flavorID,
FlavorName: flavorName,
Expand All @@ -363,8 +366,8 @@ func getInfrastructureDefaultsFromEnvOrDie() targetcontroller.InfrastructureDefa
ImageName: imageName,
ImageSearch: imageSearch,
},
AvailabilityZone: pointer.String(availabilityZone),
InternalLB: pointer.Bool(internalLb),
AvailabilityZone: ptr.To(availabilityZone),
InternalLB: ptr.To(internalLb),
}
}

Expand Down
31 changes: 22 additions & 9 deletions cmd/yawol-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
discovery "k8s.io/client-go/discovery"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

"go.uber.org/zap/zapcore"
"golang.org/x/time/rate"
Expand Down Expand Up @@ -152,8 +153,10 @@ func main() {
// LoadBalancer Controller
if lbController {
loadBalancerMgr, err = ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddrLb,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddrLb,
},
LeaderElection: enableLeaderElection,
LeaderElectionReleaseOnCancel: true,
LeaderElectionID: "3a7ac996.stackit.cloud",
Expand All @@ -162,7 +165,9 @@ func main() {
RetryPeriod: &leasesRetryPeriod,
LeaderElectionResourceLock: leasesLeaderElectionResourceLock,
Cache: cache.Options{
Namespaces: []string{clusterNamespace},
DefaultNamespaces: map[string]cache.Config{
clusterNamespace: {},
},
},
})
if err != nil {
Expand All @@ -189,8 +194,10 @@ func main() {
// LoadBalancerSet Controller
if lbSetController {
loadBalancerSetMgr, err = ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddrLbs,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddrLbs,
},
LeaderElection: enableLeaderElection,
LeaderElectionReleaseOnCancel: true,
LeaderElectionID: "rgp5vg43.stackit.cloud",
Expand All @@ -199,7 +206,9 @@ func main() {
RetryPeriod: &leasesRetryPeriod,
LeaderElectionResourceLock: leasesLeaderElectionResourceLock,
Cache: cache.Options{
Namespaces: []string{clusterNamespace},
DefaultNamespaces: map[string]cache.Config{
clusterNamespace: {},
},
},
})
if err != nil {
Expand Down Expand Up @@ -241,8 +250,10 @@ func main() {
discoveryClient := discovery.NewDiscoveryClientForConfigOrDie(cfg)

loadBalancerMachineMgr, err = ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddrLbm,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddrLbm,
},
LeaderElection: enableLeaderElection,
LeaderElectionReleaseOnCancel: true,
LeaderElectionID: "tanf7ges.stackit.cloud",
Expand All @@ -251,7 +262,9 @@ func main() {
RetryPeriod: &leasesRetryPeriod,
LeaderElectionResourceLock: leasesLeaderElectionResourceLock,
Cache: cache.Options{
Namespaces: []string{clusterNamespace},
DefaultNamespaces: map[string]cache.Config{
clusterNamespace: {},
},
},
})
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions cmd/yawollet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/fields"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
Expand Down Expand Up @@ -185,11 +186,15 @@ func main() {
}()

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
LeaderElection: false,
Scheme: scheme,
Metrics: server.Options{
BindAddress: metricsAddr,
},
LeaderElection: false,
Cache: cache.Options{
Namespaces: []string{namespace},
DefaultNamespaces: map[string]cache.Config{
namespace: {},
},
ByObject: map[client.Object]cache.ByObject{
&yawolv1beta1.LoadBalancer{}: {Field: fields.SelectorFromSet(fields.Set{"metadata.name": loadbalancerName})},
&yawolv1beta1.LoadBalancerMachine{}: {Field: fields.SelectorFromSet(fields.Set{"metadata.name": loadbalancerMachineName})},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
// +kubebuilder:scaffold:imports
Expand Down Expand Up @@ -63,8 +64,10 @@ var _ = BeforeSuite(func() {
Expect(k8sClient).ToNot(BeNil())

k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme.Scheme,
MetricsBindAddress: "0",
Scheme: scheme.Scheme,
Metrics: server.Options{
BindAddress: "0",
},
})
Expect(err).ToNot(HaveOccurred())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
v1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

type InfrastructureDefaults struct {
Expand Down Expand Up @@ -82,7 +82,7 @@ func GetInfrastructureDetailsFromService(svc *v1.Service) InfrastructureDefaults
}
if svc.Annotations[yawolv1beta1.ServiceAvailabilityZone] != "" {
az := svc.Annotations[yawolv1beta1.ServiceAvailabilityZone]
serviceInfraDefault.AvailabilityZone = pointer.String(az)
serviceInfraDefault.AvailabilityZone = ptr.To(az)
}
if svc.Annotations[yawolv1beta1.ServiceInternalLoadbalancer] != "" {
internalLB, err := strconv.ParseBool(svc.Annotations[yawolv1beta1.ServiceInternalLoadbalancer])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
Expand Down Expand Up @@ -565,7 +565,7 @@ var _ = Describe("Check loadbalancer reconcile", Serial, Ordered, func() {
Namespace: "default",
},
Spec: v1.ServiceSpec{
LoadBalancerClass: pointer.String("foo"),
LoadBalancerClass: ptr.To("foo"),
Ports: []v1.ServicePort{
{
Name: "port1",
Expand Down Expand Up @@ -597,7 +597,7 @@ var _ = Describe("Check loadbalancer reconcile", Serial, Ordered, func() {
Namespace: "default",
},
Spec: v1.ServiceSpec{
LoadBalancerClass: pointer.String(helper.DefaultLoadbalancerClass),
LoadBalancerClass: ptr.To(helper.DefaultLoadbalancerClass),
Ports: []v1.ServicePort{
{
Name: "port1",
Expand Down Expand Up @@ -1062,7 +1062,7 @@ var _ = Describe("Check loadbalancer reconcile", Serial, Ordered, func() {
},
Spec: v1.ServiceSpec{
IPFamilies: []v1.IPFamily{v1.IPv4Protocol, v1.IPv6Protocol},
IPFamilyPolicy: (*v1.IPFamilyPolicyType)(pointer.String(string(v1.IPFamilyPolicyRequireDualStack))),
IPFamilyPolicy: (*v1.IPFamilyPolicyType)(ptr.To(string(v1.IPFamilyPolicyRequireDualStack))),
Ports: []v1.ServicePort{
{
Name: "port1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
"github.com/stackitcloud/yawol/internal/helper"
Expand Down Expand Up @@ -69,8 +70,10 @@ var _ = BeforeSuite(func() {
Expect(k8sClient).ToNot(BeNil())

k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme.Scheme,
MetricsBindAddress: "0",
Scheme: scheme.Scheme,
Metrics: server.Options{
BindAddress: "0",
},
})
Expect(err).ToNot(HaveOccurred())
authSecretName := "secret"
Expand Down
Loading

0 comments on commit 5474434

Please sign in to comment.