Created
July 29, 2015 00:36
-
-
Save guessi/ba752cb412fc77685495 to your computer and use it in GitHub Desktop.
validation image name for docker agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PATTERN="^([a-z0-9]+([._-]{0,1}[a-z0-9])*\/)*[a-zA-Z0-9]+([._-]{0,1}[a-z0-9])*(:[A-Za-z0-9][A-Za-z0-9.-]*){0,1}$" | |
for input in \ | |
i \ | |
image \ | |
i:t \ | |
i:t::: \ | |
image:t \ | |
i:tag \ | |
r/i \ | |
r/i: \ | |
r/i:t \ | |
repo/i \ | |
repo/i:t \ | |
repo/i:t: \ | |
repo/i:t:t2 \ | |
repo_/i \ | |
repo_test/i \ | |
repo__test/i \ | |
repo.s-i_tory/i; do | |
printf "input: %-16s ---> " $input | |
echo "$input" | egrep -q -s "${PATTERN}" | |
[ $? -eq 0 ] && echo "pass (0)" || echo "fail (1)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment