Skip to content

Commit 8e2898d

Browse files
committed
fix: address Mansi's review comments on cli.go
- Remove noNamespace bool; use namespace == "" check instead - Use filepath.Join for default kubeconfig path
1 parent 5c275f9 commit 8e2898d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

test/extended/utils/cli.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import (
55
"fmt"
66
"os"
77
"os/exec"
8+
"path/filepath"
89
"strings"
910
)
1011

1112
// CLI wraps the oc command-line tool for use in OTE Ginkgo tests.
1213
type CLI struct {
13-
namespace string
14-
asAdmin bool
15-
noNamespace bool
16-
kubeconfig string
14+
namespace string
15+
asAdmin bool
16+
kubeconfig string
1717
}
1818

1919
// NewCLI creates a CLI instance with the given namespace.
@@ -27,8 +27,7 @@ func NewCLI(namespace string) *CLI {
2727
// NewCLIWithoutNamespace creates a CLI instance without a namespace (for cluster-scoped resources).
2828
func NewCLIWithoutNamespace() *CLI {
2929
return &CLI{
30-
noNamespace: true,
31-
kubeconfig: kubeconfig(),
30+
kubeconfig: kubeconfig(),
3231
}
3332
}
3433

@@ -45,9 +44,7 @@ func (c *CLI) Run(verb string, args ...string) (string, string, error) {
4544
if c.asAdmin {
4645
cmdArgs = append(cmdArgs, "--as=system:admin")
4746
}
48-
if c.noNamespace {
49-
// no -n flag
50-
} else if c.namespace != "" {
47+
if c.namespace != "" {
5148
cmdArgs = append(cmdArgs, "-n", c.namespace)
5249
}
5350
cmdArgs = append(cmdArgs, args...)
@@ -78,5 +75,5 @@ func kubeconfig() string {
7875
if kc := os.Getenv("KUBECONFIG"); kc != "" {
7976
return kc
8077
}
81-
return os.Getenv("HOME") + "/.kube/config"
78+
return filepath.Join(os.Getenv("HOME"), ".kube", "config")
8279
}

0 commit comments

Comments
 (0)