Commit 2c21e985 authored by Jon Azpiazu's avatar Jon Azpiazu
Browse files

Minor style fixes to script

parent 25ae5c49
Pipeline #60009 failed with stage
in 20 seconds
#!/bin/bash #!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Usage: $0 IMAGE_NAME"
exit 1
fi
image_name="$1" image_name="$1"
declare -A enforced_labels=( ["com.jfrog.artifactory.retention.maxCount"]="10" ["com.jfrog.artifactory.retention.maxDays"]="7") declare -A enforced_labels=( ["com.jfrog.artifactory.retention.maxCount"]="10" ["com.jfrog.artifactory.retention.maxDays"]="7")
if ! docker inspect --type=image $1 > /dev/null ; then if ! docker inspect --type=image "$1" > /dev/null ; then
echo "Error: image does not exist" echo "Error: image does not exist"
exit 0 exit 0
fi fi
for label in "${!enforced_labels[@]}" ; do for label in "${!enforced_labels[@]}" ; do
if ! docker inspect -f "{{json .Config.Labels }}" $image_name | jq -e '.['\"$label\"']' ; then if ! docker inspect -f "{{json .Config.Labels }}" "$image_name" | jq -e '.['\"$label\"']' ; then
echo "Key not found" echo "Key not found"
echo "$label = ${enforced_labels[$label]}" echo "$label = ${enforced_labels[$label]}"
label_args+=" --label $label=\"${enforced_labels[$label]}\"" label_args+=" --label $label=\"${enforced_labels[$label]}\""
...@@ -19,5 +24,5 @@ done ...@@ -19,5 +24,5 @@ done
if [ -v label_args ]; then if [ -v label_args ]; then
run_command="echo \"FROM $image_name\" | docker build $label_args -t $image_name -" run_command="echo \"FROM $image_name\" | docker build $label_args -t $image_name -"
eval "$run_command" echo "$run_command"
fi fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment