Skip to content

Commit

Permalink
Add build args for recipes
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Neff <[email protected]>
  • Loading branch information
andyneff committed Dec 12, 2023
1 parent af7f86b commit a59576f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 8 additions & 1 deletion linux/just_files/just_docker_functions.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ function get_docker_recipes()
# .. command:: build_recipes
#
# :Arguments: [``$1``]... - Recipe names to run
# :Parameters: ``JUST_RECIPE_BUILDARGS`` - Array of build args to be added to every recipe (e.g. ``FOO=BAR``).
#
# Runs ``docker compose build`` for the docker recipes. Useful command to call before ``docker build`` on your own project that uses recipes in vsi_common, to keep them synced with your build.
#
Expand Down Expand Up @@ -346,8 +347,14 @@ function docker_defaultify()
shift 1
case ${arg} in
build_recipes) # Build recipes
local build_args=()
local build_arg
for build_arg in ${JUST_RECIPE_BUILDARGS[@]+"${JUST_RECIPE_BUILDARGS[@]}"}; do
build_args+=(--set "*.args.${build_arg}")
done

pushd "${VSI_COMMON_DIR}/docker/recipes/" &> /dev/null
Docker buildx bake ${@+"${@}"}
Docker buildx bake ${build_args[@]+"${build_args[@]}"} ${@+"${@}"}
popd &> /dev/null
extra_args=${#}
;;
Expand Down
26 changes: 26 additions & 0 deletions linux/just_files/just_functions.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,32 @@ function safe_load() # Loads a very simple safe config file, and sets environmen
done < "${1}"
}

#**
# .. function:: just_error
#
# Helper function to be combined with calls to print a useful error message on error.
#
# Errors captured by :func:`just_functions.bsh just_error` will not print out an error stack.
#
# :Arguments: Inputs ``$1...`` - Message to echo on error
#
# :Return Value: * Returns the same return value of the previously run command
#
# :Output: Echos message
#
# .. rubric:: Example
#
# .. code-block:: bash
#
# run_some_command || just_error "That command failed, here's some helpful advise"
#**
function just_error()
{
JUST_IGNORE_EXIT_CODES=${?}
echo ${@+"${@}"}
return "${JUST_IGNORE_EXIT_CODES}"
}

#**
# .. file:: .justplugins
#
Expand Down

0 comments on commit a59576f

Please sign in to comment.