File tree 3 files changed +38
-16
lines changed
scaletest/templates/scaletest-runner
3 files changed +38
-16
lines changed Original file line number Diff line number Diff line change @@ -210,3 +210,33 @@ wait_baseline() {
210
210
maybedryrun " $DRY_RUN " sleep $(( s * 60 ))
211
211
PHASE_TYPE=" phase-wait" end_phase
212
212
}
213
+
214
+ get_appearance () {
215
+ session_token=$CODER_SESSION_TOKEN
216
+ if [[ -f " ${CODER_CONFIG_DIR} /session" ]]; then
217
+ session_token=" $( < " ${CODER_CONFIG_DIR} /session" ) "
218
+ fi
219
+ curl -sSL \
220
+ -H " Coder-Session-Token: ${session_token} " \
221
+ " ${CODER_URL} /api/v2/appearance"
222
+ }
223
+ set_appearance () {
224
+ local json=$1 color=$2 message=$3
225
+
226
+ session_token=$CODER_SESSION_TOKEN
227
+ if [[ -f " ${CODER_CONFIG_DIR} /session" ]]; then
228
+ session_token=" $( < " ${CODER_CONFIG_DIR} /session" ) "
229
+ fi
230
+ newjson=" $(
231
+ jq \
232
+ --arg color " ${color} " \
233
+ --arg message " ${message} " \
234
+ ' . | .service_banner.message |= $message | .service_banner.background_color |= $color' <<< " ${json}"
235
+ ) "
236
+ maybedryrun " ${DRY_RUN} " curl -sSL \
237
+ -X PUT \
238
+ -H ' Content-Type: application/json' \
239
+ -H " Coder-Session-Token: ${session_token} " \
240
+ --data " ${newjson} " \
241
+ " ${CODER_URL} /api/v2/appearance"
242
+ }
Original file line number Diff line number Diff line change @@ -16,3 +16,10 @@ annotate_grafana "workspace" "Agent stopping..."
16
16
" ${SCRIPTS_DIR} /cleanup.sh" shutdown
17
17
18
18
annotate_grafana_end " workspace" " Agent running"
19
+
20
+ appearance_json=" $( get_appearance) "
21
+ service_banner_message=$( jq -r ' .service_banner.message' <<< " ${appearance_json}" )
22
+ service_banner_message=" ${service_banner_message/% | */ } "
23
+ service_banner_color=" #4CD473" # Green.
24
+
25
+ set_appearance " ${service_banner_color} " " ${service_banner_message} "
Original file line number Diff line number Diff line change 21
21
# shellcheck disable=SC2153 source=scaletest/templates/scaletest-runner/scripts/lib.sh
22
22
. " ${SCRIPTS_DIR} /lib.sh"
23
23
24
- appearance_json=" $(
25
- curl -sSL \
26
- -H " Coder-Session-Token: ${CODER_USER_TOKEN} " \
27
- " ${CODER_URL} /api/v2/appearance"
28
- ) "
24
+ appearance_json=" $( get_appearance) "
29
25
service_banner_message=$( jq -r ' .service_banner.message' <<< " ${appearance_json}" )
30
26
service_banner_message=" ${service_banner_message/% | */ } "
31
27
service_banner_color=" #D65D0F" # Orange.
32
28
33
- set_appearance () {
34
- local color=$1 message=$2
35
- jq --arg color " ${color} " --arg message " ${message} " ' . | .service_banner.message |= $message | .service_banner.background_color |= $color' <<< " ${appearance_json}" \
36
- | curl -sSL \
37
- -X ' PUT' \
38
- -H ' Content-Type: application/json' \
39
- -H " Coder-Session-Token: ${CODER_USER_TOKEN} " \
40
- --data @- \
41
- " ${CODER_URL} /api/v2/appearance"
42
- }
43
-
44
29
annotate_grafana " workspace" " Agent running" # Ended in shutdown.sh.
45
30
46
31
{
You can’t perform that action at this time.
0 commit comments