gitlab-runner: write config as toml, don't clobber existing file

The previous command would fail because of datetimes not being
representable as JSON, wiping the config entirely because of the
`sponge` invocation that doesn't care whether the program piped in
fails.
This commit is contained in:
Linus Heckemann 2025-05-12 13:08:59 +02:00
parent 43975d782b
commit 4cabc9c286

View file

@ -19,6 +19,7 @@ let
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
'' else ''
set -e
export CONFIG_FILE=${configPath}
mkdir -p $(dirname ${configPath})
@ -92,8 +93,8 @@ let
done
# update global options
remarshal --if toml --of json ${configPath} \
| jq -cM ${escapeShellArg (concatStringsSep " | " [
tomlq -t \
${escapeShellArg (concatStringsSep " | " [
".check_interval = ${toJSON cfg.checkInterval}"
".concurrent = ${toJSON cfg.concurrent}"
".sentry_dsn = ${toJSON cfg.sentryDSN}"
@ -103,9 +104,9 @@ let
".session_server.session_timeout = ${toJSON cfg.sessionServer.sessionTimeout}"
"del(.[] | nulls)"
"del(.session_server[] | nulls)"
])} \
| remarshal --if json --of toml \
| sponge ${configPath}
])} ${configPath} \
> config.toml.new
mv config.toml.new ${configPath}
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
@ -559,7 +560,7 @@ in
gawk
jq
moreutils
remarshal
yq
# util-linux
cfg.package
coreutils