Skip to content

Commit 2d22e87

Browse files
Merge pull request #30442 from rioliu-rh/add-showinfo-flag-ocpert-201
NO-JIRA: Add showInfo flag to control CLI command logging
2 parents b115048 + 8c00829 commit 2d22e87

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

test/extended/util/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ type CLI struct {
110110
addEnvVars map[string]string
111111

112112
verbose bool
113+
showInfo bool // control framework.Logf output
113114
withoutNamespace bool
114115
withManagedNamespace bool
115116
kubeFramework *framework.Framework
@@ -134,6 +135,7 @@ func NewCLIWithFramework(kubeFramework *framework.Framework) *CLI {
134135
execPath: "oc",
135136
adminConfigPath: KubeConfigPath(),
136137
staticConfigManifestDir: StaticConfigManifestDir(),
138+
showInfo: true,
137139
}
138140
// Called only once (assumed the objects will never get modified)
139141
// TODO: run in every BeforeEach
@@ -178,6 +180,7 @@ func NewCLIWithoutNamespace(project string) *CLI {
178180
execPath: "oc",
179181
adminConfigPath: KubeConfigPath(),
180182
staticConfigManifestDir: StaticConfigManifestDir(),
183+
showInfo: true,
181184
withoutNamespace: true,
182185
}
183186
g.BeforeEach(cli.kubeFramework.BeforeEach)
@@ -211,6 +214,7 @@ func NewCLIForMonitorTest(project string) *CLI {
211214
execPath: "oc",
212215
adminConfigPath: KubeConfigPath(),
213216
staticConfigManifestDir: StaticConfigManifestDir(),
217+
showInfo: true,
214218
withoutNamespace: true,
215219
}
216220

@@ -241,6 +245,7 @@ func NewHypershiftManagementCLI(project string) *CLI {
241245
username: "admin",
242246
execPath: "oc",
243247
adminConfigPath: kubeconfig,
248+
showInfo: true,
244249
withoutNamespace: true,
245250
}
246251
}
@@ -1020,7 +1025,10 @@ func (c *CLI) start(stdOutBuff, stdErrBuff *bytes.Buffer) (*exec.Cmd, error) {
10201025
cmd := exec.Command(c.execPath, c.finalArgs...)
10211026
cmd.Stdin = c.stdin
10221027
// Redact any bearer token information from the log.
1023-
framework.Logf("Running '%s %s'", c.execPath, RedactBearerToken(strings.Join(c.finalArgs, " ")))
1028+
// Only log if showInfo is enabled (controlled by util_otp)
1029+
if c.showInfo {
1030+
framework.Logf("Running '%s %s'", c.execPath, RedactBearerToken(strings.Join(c.finalArgs, " ")))
1031+
}
10241032

10251033
cmd.Env = c.env
10261034
if len(c.addEnvVars) > 0 {

test/extended/util/util_otp.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ import (
2323

2424
// NotShowInfo disables showing info in CLI output
2525
func (c *CLI) NotShowInfo() *CLI {
26-
// OTP tracks this with a showInfo field, but origin doesn't have this field
27-
// For now, this is a no-op in origin
26+
c.showInfo = false
2827
return c
2928
}
3029

3130
// SetShowInfo enables showing info in CLI output
3231
func (c *CLI) SetShowInfo() *CLI {
33-
// OTP tracks this with a showInfo field, but origin doesn't have this field
34-
// For now, this is a no-op in origin
32+
c.showInfo = true
3533
return c
3634
}
3735

0 commit comments

Comments
 (0)