Skip to content

Commit

Permalink
Bump klog and use the new constructor
Browse files Browse the repository at this point in the history
This removes deprecated klog flags per KEP-2845.

Upstream-Commit: c6b2b37
  • Loading branch information
qbarrand committed Nov 8, 2023
1 parent f7501ce commit 92c922c
Show file tree
Hide file tree
Showing 31 changed files with 1,857 additions and 405 deletions.
18 changes: 9 additions & 9 deletions cmd/manager-hub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
clusterv1 "open-cluster-management.io/api/cluster/v1"
workv1 "open-cluster-management.io/api/work/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -82,20 +81,21 @@ func init() {
}

func main() {
logger := klogr.New().WithName("kmm-hub")

ctrl.SetLogger(logger)

setupLogger := logger.WithName("setup")
logConfig := textlogger.NewConfig()
logConfig.AddFlags(flag.CommandLine)

var configFile string

flag.StringVar(&configFile, "config", "", "The path to the configuration file.")

klog.InitFlags(flag.CommandLine)

flag.Parse()

logger := textlogger.NewLogger(logConfig).WithName("kmm-hub")

ctrl.SetLogger(logger)

setupLogger := logger.WithName("setup")

setupLogger.Info("Creating manager", "version", Version, "git commit", GitCommit)
setupLogger.Info("Parsing configuration file", "path", configFile)

Expand Down
18 changes: 9 additions & 9 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
clusterv1alpha1 "open-cluster-management.io/api/cluster/v1alpha1"
ctrl "sigs.k8s.io/controller-runtime"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -79,20 +78,21 @@ func init() {
}

func main() {
logger := klogr.New().WithName("kmm")

ctrl.SetLogger(logger)

setupLogger := logger.WithName("setup")
logConfig := textlogger.NewConfig()
logConfig.AddFlags(flag.CommandLine)

var configFile string

flag.StringVar(&configFile, "config", "", "The path to the configuration file.")

klog.InitFlags(flag.CommandLine)

flag.Parse()

logger := textlogger.NewLogger(logConfig).WithName("kmm")

ctrl.SetLogger(logger)

setupLogger := logger.WithName("setup")

setupLogger.Info("Creating manager", "version", Version, "git commit", GitCommit)

operatorNamespace := cmd.GetEnvOrFatalError(constants.OperatorNamespaceEnvVar, setupLogger)
Expand Down
9 changes: 5 additions & 4 deletions cmd/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
kmmcmd "github.com/rh-ecosystem-edge/kernel-module-management/internal/cmd"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/worker"
"github.com/spf13/cobra"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
)

var (
Expand Down Expand Up @@ -74,7 +73,9 @@ func main() {
kmodCmd.AddCommand(kmodLoadCmd, kmodUnloadCmd)

klogFlagSet := flag.NewFlagSet("klog", flag.ContinueOnError)
klog.InitFlags(klogFlagSet)

logConfig := textlogger.NewConfig()
logConfig.AddFlags(klogFlagSet)

rootCmd.PersistentFlags().AddGoFlagSet(klogFlagSet)

Expand All @@ -95,7 +96,7 @@ func main() {
"if set, this the value that firmware host path is mounted to")

rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
logger = klogr.New().WithName("kmm-worker")
logger = textlogger.NewLogger(logConfig).WithName("kmm-worker")

logger.Info("Starting worker", "version", rootCmd.Version, "git commit", GitCommit)
logger.Info("Reading pull secrets", "base dir", worker.PullSecretsDir)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/a8m/envsubst v1.4.2
github.com/budougumi0617/cmpmock v0.0.4
github.com/containers/image/v5 v5.28.0
github.com/go-logr/logr v1.2.4
github.com/go-logr/logr v1.3.0
github.com/google/go-cmp v0.6.0
github.com/google/go-containerregistry v0.16.1
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230523181351-c3f8a49229d3
Expand All @@ -25,7 +25,7 @@ require (
k8s.io/api v0.27.7
k8s.io/apimachinery v0.27.7
k8s.io/client-go v0.27.7
k8s.io/klog/v2 v2.100.1
k8s.io/klog/v2 v2.110.1
k8s.io/kubectl v0.27.7
k8s.io/utils v0.0.0-20230505201702-9f6742963106
open-cluster-management.io/api v0.12.0
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
Expand Down Expand Up @@ -381,8 +380,8 @@ k8s.io/client-go v0.27.7 h1:+Xgh9OOKv6A3qdD4Dnl/0VOI5EvAv+0s/OseDxVVTwQ=
k8s.io/client-go v0.27.7/go.mod h1:dZ2kqcalYp5YZ2EV12XIMc77G6PxHWOJp/kclZr4+5Q=
k8s.io/component-base v0.27.7 h1:kngM58HR9W9Nqpv7e4rpdRyWnKl/ABpUhLAZ+HoliMs=
k8s.io/component-base v0.27.7/go.mod h1:YGjlCVL1oeKvG3HSciyPHFh+LCjIEqsxz4BDR3cfHRs=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=
k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo=
k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5 h1:azYPdzztXxPSa8wb+hksEKayiz0o+PPisO/d+QhWnoo=
k8s.io/kube-openapi v0.0.0-20230515203736-54b630e78af5/go.mod h1:kzo02I3kQ4BTtEfVLaPbjvCkX97YqGve33wzlb3fofQ=
k8s.io/kubectl v0.27.7 h1:HTEDa4s/oWjB3t5ysdW1yKlcNl9bzigcqWBq0LIIe3k=
Expand Down
113 changes: 112 additions & 1 deletion vendor/github.com/go-logr/logr/README.md

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

18 changes: 18 additions & 0 deletions vendor/github.com/go-logr/logr/SECURITY.md

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

Loading

0 comments on commit 92c922c

Please sign in to comment.