Fix shellcheck items found by shellcheck 0.7.1
This commit is contained in:
parent
8e34f46bad
commit
794fb45e0e
@ -7,28 +7,33 @@ get_image_label() {
|
|||||||
local label=$1
|
local label=$1
|
||||||
local image=$2
|
local image=$2
|
||||||
local tag=$3
|
local tag=$3
|
||||||
local token=$(_get_token $image)
|
local token
|
||||||
local digest=$(_get_digest $image $tag $token)
|
token=$(_get_token "$image")
|
||||||
|
local digest
|
||||||
|
digest=$(_get_digest "$image" "$tag" "$token")
|
||||||
local retval="null"
|
local retval="null"
|
||||||
if [ $digest != "null" ]; then
|
if [ "$digest" != "null" ]; then
|
||||||
retval=$(_get_image_configuration $image $token $digest $label)
|
retval=$(_get_image_configuration "$image" "$token" "$digest" "$label")
|
||||||
fi
|
fi
|
||||||
echo $retval
|
echo "$retval"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_layers() {
|
get_image_layers() {
|
||||||
local image=$1
|
local image=$1
|
||||||
local tag=$2
|
local tag=$2
|
||||||
local token=$(_get_token $image)
|
local token
|
||||||
_get_layers $image $tag $token
|
token=$(_get_token "$image")
|
||||||
|
_get_layers "$image" "$tag" "$token"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_last_layer() {
|
get_image_last_layer() {
|
||||||
local image=$1
|
local image=$1
|
||||||
local tag=$2
|
local tag=$2
|
||||||
local token=$(_get_token $image)
|
local token
|
||||||
local layers=($(_get_layers $image $tag $token))
|
token=$(_get_token "$image")
|
||||||
echo ${layers[-1]}
|
local layers
|
||||||
|
mapfile -t layers < <(_get_layers "$image" "$tag" "$token")
|
||||||
|
echo "${layers[-1]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_image_configuration() {
|
_get_image_configuration() {
|
||||||
|
20
build.sh
20
build.sh
@ -172,9 +172,9 @@ PROJECT_VERSION="${PROJECT_VERSION-$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]
|
|||||||
|
|
||||||
# Get the Git information from the netbox directory
|
# Get the Git information from the netbox directory
|
||||||
if [ -d "${NETBOX_PATH}/.git" ]; then
|
if [ -d "${NETBOX_PATH}/.git" ]; then
|
||||||
NETBOX_GIT_REF=$(cd ${NETBOX_PATH}; git rev-parse HEAD)
|
NETBOX_GIT_REF=$(cd "${NETBOX_PATH}"; git rev-parse HEAD)
|
||||||
NETBOX_GIT_BRANCH=$(cd ${NETBOX_PATH}; git rev-parse --abbrev-ref HEAD)
|
NETBOX_GIT_BRANCH=$(cd "${NETBOX_PATH}"; git rev-parse --abbrev-ref HEAD)
|
||||||
NETBOX_GIT_URL=$(cd ${NETBOX_PATH}; git remote get-url origin)
|
NETBOX_GIT_URL=$(cd "${NETBOX_PATH}"; git remote get-url origin)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -253,19 +253,19 @@ for DOCKER_TARGET in "${DOCKER_TARGETS[@]}"; do
|
|||||||
SHOULD_BUILD="true"
|
SHOULD_BUILD="true"
|
||||||
BUILD_REASON="${BUILD_REASON} interactive"
|
BUILD_REASON="${BUILD_REASON} interactive"
|
||||||
fi
|
fi
|
||||||
if [ $DOCKER_REGISTRY = "docker.io" ] && [ $SHOULD_BUILD = "false" ]; then
|
if [ "$DOCKER_REGISTRY" = "docker.io" ] && [ "$SHOULD_BUILD" = "false" ]; then
|
||||||
source ./build-functions/get-public-image-config.sh
|
source ./build-functions/get-public-image-config.sh
|
||||||
IFS=':' read -ra DOCKER_FROM_SPLIT <<< "${DOCKER_FROM}"
|
IFS=':' read -ra DOCKER_FROM_SPLIT <<< "${DOCKER_FROM}"
|
||||||
if ! [[ ${DOCKER_FROM_SPLIT[0]} =~ ".*/.*" ]]; then
|
if ! [[ ${DOCKER_FROM_SPLIT[0]} =~ .*/.* ]]; then
|
||||||
# Need to use "library/..." for images the have no two part name
|
# Need to use "library/..." for images the have no two part name
|
||||||
DOCKER_FROM_SPLIT[0]="library/${DOCKER_FROM_SPLIT[0]}"
|
DOCKER_FROM_SPLIT[0]="library/${DOCKER_FROM_SPLIT[0]}"
|
||||||
fi
|
fi
|
||||||
PYTHON_LAST_LAYER=$(get_image_last_layer ${DOCKER_FROM_SPLIT[0]} ${DOCKER_FROM_SPLIT[1]})
|
PYTHON_LAST_LAYER=$(get_image_last_layer "${DOCKER_FROM_SPLIT[0]}" "${DOCKER_FROM_SPLIT[1]}")
|
||||||
IMAGES_LAYERS_OLD=($(get_image_layers ${DOCKER_ORG}/${DOCKER_REPO} ${TAG}))
|
mapfile -t IMAGES_LAYERS_OLD < <(get_image_layers "${DOCKER_ORG}"/"${DOCKER_REPO}" "${TAG}")
|
||||||
NETBOX_GIT_REF_OLD=$(get_image_label NETBOX_GIT_REF ${DOCKER_ORG}/${DOCKER_REPO} ${TAG})
|
NETBOX_GIT_REF_OLD=$(get_image_label NETBOX_GIT_REF "${DOCKER_ORG}"/"${DOCKER_REPO}" "${TAG}")
|
||||||
GIT_REF_OLD=$(get_image_label org.label-schema.vcs-ref ${DOCKER_ORG}/${DOCKER_REPO} ${TAG})
|
GIT_REF_OLD=$(get_image_label org.label-schema.vcs-ref "${DOCKER_ORG}"/"${DOCKER_REPO}" "${TAG}")
|
||||||
|
|
||||||
if ! printf '%s\n' ${IMAGES_LAYERS_OLD[@]} | grep -q -P "^${PYTHON_LAST_LAYER}\$"; then
|
if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${PYTHON_LAST_LAYER}\$"; then
|
||||||
SHOULD_BUILD="true"
|
SHOULD_BUILD="true"
|
||||||
BUILD_REASON="${BUILD_REASON} python"
|
BUILD_REASON="${BUILD_REASON} python"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user