From 9d40f32e899281ef5ea0b5e571869240ccef979e Mon Sep 17 00:00:00 2001
From: kaiyou <dev@kaiyou.fr>
Date: Mon, 23 Jan 2023 22:20:01 +0100
Subject: [PATCH] Hide unwanted k8s global flags more properly

---
 cmd/hepto/config.go | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/cmd/hepto/config.go b/cmd/hepto/config.go
index 9676792..6bbaf08 100644
--- a/cmd/hepto/config.go
+++ b/cmd/hepto/config.go
@@ -29,7 +29,8 @@ type Config struct {
 var config Config
 
 func (c *Config) Complete() error {
-  // Print version if requested
+  // Print version if requested, verflag flags are declared
+  // by init() functions deep in k8s code
   verflag.PrintAndExitIfRequested()
 	// Mount a shell if required
 	if c.Shell != "" {
@@ -70,10 +71,8 @@ func (c *Config) Complete() error {
 }
 
 func init() {
-  verflag.AddFlags(Hepto.Flags()) // Expose k8s version directly
-  // Force-reinit pflag global cli object, because k8s has a nasty habit of
-  // globally registering flags in init()
-  pflag.CommandLine = pflag.NewFlagSet("hepto", pflag.ExitOnError)
+  // Hide unwanted flags declared inside k8s init() directly
+  pflag.CommandLine.MarkHidden("azure-container-registry-config")
 	cobra.OnInitialize(viper.AutomaticEnv)
 
 	// General config
-- 
GitLab