From 67eb2edb43df30a976a99a75ad31648fd71002d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergen=20Yal=C3=A7=C4=B1n?= Date: Thu, 30 Oct 2025 17:45:52 +0300 Subject: [PATCH] Add crossplane-cli trace log support for namespaced MRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergen Yalçın --- internal/tester.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/tester.go b/internal/tester.go index 796295d..1967056 100644 --- a/internal/tester.go +++ b/internal/tester.go @@ -255,6 +255,10 @@ func logCollectorLibraryMode(done chan bool, ticker *time.Ticker, mutex sync.Loc Output: "wide", } + if r.Namespace != "" { + traceCmd.Namespace = r.Namespace + } + if err := traceCmd.Run(kongCtx, logger); err != nil { continue } @@ -277,7 +281,11 @@ func logCollectorCLIMode(done chan bool, ticker *time.Ticker, mutex sync.Locker, // We do not want to show this error to the user because it // is a noise and temporary one. // The error output was redirected to a file. - 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 + traceCmdArgs := fmt.Sprintf(`"${CROSSPLANE_CLI}" beta trace %s %s -o wide 2>>/tmp/uptest_crossplane_temp_errors.log`, r.KindGroup, r.Name) + if r.Namespace != "" { + 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) + } + traceCmd := exec.Command("bash", "-c", traceCmdArgs) //nolint:gosec // Disabling gosec to allow dynamic shell command execution output, err := traceCmd.CombinedOutput() if err == nil { log.Printf("crossplane trace logs %s\n%s\n", time.Now(), string(output))