From 26d9c07191bd08653e7d4f27c6c498bfecc6d0f2 Mon Sep 17 00:00:00 2001 From: Daniel Olsson Date: Tue, 9 Jun 2020 21:21:09 +0200 Subject: [PATCH] Namespace flag overrides all assumptions based on jwt and other flags --- cmd/root.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 773f556..8f38a9f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -31,12 +31,13 @@ var Namespace string var Context string var ( - cfgFile string - verbose bool - lab bool - sandbox bool - teams []string - data []string + cfgFile string + namespaceFlag string + verbose bool + lab bool + sandbox bool + teams []string + data []string ) var secretAliases = []string{ @@ -65,7 +66,7 @@ func init() { rootCmd.PersistentFlags().BoolVarP(&lab, "lab", "", false, "Run lab to simulate team membership.") rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output") rootCmd.PersistentFlags().BoolVarP(&sandbox, "sandbox", "s", false, "Set if you want to work in a sandbox Namespace.") - rootCmd.PersistentFlags().StringVarP(&Namespace, "namespace", "n", "", "Namespace to create secret in. Usually only needed when member of more than one team.") + rootCmd.PersistentFlags().StringVarP(&namespaceFlag, "namespace", "n", "", "Namespace to create secret in. Usually only needed when member of more than one team.") rootCmd.PersistentFlags().StringVarP(&Context, "context", "", "", "Set context name.") // Hide flags @@ -102,4 +103,9 @@ func identifyTeam() { if sandbox { Namespace = Namespace + "-sandbox" } + + // Override namespace if provided with --namespace flag. + if namespaceFlag != "" { + Namespace = namespaceFlag + } }