Fission failed to list resources if namespace flag is not provided (#2585)

* use default namespace if no namespace is available
* remove the current-context namespace from push_pr GitHub workflow
This commit is contained in:
Shubham Bansal
2022-10-28 17:39:49 +05:30
committed by GitHub
parent 2bd005c387
commit dbd2153181
2 changed files with 3 additions and 8 deletions
+3 -7
View File
@@ -166,14 +166,13 @@ func GetKubernetesNamespace(kubeContext string) (currentNS string, err error) {
return "", err
}
config1, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
loadingRules, &clientcmd.ConfigOverrides{CurrentContext: kubeContext}).RawConfig()
namespace, _, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
loadingRules, &clientcmd.ConfigOverrides{CurrentContext: kubeContext}).Namespace()
if err != nil {
return "", errors.Wrap(err, "Failed to build Kubernetes config")
}
currentNS = config1.Contexts[config1.CurrentContext].Namespace
return currentNS, nil
return namespace, nil
}
// given a list of functions, this checks if the functions actually exist on the cluster
@@ -508,9 +507,6 @@ func GetResourceNamespace(input cli.Input, deprecatedFlag string) (namespace, cu
return namespace, currentNS, err
}
}
if currentNS == "" {
return namespace, currentNS, errors.Errorf("either set current-context or provide namespace with --namespace flag")
}
}
console.Verbose(2, "Namespace for resource %s ", currentNS)