doitintl / kube-no-trouble

Easily check your clusters for use of deprecated APIs
MIT License
3.21k stars 157 forks source link

Remove reduntant check in config for type of printer or find a better way of doing it #650

Closed dark0dave closed 1 week ago

dark0dave commented 1 month ago

Currently we check in config and printer for the printer type text,csv, or json. Ideally we do this once. The pflag library is alittle lacking when it comes to exact strings so this is alittle annoying. I am open to suggestions here.

harry97uk commented 2 weeks ago

I have trialled a solution that works.

Instead of a string value for Config.Output, we can have a OutputFormat type that implements pflag.Value to enforce strict string matching during flag parsing. Then we use VarP instead of StringVarP to register the value that will automatically validate the flag.

I am ready to submit a PR. What do you think?

dark0dave commented 2 weeks ago

@harry97uk please submit a pr, I think its an excellent solution.