From d380969ac64177c3a3dc9ed08f225e8aa9fc2500 Mon Sep 17 00:00:00 2001 From: Mike Fedosin Date: Thu, 25 Aug 2022 13:21:08 +0200 Subject: [PATCH] Fix breaking changes introduced in v1.25 All log config methods became functions in v1.25: https://github.com/kubernetes/component-base/commit/41262c34b8289295c4b617a8db5aebbb3645da6e --- bootstrap/kubeadm/main.go | 5 +++-- controlplane/kubeadm/main.go | 5 +++-- main.go | 5 +++-- test/extension/main.go | 5 +++-- test/infrastructure/docker/main.go | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bootstrap/kubeadm/main.go b/bootstrap/kubeadm/main.go index 2b58e5d5739d..22c4983cb084 100644 --- a/bootstrap/kubeadm/main.go +++ b/bootstrap/kubeadm/main.go @@ -35,6 +35,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + logapiv1 "k8s.io/component-base/logs/api/v1" _ "k8s.io/component-base/logs/json/register" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" @@ -90,7 +91,7 @@ var ( // InitFlags initializes this manager's flags. func InitFlags(fs *pflag.FlagSet) { logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags()) - logOptions.AddFlags(fs) + logapiv1.AddFlags(logOptions, fs) fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080", "The address the metric endpoint binds to.") @@ -145,7 +146,7 @@ func main() { pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() - if err := logOptions.ValidateAndApply(nil); err != nil { + if err := logapiv1.ValidateAndApply(logOptions, nil); err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) } diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index c49fb5c4fbd7..d00f6030372e 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -37,6 +37,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + logapiv1 "k8s.io/component-base/logs/api/v1" _ "k8s.io/component-base/logs/json/register" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" @@ -94,7 +95,7 @@ var ( // InitFlags initializes the flags. func InitFlags(fs *pflag.FlagSet) { logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags()) - logOptions.AddFlags(fs) + logapiv1.AddFlags(logOptions, fs) fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080", "The address the metric endpoint binds to.") @@ -148,7 +149,7 @@ func main() { pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() - if err := logOptions.ValidateAndApply(nil); err != nil { + if err := logapiv1.ValidateAndApply(logOptions, nil); err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) } diff --git a/main.go b/main.go index 7721aa08d534..0c3efcae6487 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + logapiv1 "k8s.io/component-base/logs/api/v1" _ "k8s.io/component-base/logs/json/register" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" @@ -129,7 +130,7 @@ func init() { // InitFlags initializes the flags. func InitFlags(fs *pflag.FlagSet) { logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags()) - logOptions.AddFlags(fs) + logapiv1.AddFlags(logOptions, fs) fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080", "The address the metric endpoint binds to.") @@ -208,7 +209,7 @@ func main() { pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() - if err := logOptions.ValidateAndApply(nil); err != nil { + if err := logapiv1.ValidateAndApply(logOptions, nil); err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) } diff --git a/test/extension/main.go b/test/extension/main.go index a02d7b1537cc..40d31d097d39 100644 --- a/test/extension/main.go +++ b/test/extension/main.go @@ -28,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + logapiv1 "k8s.io/component-base/logs/api/v1" "k8s.io/klog/v2" "k8s.io/utils/pointer" ctrl "sigs.k8s.io/controller-runtime" @@ -65,7 +66,7 @@ func init() { // InitFlags initializes the flags. func InitFlags(fs *pflag.FlagSet) { logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags()) - logOptions.AddFlags(fs) + logapiv1.AddFlags(logOptions, fs) fs.StringVar(&profilerAddress, "profiler-address", "", "Bind address to expose the pprof profiler (e.g. localhost:6060)") @@ -83,7 +84,7 @@ func main() { pflag.CommandLine.AddGoFlagSet(flag.CommandLine) pflag.Parse() - if err := logOptions.ValidateAndApply(nil); err != nil { + if err := logapiv1.ValidateAndApply(logOptions, nil); err != nil { setupLog.Error(err, "unable to start extension") os.Exit(1) } diff --git a/test/infrastructure/docker/main.go b/test/infrastructure/docker/main.go index 8c801c888a4b..bf783bb96dc9 100644 --- a/test/infrastructure/docker/main.go +++ b/test/infrastructure/docker/main.go @@ -34,6 +34,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + logapiv1 "k8s.io/component-base/logs/api/v1" _ "k8s.io/component-base/logs/json/register" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" @@ -85,7 +86,7 @@ func init() { func initFlags(fs *pflag.FlagSet) { logs.AddFlags(fs, logs.SkipLoggingConfigurationFlags()) - logOptions.AddFlags(fs) + logapiv1.AddFlags(logOptions, fs) fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080", "The address the metric endpoint binds to.") @@ -119,7 +120,7 @@ func main() { pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) pflag.Parse() - if err := logOptions.ValidateAndApply(nil); err != nil { + if err := logapiv1.ValidateAndApply(logOptions, nil); err != nil { setupLog.Error(err, "unable to start manager") os.Exit(1) }