mirror of https://github.com/knative/client.git
fix: Fix error when no current namespace is set (#305)
When no current namespace is set in the config file, then using `kn` without -n fails: ``` invalid configuration: no configuration has been provided ``` Instead of failing in this case, assume the default namespace "namespace"
This commit is contained in:
parent
59b2855d04
commit
7d1594dc1f
|
|
@ -17,6 +17,7 @@ package commands
|
|||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
// AddNamespaceFlags adds the namespace-related flags:
|
||||
|
|
@ -57,7 +58,11 @@ func (params *KnParams) GetNamespace(cmd *cobra.Command) (string, error) {
|
|||
var err error
|
||||
namespace, err = params.CurrentNamespace()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if !clientcmd.IsEmptyConfig(err) {
|
||||
return "", err
|
||||
}
|
||||
// If no current namespace is set use "default"
|
||||
namespace = "default"
|
||||
}
|
||||
}
|
||||
return namespace, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue