Skip to content

Commit 180efba

Browse files
authored
Merge pull request #52 from sergenyalcin/support-ns-mr-trace-log
Add crossplane-cli trace log support for namespaced MRs
2 parents 15e94cc + 67eb2ed commit 180efba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/tester.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ func logCollectorLibraryMode(done chan bool, ticker *time.Ticker, mutex sync.Loc
255255
Output: "wide",
256256
}
257257

258+
if r.Namespace != "" {
259+
traceCmd.Namespace = r.Namespace
260+
}
261+
258262
if err := traceCmd.Run(kongCtx, logger); err != nil {
259263
continue
260264
}
@@ -277,7 +281,11 @@ func logCollectorCLIMode(done chan bool, ticker *time.Ticker, mutex sync.Locker,
277281
// We do not want to show this error to the user because it
278282
// is a noise and temporary one.
279283
// The error output was redirected to a file.
280-
traceCmd := exec.Command("bash", "-c", fmt.Sprintf(`"${CROSSPLANE_CLI}" beta trace %s %s -o wide 2>>/tmp/uptest_crossplane_temp_errors.log`, r.KindGroup, r.Name)) //nolint:gosec // Disabling gosec to allow dynamic shell command execution
284+
traceCmdArgs := fmt.Sprintf(`"${CROSSPLANE_CLI}" beta trace %s %s -o wide 2>>/tmp/uptest_crossplane_temp_errors.log`, r.KindGroup, r.Name)
285+
if r.Namespace != "" {
286+
traceCmdArgs = fmt.Sprintf(`"${CROSSPLANE_CLI}" beta trace %s %s -n %s -o wide 2>>/tmp/uptest_crossplane_temp_errors.log`, r.KindGroup, r.Name, r.Namespace)
287+
}
288+
traceCmd := exec.Command("bash", "-c", traceCmdArgs) //nolint:gosec // Disabling gosec to allow dynamic shell command execution
281289
output, err := traceCmd.CombinedOutput()
282290
if err == nil {
283291
log.Printf("crossplane trace logs %s\n%s\n", time.Now(), string(output))

0 commit comments

Comments
 (0)