Skip to content

Commit 7f1e9ed

Browse files
authored
(barbican-kms-plugin)Refactor and enhance Barbican KMS plugin codebase. (kubernetes#2278)
* Refactor and enhance Barbican KMS plugin codebase. * fixed the formmating issue
1 parent 0c5e1d2 commit 7f1e9ed

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

cmd/barbican-kms-plugin/main.go

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,36 @@ import (
2929
)
3030

3131
var (
32-
socketpath string
33-
cloudconfig string
32+
socketPath string
33+
cloudConfig string
3434
)
3535

3636
func main() {
37-
// Glog requires this otherwise it complains.
38-
if err := flag.CommandLine.Parse(nil); err != nil {
39-
klog.Fatalf("Unable to parse flags: %v", err)
40-
}
37+
flag.Parse()
38+
4139
// This is a temporary hack to enable proper logging until upstream dependencies
4240
// are migrated to fully utilize klog instead of glog.
43-
klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
44-
klog.InitFlags(klogFlags)
45-
// Sync the glog and klog flags.
46-
flag.CommandLine.VisitAll(func(f1 *flag.Flag) {
47-
f2 := klogFlags.Lookup(f1.Name)
48-
if f2 != nil {
49-
value := f1.Value.String()
50-
_ = f2.Value.Set(value)
51-
}
52-
})
41+
klog.InitFlags(nil)
5342

5443
cmd := &cobra.Command{
5544
Use: "barbican-kms-plugin",
56-
Short: "Barbican KMS plugin for kubernetes",
45+
Short: "Barbican KMS plugin for Kubernetes",
5746
RunE: func(cmd *cobra.Command, args []string) error {
58-
sigchan := make(chan os.Signal, 1)
59-
signal.Notify(sigchan, unix.SIGTERM, unix.SIGINT)
60-
err := server.Run(cloudconfig, socketpath, sigchan)
47+
sigChan := make(chan os.Signal, 1)
48+
signal.Notify(sigChan, unix.SIGTERM, unix.SIGINT)
49+
err := server.Run(cloudConfig, socketPath, sigChan)
6150
return err
6251
},
6352
}
6453

65-
cmd.Flags().AddGoFlagSet(flag.CommandLine)
66-
67-
cmd.PersistentFlags().StringVar(&socketpath, "socketpath", "", "Barbican KMS Plugin unix socket endpoint")
54+
cmd.PersistentFlags().StringVar(&socketPath, "socketpath", "", "Barbican KMS Plugin unix socket endpoint")
6855
if err := cmd.MarkPersistentFlagRequired("socketpath"); err != nil {
69-
klog.Fatalf("Unable to mark flag socketpath to be required: %v", err)
56+
klog.Fatalf("Unable to mark flag socketpath as required: %v", err)
7057
}
7158

72-
cmd.PersistentFlags().StringVar(&cloudconfig, "cloud-config", "", "Barbican KMS Plugin cloud config")
59+
cmd.PersistentFlags().StringVar(&cloudConfig, "cloud-config", "", "Barbican KMS Plugin cloud config")
7360
if err := cmd.MarkPersistentFlagRequired("cloud-config"); err != nil {
74-
klog.Fatalf("Unable to mark flag cloud-config to be required: %v", err)
61+
klog.Fatalf("Unable to mark flag cloud-config as required: %v", err)
7562
}
7663

7764
code := cli.Run(cmd)

0 commit comments

Comments
 (0)