Skip to content

Commit e345c79

Browse files
committed
docker: better readability
Signed-off-by: Vitor Bandeira <[email protected]>
1 parent 2f0d0cb commit e345c79

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

etc/DockerHelper.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ EOF
3636
}
3737

3838
_setup() {
39-
commitSha="$(git rev-parse HEAD)"
40-
commitSha="$(echo "$commitSha" | tr -cd 'a-zA-Z0-9-')"
39+
commitSha="$(git rev-parse HEAD | tr -cd 'a-zA-Z0-9-')"
4140
case "${os}" in
4241
"ubuntu20.04")
4342
osBaseImage="ubuntu:20.04"
@@ -91,11 +90,11 @@ _create() {
9190
_push() {
9291
if [[ -z ${username+x} ]]; then
9392
echo "Missing required -username=<USER> argument"
94-
exit 1
93+
_help
9594
fi
9695
if [[ -z ${password+x} ]]; then
9796
echo "Missing required -password=<PASS> argument"
98-
exit 1
97+
_help
9998
fi
10099
docker login --username ${username} --password ${password}
101100
if [[ "${tag}" == "NONE" ]]; then
@@ -123,7 +122,7 @@ _push() {
123122
;;
124123

125124
*)
126-
echo "Target ${target} is not valid candidate for push to DockerHub." >&2
125+
echo "Target ${target} is not valid candidate for push to Docker Hub." >&2
127126
_help
128127
;;
129128
esac
@@ -152,7 +151,7 @@ if [[ -z $(command -v "${_rule}") ]]; then
152151
_help
153152
fi
154153

155-
# default values, can be overwritten by cmdline args
154+
# default values, can be overwritten by command line arguments
156155
os="ubuntu22.04"
157156
target="dev"
158157
numThreads="-1"
@@ -164,6 +163,9 @@ while [ "$#" -gt 0 ]; do
164163
-h|-help)
165164
_help 0
166165
;;
166+
-ci )
167+
options="-ci"
168+
;;
167169
-os=* )
168170
os="${1#*=}"
169171
;;
@@ -173,13 +175,6 @@ while [ "$#" -gt 0 ]; do
173175
-threads=* )
174176
numThreads="${1#*=}"
175177
;;
176-
-ci )
177-
options="-ci"
178-
;;
179-
-os | -target )
180-
echo "${1} requires an argument" >&2
181-
_help
182-
;;
183178
-username=* )
184179
username="${1#*=}"
185180
;;
@@ -189,6 +184,10 @@ while [ "$#" -gt 0 ]; do
189184
-tag=* )
190185
tag="${1#*=}"
191186
;;
187+
-os | -target | -threads | -username | -password | -tag )
188+
echo "${1} requires an argument" >&2
189+
_help
190+
;;
192191
*)
193192
echo "unknown option: ${1}" >&2
194193
_help

0 commit comments

Comments
 (0)