Skip to content

Commit

Permalink
Migrate to slog and go-1.22 (#51)
Browse files Browse the repository at this point in the history
majst01 authored Mar 13, 2024
1 parent f89d5cf commit 8137ae5
Showing 12 changed files with 299 additions and 649 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -31,14 +31,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.21
uses: actions/setup-go@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'
cache: false

- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
args: --build-tags integration -p bugs -p unused --timeout=10m

@@ -63,10 +63,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Go 1.21
uses: actions/setup-go@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'

- name: Checkout
run: |
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Build the firewall-controller-manager binary
FROM golang:1.21 as builder
FROM golang:1.22 as builder

WORKDIR /work
COPY . .
RUN make

FROM alpine:3.18
FROM alpine:3.19
COPY --from=builder /work/bin/firewall-controller-manager .
USER 65534
ENTRYPOINT ["/firewall-controller-manager"]
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.18
FROM alpine:3.19
COPY bin/firewall-controller-manager /firewall-controller-manager
USER 65534
ENTRYPOINT ["/firewall-controller-manager"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ GITVERSION := $(shell git describe --long --all)
BUILDDATE := $(shell date -Iseconds)
VERSION := $(or ${VERSION},$(shell git describe --tags --exact-match 2> /dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD))

CONTROLLER_TOOLS_VERSION ?= v0.11.3
CONTROLLER_TOOLS_VERSION ?= v0.14.0
LOCALBIN ?= $(shell pwd)/bin
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
7 changes: 4 additions & 3 deletions api/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 10 additions & 18 deletions controllers/logger.go
Original file line number Diff line number Diff line change
@@ -2,26 +2,18 @@ package controllers

import (
"fmt"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"log/slog"
"os"
)

func NewZapLogger(levelString string) (*zap.SugaredLogger, error) {
level, err := zap.ParseAtomicLevel(levelString)
if err != nil {
return nil, fmt.Errorf("unable to parse log level: %w", err)
}

cfg := zap.NewProductionConfig()
cfg.Level = level
cfg.EncoderConfig.TimeKey = "timestamp"
cfg.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder

l, err := cfg.Build()
func NewLogger(levelString string) (slog.Handler, error) {
var (
lvlvar slog.LevelVar
)
err := lvlvar.UnmarshalText([]byte(levelString))
if err != nil {
return nil, fmt.Errorf("can't initialize zap logger: %w", err)
return nil, fmt.Errorf("can't initialize logger: %w", err)
}

return l.Sugar(), nil
level := lvlvar.Level()
return slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: level}), nil
}
6 changes: 3 additions & 3 deletions controllers/set/suite_test.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/go-logr/zapr"
"github.com/go-logr/logr"
v2 "github.com/metal-stack/firewall-controller-manager/api/v2"
controllerconfig "github.com/metal-stack/firewall-controller-manager/api/v2/config"
"github.com/metal-stack/firewall-controller-manager/controllers"
@@ -46,10 +46,10 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
l, err := controllers.NewZapLogger("debug")
l, err := controllers.NewLogger("debug")
Expect(err).NotTo(HaveOccurred())

ctrl.SetLogger(zapr.NewLogger(l.Desugar()))
ctrl.SetLogger(logr.FromSlogHandler(l))

ctx, cancel = context.WithCancel(context.Background())

157 changes: 81 additions & 76 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,142 +1,147 @@
module github.com/metal-stack/firewall-controller-manager

go 1.21
go 1.22

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/flatcar/container-linux-config-transpiler v0.9.4
github.com/go-logr/logr v1.2.4
github.com/go-logr/zapr v1.2.4
github.com/go-openapi/strfmt v0.21.7
github.com/go-logr/logr v1.4.1
github.com/go-openapi/strfmt v0.23.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
github.com/metal-stack/metal-go v0.24.3
github.com/metal-stack/metal-lib v0.13.5
github.com/google/uuid v1.6.0
github.com/metal-stack/metal-go v0.28.1
github.com/metal-stack/metal-lib v0.15.1
github.com/metal-stack/v v1.0.3
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.1
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
k8s.io/api v0.26.3
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.26.3
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
github.com/stretchr/testify v1.9.0
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.14.5
)

replace (
k8s.io/api => k8s.io/api v0.26.3
k8s.io/client-go => k8s.io/client-go v0.26.3
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f
)

