Skip to content

Commit 1f491dd

Browse files
authored
Merge pull request #460 from kosli-dev/add-faq-for-stream-multiplexing
Add FAQ on stdout/stderr being multiplexec in CI workflows
2 parents 94bfec9 + ccc5277 commit 1f491dd

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

docs.kosli.com/content/faq/_index.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,50 @@ env:
7878
KOSLI_API_TOKEN: ${{ secrets.kosli_api_token }}
7979
```
8080

81+
## I'm running the Kosli CLI in a subshell and the captured output includes stderr!
82+
83+
The Kosli CLI writes debug information to `stderr`, and all other output to `stdout`.
84+
Normally, in a bash $(subshell), only `stdout` is captured.
85+
In the following example, the `DIGEST` variable captures _only_ the 64 character digest of the docker image;
86+
the extra debug information is printed to the terminal.
87+
88+
```shell {.command}
89+
# In a local terminal
90+
KOSLI_DEBUG=true
91+
DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker)"
92+
93+
[debug] calculated fingerprint: 2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e for artifact: 244531986313.dkr.ecr.eu-central-1.amazonaws.com/exercises-start-points:86f9052
94+
95+
echo "DIGEST=${DIGEST}"
96+
DIGEST=2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e
97+
```
98+
99+
However, in many CI workflows (including Github and Gitlab), `stdout` and `stderr` are multiplexed together.
100+
This means `DIGEST` will contain _both_ the 64 character digest _and_ the debug information.
101+
For example:
102+
103+
```shell {.command}
104+
# In a CI workflow
105+
KOSLI_DEBUG=true
106+
DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker)"
107+
108+
echo "DIGEST=${DIGEST}"
109+
DIGEST=[debug] calculated fingerprint: 2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e for artifact: 244531986313.dkr.ecr.eu-central-1.amazonaws.com/exercises-start-points:86f9052
110+
2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e
111+
```
112+
113+
When running the Kosli CLI in a subshell, in a CI workflow, we recommend explicitly setting the `--debug` flag to false.
114+
115+
```shell {.command}
116+
# In a CI workflow
117+
KOSLI_DEBUG=true
118+
DIGEST="$(kosli fingerprint "${IMAGE_NAME}" --artifact-type=docker --debug=false)"
119+
120+
echo "DIGEST=${DIGEST}"
121+
DIGEST=2c6079df58292ed10e8074adcb74be549b7f841a1bd8266f06bb5c518643193e
122+
```
123+
124+
81125
## Where can I find API documentation?
82126

83127
Kosli API documentation is available for logged in Kosli users here: https://app.kosli.com/api/v2/doc/

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ require (
195195
go.uber.org/zap v1.26.0 // indirect
196196
golang.org/x/crypto v0.35.0 // indirect
197197
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
198-
golang.org/x/net v0.35.0 // indirect
198+
golang.org/x/net v0.36.0 // indirect
199199
golang.org/x/sync v0.11.0 // indirect
200200
golang.org/x/sys v0.30.0 // indirect
201201
golang.org/x/term v0.29.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,8 @@ golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
950950
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
951951
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
952952
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
953-
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
954-
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
953+
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
954+
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
955955
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
956956
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
957957
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

0 commit comments

Comments
 (0)