Automatically lowercasing registry and image name (#86)

* make name lowercase

* Calling toLower

* fixed typo in lowercase method

* Also lowering registry input

* Update test.bats

Adapted tests

* Fixed last Upercases

* Linting

Co-authored-by: Lars Gohr <larsgohr@posteo.de>
This commit is contained in:
Tobias Pieri
2020-05-24 12:24:52 +02:00
committed by GitHub
parent c1a23962ec
commit 014155fcaa
2 changed files with 24 additions and 13 deletions

View File

@@ -9,11 +9,14 @@ main() {
echo "::add-mask::${INPUT_PASSWORD}"
set -x
fi
sanitize "${INPUT_NAME}" "name"
sanitize "${INPUT_USERNAME}" "username"
sanitize "${INPUT_PASSWORD}" "password"
registryToLower
nameToLower
REGISTRY_NO_PROTOCOL=$(echo "${INPUT_REGISTRY}" | sed -e 's/^https:\/\///g')
if uses "${INPUT_REGISTRY}" && ! isPartOfTheName "${REGISTRY_NO_PROTOCOL}"; then
INPUT_NAME="${REGISTRY_NO_PROTOCOL}/${INPUT_NAME}"
@@ -68,6 +71,14 @@ sanitize() {
fi
}
registryToLower(){
INPUT_REGISTRY=$(echo "${INPUT_REGISTRY}" | tr '[A-Z]' '[a-z]')
}
nameToLower(){
INPUT_NAME=$(echo "${INPUT_NAME}" | tr '[A-Z]' '[a-z]')
}
isPartOfTheName() {
[ $(echo "${INPUT_NAME}" | sed -e "s/${1}//g") != "${INPUT_NAME}" ]
}