require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ajeddeloh/go-json v0.0.0-20200220154158-5ae607161559 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-oidc/v3 v3.6.0 // indirect
github.com/coreos/go-oidc/v3 v3.9.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/flatcar/ignition v0.36.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-openapi/analysis v0.22.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/loads v0.21.5 // indirect
github.com/go-openapi/runtime v0.27.1 // indirect
github.com/go-openapi/spec v0.20.14 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-openapi/validate v0.22.6 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-yaml v1.11.0 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // 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/jszwec/csvutil v1.8.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx v1.2.26 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.19 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/metal-stack/security v0.6.7 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/metal-stack/security v0.7.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // 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/olekukonko/tablewriter v0.0.5 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.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.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/vincent-petithory/dataurl v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.3 // indirect
k8s.io/component-base v0.26.3 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // 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
653 changes: 152 additions & 501 deletions go.sum

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions integration/metal_resources_test.go
Original file line number Diff line number Diff line change
@@ -326,6 +326,4 @@ func swapMetalClient(mockFns *metalclient.MetalMockFns) {

metalMockClient := metalClient.(*metalclient.MetalMockClient)
*metalMockClient = *newClient // nolint for testing this is just fine

return
}
6 changes: 3 additions & 3 deletions integration/suite_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/go-logr/zapr"
"github.com/go-logr/logr"
v2 "github.com/metal-stack/firewall-controller-manager/api/v2"
controllerconfig "github.com/metal-stack/firewall-controller-manager/api/v2/config"
"github.com/metal-stack/firewall-controller-manager/controllers"
@@ -54,10 +54,10 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func() {
l, err := controllers.NewZapLogger("debug")
l, err := controllers.NewLogger("debug")
Expect(err).NotTo(HaveOccurred())

ctrl.SetLogger(zapr.NewLogger(l.Desugar()))
ctrl.SetLogger(logr.FromSlogHandler(l))

ctx, cancel = context.WithCancel(context.Background())

67 changes: 35 additions & 32 deletions main.go
Original file line number Diff line number Diff line change
@@ -4,12 +4,13 @@ import (
"context"
"flag"
"fmt"
"log"
"log/slog"
"net/http"
"os"
"time"

"github.com/go-logr/zapr"
"go.uber.org/zap"
"github.com/go-logr/logr"

metalgo "github.com/metal-stack/metal-go"
"github.com/metal-stack/metal-lib/pkg/pointer"
@@ -35,7 +36,7 @@ const (
metalAuthHMACEnvVar = "METAL_AUTH_HMAC"
)

func healthCheckFunc(log *zap.SugaredLogger, seedClient controllerclient.Client, namespace string) func(req *http.Request) error {
func healthCheckFunc(log *slog.Logger, seedClient controllerclient.Client, namespace string) func(req *http.Request) error {
return func(req *http.Request) error {
log.Info("health check called")

@@ -101,20 +102,22 @@ func main() {

flag.Parse()

l, err := controllers.NewZapLogger(logLevel)
slogHandler, err := controllers.NewLogger(logLevel)
if err != nil {
ctrl.Log.WithName("setup").Error(err, "unable to parse log level")
os.Exit(1)
}
ctrl.SetLogger(zapr.NewLogger(l.Desugar()))
l := slog.New(slogHandler)

ctrl.SetLogger(logr.FromSlogHandler(slogHandler))

var (
stop = ctrl.SetupSignalHandler()
)

mclient, err := getMetalClient(metalURL)
if err != nil {
l.Fatalw("unable to create metal client", "error", err)
log.Fatalf("unable to create metal client %v", err)
}

seedMgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
@@ -130,7 +133,7 @@ func main() {
CertDir: certDir,
})
if err != nil {
l.Fatalw("unable to setup firewall-controller-manager", "error", err)
log.Fatalf("unable to setup firewall-controller-manager %v", err)
}

// cannot use seedMgr.GetClient() because it gets initialized at a later point in time
@@ -139,14 +142,14 @@ func main() {
Scheme: scheme,
})
if err != nil {
l.Fatalw("unable to create seed client", "error", err)
log.Fatalf("unable to create seed client %v", err)
}

if err := seedMgr.AddHealthzCheck("health", healthCheckFunc(l.Named("health"), seedClient, namespace)); err != nil {
l.Fatalw("unable to set up health check", "error", err)
if err := seedMgr.AddHealthzCheck("health", healthCheckFunc(l.WithGroup("health"), seedClient, namespace)); err != nil {
log.Fatalf("unable to set up health check %v", err)
}
if err := seedMgr.AddReadyzCheck("check", healthCheckFunc(l.Named("ready"), seedMgr.GetClient(), namespace)); err != nil {
l.Fatalw("unable to set up ready check", "error", err)
if err := seedMgr.AddReadyzCheck("check", healthCheckFunc(l.WithGroup("ready"), seedMgr.GetClient(), namespace)); err != nil {
log.Fatalf("unable to set up ready check %v", err)
}

var (
@@ -169,15 +172,15 @@ func main() {

internalShootAccessHelper = helper.NewSingleClusterModeHelper(seedMgr.GetConfig())
if err != nil {
l.Fatalw("unable to create shoot helper", "error", err)
log.Fatalf("unable to create shoot helper %v", err)
}
l.Infow("running in single-cluster mode")
l.Info("running in single-cluster mode")
} else {
internalShootAccessHelper = helper.NewShootAccessHelper(seedClient, internalShootAccess)
if err != nil {
l.Fatalw("unable to create shoot helper", "error", err)
log.Fatalf("unable to create shoot helper %v", err)
}
l.Infow("running in split-cluster mode (seed and shoot client)")
l.Info("running in split-cluster mode (seed and shoot client)")
}

if shootTokenPath != "" {
@@ -199,12 +202,12 @@ func main() {
//
updater, err := helper.NewShootAccessTokenUpdater(internalShootAccessHelper, shootTokenPath)
if err != nil {
l.Fatalw("unable to create shoot access token updater", "error", err)
log.Fatalf("unable to create shoot access token updater %v", err)
}

err = updater.UpdateContinuously(ctrl.Log.WithName("token-updater"), stop)
if err != nil {
l.Fatalw("unable to start token updater", "error", err)
log.Fatalf("unable to start token updater %v", err)
}
}

@@ -213,7 +216,7 @@ func main() {

shootConfig, err := internalShootAccessHelper.RESTConfig(ctx)
if err != nil {
l.Fatalw("unable to create shoot config", "error", err)
log.Fatalf("unable to create shoot config %v", err)
}

shootMgr, err := ctrl.NewManager(shootConfig, ctrl.Options{
@@ -224,7 +227,7 @@ func main() {
GracefulShutdownTimeout: pointer.Pointer(time.Duration(0)),
})
if err != nil {
l.Fatalw("unable to start firewall-controller-manager-monitor", "error", err)
log.Fatalf("unable to start firewall-controller-manager-monitor %v", err)
}

cc, err := config.New(&config.NewControllerConfig{
@@ -248,42 +251,42 @@ func main() {
CreateTimeout: createTimeout,
})
if err != nil {
l.Fatalw("unable to create controller config", "error", err)
log.Fatalf("unable to create controller config %v", err)
}

if err := deployment.SetupWithManager(ctrl.Log.WithName("controllers").WithName("deployment"), seedMgr.GetEventRecorderFor("firewall-deployment-controller"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup controller", "error", err, "controller", "deployment")
log.Fatalf("unable to setup controller deployment %v", err)
}
if err := set.SetupWithManager(ctrl.Log.WithName("controllers").WithName("set"), seedMgr.GetEventRecorderFor("firewall-set-controller"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup controller", "error", err, "controller", "set")
log.Fatalf("unable to setup controller set %v", err)
}
if err := firewall.SetupWithManager(ctrl.Log.WithName("controllers").WithName("firewall"), seedMgr.GetEventRecorderFor("firewall-controller"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup controller", "error", err, "controller", "firewall")
log.Fatalf("unable to setup controller firewall %v", err)
}
if err := monitor.SetupWithManager(ctrl.Log.WithName("controllers").WithName("firewall-monitor"), shootMgr, cc); err != nil {
l.Fatalw("unable to setup controller", "error", err, "controller", "monitor")
log.Fatalf("unable to setup controller monitor %v", err)
}

if err := deployment.SetupWebhookWithManager(ctrl.Log.WithName("defaulting-webhook"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup webhook", "error", err, "controller", "deployment")
log.Fatalf("unable to setup webhook, controller deployment %v", err)
}
if err := set.SetupWebhookWithManager(ctrl.Log.WithName("defaulting-webhook"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup webhook", "error", err, "controller", "set")
log.Fatalf("unable to setup webhook, controller set %v", err)
}
if err := firewall.SetupWebhookWithManager(ctrl.Log.WithName("defaulting-webhook"), seedMgr, cc); err != nil {
l.Fatalw("unable to setup webhook", "error", err, "controller", "firewall")
log.Fatalf("unable to setup webhook, controller firewall %v", err)
}

go func() {
l.Infow("starting shoot controller", "version", v.V)
l.Info("starting shoot controller", "version", v.V)
if err := shootMgr.Start(stop); err != nil {
l.Fatalw("problem running shoot controller", "error", err)
log.Fatalf("problem running shoot controller %v", err)
}
}()

l.Infow("starting seed controller", "version", v.V)
l.Info("starting seed controller", "version", v.V)
if err := seedMgr.Start(stop); err != nil {
l.Fatalw("problem running seed controller", "error", err)
log.Fatalf("problem running seed controller %v", err)
}
}

0 comments on commit 8137ae5

Please sign in to comment.