J.U.S.T. Plugins
- J.U.S.T. Docker Plugin
- J.U.S.T. Singularity Plugin
- Container Functions
- J.U.S.T. Bash Coverage Functions
- J.U.S.T. CI Functions
- J.U.S.T. Default Run Functions
- J.U.S.T. Mirror to an Air-gapped Repository
- J.U.S.T. Git Functions
- J.U.S.T. Install CI Functions
- J.U.S.T. Makeself Functions
- J.U.S.T. Pip-tools Functions
- J.U.S.T. Pre-commit Functions
- J.U.S.T. Robodoc Functions
- J.U.S.T. Sphinx Docs Functions
- J.U.S.T. Test Functions
- J.U.S.T. Troubleshooter Functions
J.U.S.T. has a number of useful plugins included. A plugin is a bash
script that can be sourced by a Justfile
and typically adds targets to just
It’s also pretty similar to add a plugin yourself. Similar to a Justfile
, but typically names just_{name}_functions.bsh
, and defines a modified Justfile caseify
that is instead names {name}_defaultify
if [[ $- != *i* ]]; then
source_once &> /dev/null && return 0
fi
JUST_DEFAULTIFY_FUNCTIONS+=(example_defaultify)
JUST_HELP_FILES+=("${BASH_SOURCE[0]}")
function example_defaultify()
{
local just_arg=$1
shift 1
case $just_arg in
example) # Just an example
echo "Example plugin!"
;;
*)
plugin_not_found=1
;;
esac
return 0
}
First we prevent the file from being sourced multiple times with
source_once.bsh
, purely for efficiency reasonsWe update
JUST_DEFAULTIFY_FUNCTIONS
andJUST_HELP_FILES
so that the plugin is called, and parsed forjust help
Then we dive into the plugin’s defaultify (named uniquely for that plugin).
And instead of calling
just_functions.bsh defaultify
in the case’s else, we setplugin_not_found=1
instead. This is required so that other plugins can continue the search.
Now to use this new plugin, you simply add source "${VSI_COMMON_DIR}/linux/just_example_functions.bsh"
(or similar) to your Justfile
Most vsi_common plugins have docker images to support them. This requires a few more steps to setup
Create a new docker file in
${VSI_COMMON_DIR}/docker/vsi_common/{name}.Dockerfile
. This Dockerfile usually needs to be setup like anew_just
Docker project’s docker file, using vsi_common’s entrypoint so that user permissions match.Add the docker to
${VSI_COMMON_DIR}/docker/vsi_common/docker-compose.yml
... example: build: context: . dockerfile: example.Dockerfile image: ${EXAMPLE_IMAGE-vsiri/example:latest} environment: <<: *plugin_environment # Any custom env variables # EXAMPLE_VAR: value # EXAMPLE_COPY_VALUE: # This will auto copy the exported variable value EXAMPLE_COPY_VALUE volumes: - <<: *vsi_common_volume # Add any EXAMPLE dirs here # - type: bind # source: ${EXAMPLE_SOURCE_DIR-} # target: /src
Add some addition logic to
{name}_defaultify
to make calling docker easier
# ... function example_defaultify() { local id_project_cwd="${JUST_PROJECT_PREFIX}_CWD" # Export variables for docker compose file local EXAMPLE_COPY_VALUE="${JUST_PROJECT_PREFIX}_EXAMPLE_COPY_VALUE" export EXAMPLE_COPY_VALUE="${!EXAMPLE_COPY_VALUE:-${!id_project_cwd}}" # These are part of the "plugin_environment" section local UID_CONTAINER="${JUST_PROJECT_PREFIX}_UID" export UID_CONTAINER="${!UID_CONTAINER-1000}" local GIDS_CONTAINER="${JUST_PROJECT_PREFIX}_GIDS" export GIDS_CONTAINER="${!GIDS_CONTAINER-1000}" local JUST_SETTINGS="${JUST_PATH_ESC}/src/$(basename "${JUST_SETTINGS}")" export JUST_SETTINGS local COMPOSE_FILE="${VSI_COMMON_DIR}/docker/vsi_common/docker-compose.yml" export COMPOSE_FILE # ...