-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
192 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
function generate_dockerimagename() { | ||
local NEWNAME | ||
NEWNAME="$(cat /proc/sys/kernel/random/uuid)" | ||
NEWNAME="${NEWNAME%%-*}" | ||
echo "$NEWNAME" | ||
} | ||
|
||
function correct_dockerimagename() { | ||
local IMNAME="$1" | ||
local BASE TAG | ||
|
||
# Correct NEWNAME | ||
IFS=':' read BASE TAG <<< "${IMNAME}" | ||
if [ "$TAG" == "" ]; then | ||
IMNAME="${IMNAME}:latest" | ||
fi | ||
echo "$IMNAME" | ||
} | ||
|
||
_INSPECT_STRING= | ||
_INSPECT_IMAGE= | ||
function get_config_field() { | ||
local IMAGE="$1" | ||
local FIELD="$2" | ||
local RAW_JQ="$3" | ||
local C_RESULT | ||
|
||
if [ "$_INSPECT_IMAGE" != "$IMAGE" ]; then | ||
_INSPECT_STRING="$(docker inspect $IMAGE)" | ||
_INSPECT_IMAGE="$IMAGE" | ||
fi | ||
|
||
C_RESULT="$(echo "$_INSPECT_STRING" | jq -r "if .[].Config.${FIELD} != null then if .[].Config.${FIELD}${RAW_JQ} | type == \"array\" then .[].Config.${FIELD}${RAW_JQ} | .[] else .[].Config.${FIELD}${RAW_JQ} end else null end")" | ||
echo "$(trim "$C_RESULT")" | ||
} | ||
|
||
function get_config_field_raw() { | ||
local IMAGE="$1" | ||
local FIELD="$2" | ||
local RAW_JQ="$3" | ||
local C_RESULT | ||
|
||
if [ "$_INSPECT_IMAGE" != "$IMAGE" ]; then | ||
_INSPECT_STRING="$(docker inspect $IMAGE)" | ||
_INSPECT_IMAGE="$IMAGE" | ||
fi | ||
|
||
C_RESULT="$(echo "$_INSPECT_STRING" | jq -r "if .[].Config.${FIELD} != null then .[].Config.${FIELD}${RAW_JQ} else null end")" | ||
echo "$(trim "$C_RESULT")" | ||
} |