:-'Generic Commit'
This commit is contained in:
24
sos/sos
24
sos/sos
@ -49,20 +49,32 @@ function upload() {
|
||||
|
||||
[ -f "$file" ] || die "File not found: $file"
|
||||
|
||||
# if the label doesn't have a tag, add :lastest
|
||||
if [[ ! "$label" =~ : ]]; then
|
||||
label="$label:latest"
|
||||
fi
|
||||
|
||||
# upload the file
|
||||
TARGET_URL="https://$server/upload"
|
||||
echo "Uploading $file to $TARGET_URL"
|
||||
|
||||
DATETIME=$(datetime)
|
||||
|
||||
# if the label doesn't have a tag, add :lastest
|
||||
[[ "$label" =~ : ]] || label="$label:latest"
|
||||
label_base=$(echo "$label" | cut -d':' -f1)
|
||||
|
||||
LABELTAGS=(
|
||||
"$label"
|
||||
"$label_base:$DATETIME"
|
||||
"$label_base:latest"
|
||||
)
|
||||
# deduplicate the labeltags
|
||||
mapfile -t LABELTAGS < <(printf "%s\n" "${LABELTAGS[@]}" | sort -u)
|
||||
LABELTAGS_JSON=$(printf '"%s",' "${LABELTAGS[@]}")
|
||||
LABELTAGS_JSON="[${LABELTAGS_JSON%,}]"
|
||||
|
||||
METADATA_JSON=$(cat <<EOF
|
||||
{
|
||||
"labeltags": ["$label"],
|
||||
"labeltags": "$LABELTAGS_JSON",
|
||||
"description": "Uploaded by sos",
|
||||
"version": "$(datetime)"
|
||||
"version": "$DATETIME"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
Reference in New Issue
Block a user