Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tecnalia_robotics-public
templates
Commits
25ae5c49
Commit
25ae5c49
authored
Nov 09, 2021
by
Jon Azpiazu
Browse files
Add initial script to add the retention labels to existing image
parent
3c95d5eb
Pipeline
#60003
failed with stage
in 11 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
scripts/enforce_labels.bash
0 → 100644
View file @
25ae5c49
#!/bin/bash
image_name
=
"
$1
"
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
echo
"Error: image does not exist"
exit
0
fi
for
label
in
"
${
!enforced_labels[@]
}
"
;
do
if
!
docker inspect
-f
"{{json .Config.Labels }}"
$image_name
| jq
-e
'.['
\"
$label
\"
']'
;
then
echo
"Key not found"
echo
"
$label
=
${
enforced_labels
[
$label
]
}
"
label_args+
=
" --label
$label
=
\"
${
enforced_labels
[
$label
]
}
\"
"
fi
done
if
[
-v
label_args
]
;
then
run_command
=
"echo
\"
FROM
$image_name
\"
| docker build
$label_args
-t
$image_name
-"
eval
"
$run_command
"
fi
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment