mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
feat: add porcelain output (#1337)
* feat: add porcaline output * feat(du-cli): add create-stale action add create-stale action Signed-off-by: nils måsén * test(flags): add alias tests * fix stray format string ref * fix shell liniting problems * feat(du-cli): remove created images * add test for common template * fix interval/schedule logic * use porcelain arg as template version * fix editor save artifacts * use simpler v1 template Signed-off-by: nils måsén
This commit is contained in:
parent
a429c373ff
commit
7900471f88
13 changed files with 344 additions and 63 deletions
|
@ -122,4 +122,65 @@ function container-started() {
|
|||
return 1
|
||||
fi
|
||||
docker container inspect "$Name" | jq -r .[].State.StartedAt
|
||||
}
|
||||
|
||||
|
||||
function container-exists() {
|
||||
local Name=$1
|
||||
if [ -z "$Name" ]; then
|
||||
echo "NAME missing"
|
||||
return 1
|
||||
fi
|
||||
|
||||
docker container inspect "$Name" 1> /dev/null 2> /dev/null
|
||||
}
|
||||
|
||||
function registry-exists() {
|
||||
container-exists "$CONTAINER_PREFIX-registry"
|
||||
}
|
||||
|
||||
function create-container() {
|
||||
local container_name=$1
|
||||
if [ -z "$container_name" ]; then
|
||||
echo "NAME missing"
|
||||
return 1
|
||||
fi
|
||||
local image_name="${2:-$container_name}"
|
||||
|
||||
echo -en "Creating \e[94m$container_name\e[0m container... "
|
||||
local result
|
||||
result=$(docker run -d --name "$container_name" "$(registry-host)/$image_name" 2>&1)
|
||||
if [ "${#result}" -eq 64 ]; then
|
||||
echo -e "\e[92m${result:0:12}\e[0m"
|
||||
return 0
|
||||
else
|
||||
echo -e "\e[91mFailed!\n\e[97m$result\e[0m"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function remove-images() {
|
||||
local image_name=$1
|
||||
if [ -z "$image_name" ]; then
|
||||
echo "NAME missing"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local images
|
||||
mapfile -t images < <(docker images -q "$image_name" | uniq)
|
||||
if [ -n "${images[*]}" ]; then
|
||||
docker image rm "${images[@]}"
|
||||
else
|
||||
echo "No images matched \"$image_name\""
|
||||
fi
|
||||
}
|
||||
|
||||
function remove-repo-images() {
|
||||
local image_name=$1
|
||||
if [ -z "$image_name" ]; then
|
||||
echo "NAME missing"
|
||||
return 1
|
||||
fi
|
||||
|
||||
remove-images "$(registry-host)/images/$image_name"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue