client: plugins: refactor example plugin
- Dynamically construct instance * Platform and tag should not be hard-coded - Add note regarding construction - Refactor main()
This commit is contained in:
@@ -38,8 +38,12 @@
|
||||
[ -z "$DOCKER_FINANCE_CLIENT_REPO" ] && exit 1
|
||||
source "${DOCKER_FINANCE_CLIENT_REPO}/client/src/docker/lib/lib_docker.bash"
|
||||
|
||||
[[ -z "$global_platform" || -z "$global_arg_delim_1" || -z "$global_user" || -z "$global_tag" ]] && lib_utils::die_fatal
|
||||
instance="${global_platform}${global_arg_delim_1}${global_user}:${global_tag}"
|
||||
|
||||
# Initialize "constructor"
|
||||
lib_docker::docker "archlinux/${USER}:default"
|
||||
# NOTE: "constructor" only needed if calling library directly
|
||||
lib_docker::docker "$instance" || lib_utils::die_fatal
|
||||
|
||||
#
|
||||
# Implementation
|
||||
@@ -47,20 +51,16 @@ lib_docker::docker "archlinux/${USER}:default"
|
||||
|
||||
function main()
|
||||
{
|
||||
[ -z "$global_arg_delim_1" ] && exit 1
|
||||
[ -z "$global_arg_delim_2" ] && exit 1
|
||||
[ -z "$global_platform" ] && exit 1
|
||||
[ -z "$global_tag" ] && exit 1
|
||||
[ -z "$global_user" ] && exit 1
|
||||
[ -z "$global_arg_delim_2" ] && lib_utils::die_fatal
|
||||
|
||||
echo -e "
|
||||
local -r _example="
|
||||
This clients's environment:
|
||||
|
||||
$(printenv | grep ^DOCKER_FINANCE | sort)
|
||||
|
||||
This plugin's caller image:
|
||||
This plugin's caller instance:
|
||||
|
||||
"${global_platform}${global_arg_delim_1}${global_user}:${global_tag}"
|
||||
$instance
|
||||
|
||||
This plugin's path is:
|
||||
|
||||
@@ -70,10 +70,11 @@ This plugin's arguments:
|
||||
|
||||
'${*}'
|
||||
|
||||
Showing current version:"
|
||||
Showing current version:
|
||||
$(lib_docker::version type${global_arg_delim_2}short)
|
||||
|
||||
lib_docker::version type${global_arg_delim_2}short
|
||||
echo
|
||||
"
|
||||
lib_utils::print_custom "$_example"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user