Skip to content

Commit 540d169

Browse files
committed
add unit tests for common.go
1 parent 5959828 commit 540d169

2 files changed

Lines changed: 531 additions & 2 deletions

File tree

pkg/cli/commands/rpkg/util/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ func RemoveRevisionMetadata(prr *porchapi.PackageRevisionResources) error {
104104

105105
// EnsureNamespace tries to return a namespace from multiple different configs before defaulting to "default"
106106
//
107-
// Should only be used if the intention cannot be all namespaces!
107+
// Should only be used if the intention cannot be "all namespaces"!
108108
func EnsureNamespace(cfg *genericclioptions.ConfigFlags) string {
109109
// if --namespace is set just return that
110110
if cfg.Namespace != nil && *cfg.Namespace != "" {
111111
return *cfg.Namespace
112112
}
113113

114114
// try getting the namespace from the kubeconfig context
115-
if kcfgNs, _, err := cfg.ToRawKubeConfigLoader().Namespace(); err == nil && kcfgNs != "" {
115+
if kcfgNs, _, err := cfg.ToRawKubeConfigLoader().Namespace(); err == nil && kcfgNs != "" && kcfgNs != "default" {
116116
return kcfgNs
117117
}
118118

0 commit comments

Comments
 (0)