@@ -145,38 +145,6 @@ var propertySetCmd = &cobra.Command{
145145 map [string ]interface {}{"ok" : color .GreenString ("ok:" ), "version" : boldString (apiVersion )}))
146146 }
147147
148- if namespace := Flags .property .namespaceSet ; len (namespace ) > 0 {
149- namespaces , _ , err := Client .Namespaces .List ()
150- if err != nil {
151- whisk .Debug (whisk .DbgError , "Client.Namespaces.List() failed: %s\n " , err )
152- errStr := fmt .Sprintf (
153- wski18n .T ("Authenticated user does not have namespace '{{.name}}'; set command failed: {{.err}}" ,
154- map [string ]interface {}{"name" : namespace , "err" : err }))
155- werr = whisk .MakeWskError (errors .New (errStr ), whisk .EXIT_CODE_ERR_GENERAL , whisk .DISPLAY_MSG , whisk .NO_DISPLAY_USAGE )
156- } else {
157- whisk .Debug (whisk .DbgInfo , "Validating namespace '%s' is in user namespace list %#v\n " , namespace , namespaces )
158- var validNamespace bool
159- for _ , ns := range namespaces {
160- if ns .Name == namespace {
161- whisk .Debug (whisk .DbgInfo , "Namespace '%s' is valid\n " , namespace )
162- validNamespace = true
163- }
164- }
165- if ! validNamespace {
166- whisk .Debug (whisk .DbgError , "Namespace '%s' is not in the list of entitled namespaces\n " , namespace )
167- errStr := fmt .Sprintf (
168- wski18n .T ("Namespace '{{.name}}' is not in the list of entitled namespaces" ,
169- map [string ]interface {}{"name" : namespace }))
170- werr = whisk .MakeWskError (errors .New (errStr ), whisk .EXIT_CODE_ERR_GENERAL , whisk .DISPLAY_MSG , whisk .NO_DISPLAY_USAGE )
171- } else {
172- props ["NAMESPACE" ] = namespace
173- okMsg += fmt .Sprintf (
174- wski18n .T ("{{.ok}} whisk namespace set to {{.name}}\n " ,
175- map [string ]interface {}{"ok" : color .GreenString ("ok:" ), "name" : boldString (namespace )}))
176- }
177- }
178- }
179-
180148 err = WriteProps (Properties .PropsFile , props )
181149 if err != nil {
182150 whisk .Debug (whisk .DbgError , "writeProps(%s, %#v) failed: %s\n " , Properties .PropsFile , props , err )
@@ -236,21 +204,6 @@ var propertyUnsetCmd = &cobra.Command{
236204 map [string ]interface {}{"ok" : color .GreenString ("ok:" )}))
237205 }
238206
239- if Flags .property .namespace {
240- delete (props , "NAMESPACE" )
241- okMsg += fmt .Sprintf (
242- wski18n .T ("{{.ok}} whisk namespace unset" ,
243- map [string ]interface {}{"ok" : color .GreenString ("ok:" )}))
244- if len (DefaultNamespace ) > 0 {
245- okMsg += fmt .Sprintf (
246- wski18n .T ("; the default value of {{.default}} will be used.\n " ,
247- map [string ]interface {}{"default" : boldString (DefaultNamespace )}))
248- } else {
249- okMsg += fmt .Sprint (
250- wski18n .T ("; there is no default value that can be used.\n " ))
251- }
252- }
253-
254207 if Flags .property .apihost {
255208 delete (props , "APIHOST" )
256209 okMsg += fmt .Sprintf (
@@ -305,8 +258,8 @@ var propertyGetCmd = &cobra.Command{
305258 case "raw" :
306259 outputFormat = "raw"
307260 break
308- //case "json": For future implementation
309- //case "yaml": For future implementation
261+ //case "json": For future implementation
262+ //case "yaml": For future implementation
310263 default :
311264 errStr := fmt .Sprintf (
312265 wski18n .T ("Supported output format are std|raw" ))
@@ -323,6 +276,7 @@ var propertyGetCmd = &cobra.Command{
323276 Flags .property .apihost || Flags .property .apibuildno ) {
324277 Flags .property .all = true
325278 }
279+
326280 if Flags .property .all {
327281 // Currently with all only standard output format is supported.
328282 if outputFormat != "std" {
@@ -332,14 +286,23 @@ var propertyGetCmd = &cobra.Command{
332286 return werr
333287 }
334288
289+ fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayAPIHost ), boldString (Properties .APIHost ))
290+ fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayAuth ), boldString (Properties .Auth ))
291+ fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayNamespace ), boldString (getNamespace ()))
335292 fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayCert ), boldString (Properties .Cert ))
336293 fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayKey ), boldString (Properties .Key ))
337- fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayAuth ), boldString (Properties .Auth ))
338- fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayAPIHost ), boldString (Properties .APIHost ))
339294 fmt .Fprintf (color .Output , "%s\t %s\n " , wski18n .T (propDisplayAPIVersion ), boldString (Properties .APIVersion ))
340- fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (propDisplayNamespace ), boldString (Properties .Namespace ))
341295 fmt .Fprintf (color .Output , "%s\t %s\n " , wski18n .T (propDisplayCLIVersion ), boldString (Properties .CLIVersion ))
342296 } else {
297+ if Flags .property .apihost {
298+ printProperty (Properties .APIHost , propDisplayAPIHost , outputFormat )
299+ }
300+ if Flags .property .auth {
301+ printProperty (Properties .Auth , propDisplayAuth , outputFormat )
302+ }
303+ if Flags .property .namespace {
304+ printProperty (getNamespace (), propDisplayNamespace , outputFormat )
305+ }
343306 if Flags .property .cert {
344307 printProperty (Properties .Cert , propDisplayCert , outputFormat )
345308 }
@@ -349,18 +312,9 @@ var propertyGetCmd = &cobra.Command{
349312 if Flags .property .cliversion {
350313 printProperty (Properties .CLIVersion , propDisplayCLIVersion , outputFormat , "%s\t %s\n " )
351314 }
352- if Flags .property .apihost {
353- printProperty (Properties .APIHost , propDisplayAPIHost , outputFormat )
354- }
355- if Flags .property .auth {
356- printProperty (Properties .Auth , propDisplayAuth , outputFormat )
357- }
358315 if Flags .property .apiversion {
359316 printProperty (Properties .APIVersion , propDisplayAPIVersion , outputFormat , "%s\t %s\n " )
360317 }
361- if Flags .property .namespace {
362- printProperty (Properties .Namespace , propDisplayNamespace , outputFormat )
363- }
364318 }
365319
366320 if Flags .property .all || Flags .property .apibuild || Flags .property .apibuildno {
@@ -418,15 +372,12 @@ func init() {
418372 propertySetCmd .Flags ().StringVar (& Flags .Global .Key , "key" , "" , wski18n .T (propDisplayKey ))
419373 propertySetCmd .Flags ().StringVar (& Flags .property .apihostSet , "apihost" , "" , wski18n .T ("whisk API `HOST`" ))
420374 propertySetCmd .Flags ().StringVar (& Flags .property .apiversionSet , "apiversion" , "" , wski18n .T ("whisk API `VERSION`" ))
421- propertySetCmd .Flags ().StringVar (& Flags .property .namespaceSet , "namespace" , "" , wski18n .T ("whisk `NAMESPACE`" ))
422375
423376 propertyUnsetCmd .Flags ().BoolVar (& Flags .property .cert , "cert" , false , wski18n .T (propDisplayCert ))
424377 propertyUnsetCmd .Flags ().BoolVar (& Flags .property .key , "key" , false , wski18n .T (propDisplayKey ))
425378 propertyUnsetCmd .Flags ().BoolVar (& Flags .property .auth , "auth" , false , wski18n .T ("authorization key" ))
426379 propertyUnsetCmd .Flags ().BoolVar (& Flags .property .apihost , "apihost" , false , wski18n .T (propDisplayAPIHost ))
427380 propertyUnsetCmd .Flags ().BoolVar (& Flags .property .apiversion , "apiversion" , false , wski18n .T (propDisplayAPIVersion ))
428- propertyUnsetCmd .Flags ().BoolVar (& Flags .property .namespace , "namespace" , false , wski18n .T (propDisplayNamespace ))
429-
430381}
431382
432383func SetDefaultProperties () {
@@ -527,14 +478,6 @@ func loadProperties() error {
527478 Properties .APIHost = apiHost
528479 }
529480
530- if namespace , hasProp := props ["NAMESPACE" ]; hasProp && len (namespace ) > 0 {
531- Properties .Namespace = namespace
532- }
533-
534- if namespace := os .Getenv ("WHISK_NAMESPACE" ); len (namespace ) > 0 {
535- Properties .Namespace = namespace
536- }
537-
538481 return nil
539482}
540483
@@ -561,13 +504,6 @@ func parseConfigFlags(cmd *cobra.Command, args []string) error {
561504 }
562505 }
563506
564- if namespace := Flags .property .namespaceSet ; len (namespace ) > 0 {
565- Properties .Namespace = namespace
566- if Client != nil {
567- Client .Config .Namespace = namespace
568- }
569- }
570-
571507 if apiVersion := Flags .Global .Apiversion ; len (apiVersion ) > 0 {
572508 Properties .APIVersion = apiVersion
573509 if Client != nil {
@@ -619,3 +555,13 @@ func printProperty(propertyName string, displayText string, formatType string, f
619555 fmt .Fprintf (color .Output , "%s\t \t %s\n " , wski18n .T (displayText ), boldString (propertyName ))
620556 }
621557}
558+
559+ func getNamespace () string {
560+ var namespaces , _ , err = Client .Namespaces .List ()
561+ whisk .Debug (whisk .DbgError , "Client.Namespaces.List() failed: %s\n " , err )
562+ if err != nil {
563+ return "_"
564+ } else {
565+ return namespaces [0 ].Name
566+ }
567+ }
0 commit comments