@@ -113,6 +113,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
113113 selector := cmdutil .GetFlagString (cmd , "selector" )
114114 allNamespaces := cmdutil .GetFlagBool (cmd , "all-namespaces" )
115115 mapper , typer := f .Object ()
116+ var all bool = allNamespaces
116117
117118 cmdNamespace , enforceNamespace , err := f .DefaultNamespace ()
118119 if err != nil {
@@ -129,12 +130,16 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
129130` )
130131 return cmdutil .UsageError (cmd , "Required resource not specified." )
131132 }
133+ userNamespace := cmdutil .GetFlagString (cmd , "namespace" )
134+ if userNamespace == "" {
135+ all = true
136+ }
132137
133138 // handle watch separately since we cannot watch multiple resource types
134139 isWatch , isWatchOnly := cmdutil .GetFlagBool (cmd , "watch" ), cmdutil .GetFlagBool (cmd , "watch-only" )
135140 if isWatch || isWatchOnly {
136141 r := resource .NewBuilder (mapper , typer , f .ClientMapperForCommand ()).
137- NamespaceParam (cmdNamespace ).DefaultNamespace ().AllNamespaces (true ).
142+ NamespaceParam (cmdNamespace ).DefaultNamespace ().AllNamespaces (all ).
138143 TenantParam (cmdTenant ).DefaultTenant ().
139144 FilenameParam (enforceTenant , enforceNamespace , options .Filenames ... ).
140145 SelectorParam (selector ).
@@ -189,7 +194,7 @@ func RunGet(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string
189194 }
190195
191196 b := resource .NewBuilder (mapper , typer , f .ClientMapperForCommand ()).
192- NamespaceParam (cmdNamespace ).DefaultNamespace ().AllNamespaces (true ).
197+ NamespaceParam (cmdNamespace ).DefaultNamespace ().AllNamespaces (all ).
193198 FilenameParam (enforceTenant , enforceNamespace , options .Filenames ... ).
194199 SelectorParam (selector ).
195200 ResourceTypeOrNameArgs (true , args ... ).
0 commit comments