Skip to content

Commit

Permalink
Merge pull request docker-library#13888 from infosiftr/external-pins-tag
Browse files Browse the repository at this point in the history
Add new `.external-pins/tag.sh` script for going from a filename to image:tag
  • Loading branch information
tianon authored Jan 13, 2023
2 parents fe59874 + c87f94c commit aad0efa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .external-pins/file.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# given an image (name:tag), return the appropriate filename

dir="$(dirname "$BASH_SOURCE")"

for img; do
Expand Down
26 changes: 26 additions & 0 deletions .external-pins/tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -Eeuo pipefail

# given a filename, return the appropriate image (name:tag)

origDir="$(dirname "$BASH_SOURCE")"
dir="$(readlink -ve "$origDir")"

for file; do
abs="$(readlink -vm "$file")"
rel="${abs#$dir/}"
rel="${rel##*.external-pins/}" # in case we weren't inside "$dir" but the path is legit
if [ "$rel" = "$abs" ]; then
echo >&2 "error: '$file' is not within '$origDir'"
echo >&2 "('$abs' vs '$dir')"
exit 1
fi

img="${rel/___/:}" # see ".external-pins/list.sh"
if [ "$img" = "$rel" ]; then
echo >&2 "error: '$file' does not contain ':' ('___') -- this violates our assumptions!"
exit 1
fi

echo "$img"
done

0 comments on commit aad0efa

Please sign in to comment.