From ddc15bc5090d4391d8167ce8a7fee0669bea37ed Mon Sep 17 00:00:00 2001 From: JonJagger Date: Mon, 19 Jan 2026 13:33:36 +0000 Subject: [PATCH] Print host before output in multihost mode --- cmd/kosli/multiHost.go | 11 ++++++----- cmd/kosli/multiHost_test.go | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/kosli/multiHost.go b/cmd/kosli/multiHost.go index 60f0e2e1f..f88a43959 100644 --- a/cmd/kosli/multiHost.go +++ b/cmd/kosli/multiHost.go @@ -5,13 +5,14 @@ Kosli uses CI pipelines in the cyber-dojo Org repos [*] for two purposes: 1. public facing documentation 2. private development purposes -All Kosli CLI calls in [*] are made to _two_ servers (because of 2) +All Kosli CLI calls in [*] are made to _three_ servers (because of 2) - https://app.kosli.com - https://staging.app.kosli.com + - https://app.us.kosli.com -Explicitly making each Kosli CLI call in [*] twice is not an option (because of 1) -Duplicating the entire CI workflows is complex because, eg, deployments must not be duplicated. -The least-worst option is to allow KOSLI_HOST and KOSLI_API_TOKEN to specify two +Explicitly making each Kosli CLI call in [*] three times is not an option (because of 1) +Duplicating the entire CI workflows is complex, eg, deployments must not be duplicated. +The least-worst option is to allow KOSLI_HOST and KOSLI_API_TOKEN to specify multiple comma-separated values. Note cyber-dojo must ensure its api-tokens do not contain commas. */ @@ -52,7 +53,7 @@ func runMultiHost(args []string) (string, error) { args0 := argsAppendHostApiTokenFlags(0) output0, err0 := runBufferedInnerMain(args0) - stdOut := output0 + stdOut := fmt.Sprintf("[%s]\n", opts.hosts[0]) + output0 var errorMessage string if err0 != nil { diff --git a/cmd/kosli/multiHost_test.go b/cmd/kosli/multiHost_test.go index c28238f88..120fca6c5 100644 --- a/cmd/kosli/multiHost_test.go +++ b/cmd/kosli/multiHost_test.go @@ -118,7 +118,7 @@ func (suite *MultiHostTestSuite) TestRunDoubledHost() { { name: "only returns primary call output when both (2) calls succeed", args: doubledArgs([]string{"kosli", "status"}), - stdOut: []string{"OK", ""}, + stdOut: []string{"[http://localhost:8001]", "OK", ""}, err: error(nil), }, } { @@ -153,7 +153,7 @@ func (suite *MultiHostTestSuite) TestRunTripledHost() { { name: "only returns primary call output when all three calls succeed", args: tripledArgs([]string{"kosli", "status"}), - stdOut: []string{"OK", ""}, + stdOut: []string{"[http://localhost:8001]", "OK", ""}, err: error(nil), }, } {