Skip to content

Conversation

thanasisk
Copy link
Contributor

addresses #70

@danielpacak danielpacak self-requested a review April 10, 2020 10:32
Copy link
Contributor

@danielpacak danielpacak left a comment

Choose a reason for hiding this comment

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

Hi @thanasisk and thank you for the PR! I just tried it out and I got the following error:

./kubectl-who-can get pod --v 6
Error: unknown flag: --v

I think that glog registered the --v flag implicitly in the init block, whereas for klog we have to register it explicitly. Also remember to flush logs in the defer statement:

func main() {
	defer klog.Flush()

	initFlags()

	root, err := cmd.NewWhoCanCommand(clioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr})
	// ...
}

func initFlags() {
	klog.InitFlags(nil)
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)

	// Hide all klog flags except for -v
	flag.CommandLine.VisitAll(func(f *flag.Flag) {
		if f.Name != "v" {
			pflag.Lookup(f.Name).Hidden = true
		}
	})
}

Please make sure to preserve the global flags:

./kubectl-who-can -h
Flags:
  ...
  -v, --v Level                          number for the log level verbosity
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

@thanasisk
Copy link
Contributor Author

thanks will have a look

Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>
@codecov-io
Copy link

Codecov Report

Merging #71 into master will not change coverage by %.
The diff coverage is 75.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #71   +/-   ##
=======================================
  Coverage   70.80%   70.80%           
=======================================
  Files           5        5           
  Lines         387      387           
=======================================
  Hits          274      274           
  Misses         98       98           
  Partials       15       15           
Impacted Files Coverage Δ
pkg/cmd/policy_rule_matcher.go 93.10% <50.00%> (ø)
pkg/cmd/list.go 56.44% <83.33%> (ø)
pkg/cmd/resource_resolver.go 85.13% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f78ee94...a5fbae6. Read the comment docs.

@danielpacak danielpacak merged commit 5925f66 into aquasecurity:master Apr 10, 2020
@danielpacak
Copy link
Contributor

thanks will have a look

Thank you for taking care of it and promptly addressing my comments !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants