Skip to content

Commit

Permalink
justfile: Hide DOCKER_SOCKET command output
Browse files Browse the repository at this point in the history
The justfile would use a command snippet starting with "set -x" to
determine the path of the Docker socket: this helps for debugging, but
most of the time it only prints cryptic messages to the console each
time we run just.

Make just print the output only when we set "debug=true". We cannot use
a variable in the triple-backquoted string, so we need a level of
indirection with a separate command and a call to shell(). We also need
to append a semicolon to "set -x" when set, and we use replace_regex()
for this.

Signed-off-by: Quentin Monnet <[email protected]>
  • Loading branch information
qmonnet committed Dec 11, 2024
1 parent be2d97f commit ea89529
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ _dev_env_container := _dpdk_sys_container_repo + "/dev-env:" + _dpdk_sys_contain
_doc_env_container := _dpdk_sys_container_repo + "/doc-env:" + _dpdk_sys_container_tag
_compile_env_container := _dpdk_sys_container_repo + "/compile-env:" + _dpdk_sys_container_tag
_network := "host"
export DOCKER_HOST := x"${DOCKER_HOST:-unix:///var/run/docker.sock}"
export DOCKER_SOCK := ```
set -x
_docker_sock_cmd := replace_regex(_just_debuggable_, ".*", "$0;") + '''
declare -r DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
declare -r without_unix="${DOCKER_HOST##unix://}"
if [ -S "${without_unix}" ]; then
printf -- '%s' "${without_unix}"
elif [ -S /var/run/docker.sock ]; then
printf -- '%s' "/var/run/docker.sock"
fi
```
'''
export DOCKER_HOST := x"${DOCKER_HOST:-unix:///var/run/docker.sock}"
export DOCKER_SOCK := shell(_docker_sock_cmd)

# The git commit hash of the last commit to HEAD
# We allow this command to fail in the sterile environment because git is not available there
Expand Down

0 comments on commit ea89529

Please sign in to comment.