Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove handling code for glog #2325

Merged
merged 7 commits into from
Oct 3, 2023
21 changes: 0 additions & 21 deletions cmd/k8s-keystone-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"os"

Expand All @@ -29,32 +28,12 @@ import (
)

func main() {
// Glog requires this otherwise it complains.
err := flag.CommandLine.Parse(nil)
if err != nil {
klog.Fatalf("Unable to parse flags: %v", err)
}

var showVersion bool
pflag.BoolVar(&showVersion, "version", false, "Show current version and exit")

// This is a temporary hack to enable proper logging until upstream dependencies
// are migrated to fully utilize klog instead of glog.
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(klogFlags)

logs.AddFlags(pflag.CommandLine)
keystone.AddExtraFlags(pflag.CommandLine)

// Sync the glog and klog flags.
flag.CommandLine.VisitAll(func(f1 *flag.Flag) {
f2 := klogFlags.Lookup(f1.Name)
if f2 != nil {
value := f1.Value.String()
_ = f2.Value.Set(value)
}
})
Comment on lines -49 to -56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to set values in flag.CommandLine, although nothing is using it?

Copy link
Member Author

@stephenfin stephenfin Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it's used alright: the kflag.InitFlags call below adds flag.CommandLine as a flagset. However, it's not doing anything useful since no upstream dependency should be using glog any more, which means there's nothing valuable to copy. You can test this by sticking some debug printf calls in here (which is what I did 😅)


logs.InitLogs()
defer logs.FlushLogs()

Expand Down