Skip to content

Commit

Permalink
compiled waitForMysql using go compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
fchastanet committed Sep 7, 2024
1 parent 0ab09ec commit 2bd43f7
Show file tree
Hide file tree
Showing 16 changed files with 1,823 additions and 1,479 deletions.
82 changes: 41 additions & 41 deletions bin/waitForIt
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ optionVersionCallback() {

# options variables initialization
declare optionTimeout="15"
declare optionExecIfTimedOut="0"
declare optionHelp="0"
declare optionConfig="0"
declare optionBashFrameworkConfig=""
Expand All @@ -1263,7 +1264,6 @@ declare optionTheme="default"
declare optionVersion="0"
declare optionQuiet="0"
declare optionAlgo=""
declare optionStrict="0"
declare optionLegacy="0"
# arguments variables initialization
declare hostOrIpArg=""
Expand All @@ -1276,6 +1276,9 @@ waitForItCommandParse() {
optionTimeout="15"
local -i options_parse_optionParsedCountOptionTimeout
((options_parse_optionParsedCountOptionTimeout = 0)) || true
optionExecIfTimedOut="0"
local -i options_parse_optionParsedCountOptionExecIfTimedOut
((options_parse_optionParsedCountOptionExecIfTimedOut = 0)) || true
optionHelp="0"
local -i options_parse_optionParsedCountOptionHelp
((options_parse_optionParsedCountOptionHelp = 0)) || true
Expand Down Expand Up @@ -1319,9 +1322,6 @@ waitForItCommandParse() {
optionAlgo=""
local -i options_parse_optionParsedCountOptionAlgo
((options_parse_optionParsedCountOptionAlgo = 0)) || true
optionStrict="0"
local -i options_parse_optionParsedCountOptionStrict
((options_parse_optionParsedCountOptionStrict = 0)) || true
optionLegacy="0"
local -i options_parse_optionParsedCountOptionLegacy
((options_parse_optionParsedCountOptionLegacy = 0)) || true
Expand Down Expand Up @@ -1365,6 +1365,20 @@ waitForItCommandParse() {
;;

# Option 2/18
# optionExecIfTimedOut alts --exec-command-on-timeout|--lax|-l
# type: Boolean min 0 max 1
--exec-command-on-timeout | --lax | -l)
# shellcheck disable=SC2034
optionExecIfTimedOut="1"

if ((options_parse_optionParsedCountOptionExecIfTimedOut >= 1 )); then
Log::displayError "Command ${SCRIPT_NAME} - Option ${options_parse_arg} - Maximum number of option occurrences reached(1)"
return 1
fi
((++options_parse_optionParsedCountOptionExecIfTimedOut))
;;

# Option 3/18
# optionHelp alts --help|-h
# type: Boolean min 0 max 1
--help | -h)
Expand All @@ -1380,7 +1394,7 @@ waitForItCommandParse() {

;;

# Option 3/18
# Option 4/18
# optionConfig alts --config
# type: Boolean min 0 max 1
--config)
Expand All @@ -1394,7 +1408,7 @@ waitForItCommandParse() {
((++options_parse_optionParsedCountOptionConfig))
;;

# Option 4/18
# Option 5/18
# optionBashFrameworkConfig alts --bash-framework-config
# type: String min 0 max 1
--bash-framework-config)
Expand All @@ -1415,7 +1429,7 @@ waitForItCommandParse() {

;;

# Option 5/18
# Option 6/18
# optionInfoVerbose alts --verbose|-v
# type: Boolean min 0 max 1
--verbose | -v)
Expand All @@ -1433,7 +1447,7 @@ waitForItCommandParse() {

;;

# Option 6/18
# Option 7/18
# optionDebugVerbose alts -vv
# type: Boolean min 0 max 1
-vv)
Expand All @@ -1451,7 +1465,7 @@ waitForItCommandParse() {

;;

# Option 7/18
# Option 8/18
# optionTraceVerbose alts -vvv
# type: Boolean min 0 max 1
-vvv)
Expand All @@ -1469,7 +1483,7 @@ waitForItCommandParse() {

;;

# Option 8/18
# Option 9/18
# optionEnvFiles alts --env-file
# type: StringArray min 0 max -1
--env-file)
Expand All @@ -1487,7 +1501,7 @@ waitForItCommandParse() {

;;

# Option 9/18
# Option 10/18
# optionLogLevel alts --log-level
# type: String min 0 max 1
# authorizedValues: OFF|ERR|ERROR|WARN|WARNING|INFO|DEBUG|TRACE
Expand Down Expand Up @@ -1515,7 +1529,7 @@ waitForItCommandParse() {

;;

# Option 10/18
# Option 11/18
# optionLogFile alts --log-file
# type: String min 0 max 1
--log-file)
Expand All @@ -1538,7 +1552,7 @@ waitForItCommandParse() {

;;

# Option 11/18
# Option 12/18
# optionDisplayLevel alts --display-level
# type: String min 0 max 1
# authorizedValues: OFF|ERR|ERROR|WARN|WARNING|INFO|DEBUG|TRACE
Expand Down Expand Up @@ -1566,7 +1580,7 @@ waitForItCommandParse() {

;;

# Option 12/18
# Option 13/18
# optionNoColor alts --no-color
# type: Boolean min 0 max 1
--no-color)
Expand All @@ -1584,7 +1598,7 @@ waitForItCommandParse() {

;;

# Option 13/18
# Option 14/18
# optionTheme alts --theme
# type: String min 0 max 1
# authorizedValues: default|default-force|noColor
Expand Down Expand Up @@ -1612,7 +1626,7 @@ waitForItCommandParse() {

;;

# Option 14/18
# Option 15/18
# optionVersion alts --version
# type: Boolean min 0 max 1
--version)
Expand All @@ -1628,7 +1642,7 @@ waitForItCommandParse() {

;;

# Option 15/18
# Option 16/18
# optionQuiet alts --quiet|-q
# type: Boolean min 0 max 1
--quiet | -q)
Expand All @@ -1646,7 +1660,7 @@ waitForItCommandParse() {

;;

# Option 16/18
# Option 17/18
# optionAlgo alts --algorithm|--algo
# type: String min 0 max 1
--algorithm | --algo)
Expand All @@ -1667,20 +1681,6 @@ waitForItCommandParse() {

;;

# Option 17/18
# optionStrict alts --exec-command-on-success-only|--strict|-s
# type: Boolean min 0 max 1
--exec-command-on-success-only | --strict | -s)
# shellcheck disable=SC2034
optionStrict="1"

if ((options_parse_optionParsedCountOptionStrict >= 1 )); then
Log::displayError "Command ${SCRIPT_NAME} - Option ${options_parse_arg} - Maximum number of option occurrences reached(1)"
return 1
fi
((++options_parse_optionParsedCountOptionStrict))
;;

# Option 18/18
# optionLegacy alts --user-nc
# type: Boolean min 0 max 1
Expand Down Expand Up @@ -1818,7 +1818,7 @@ waitForItCommandHelp() {
# ------------------------------------------
# usage/options section
# ------------------------------------------
optionsAltList=("[--timeout|-t <timeout>]" "[--help|-h]" "[--config]" "[--bash-framework-config <bash-framework-config>]" "[--verbose|-v]" "[-vv]" "[-vvv]" "[--env-file <env-file>]" "[--log-level <log-level>]" "[--log-file <log-file>]" "[--display-level <display-level>]" "[--no-color]" "[--theme <theme>]" "[--version]" "[--quiet|-q]" "[--algorithm|--algo <algorithm>]" "[--exec-command-on-success-only|--strict|-s]" "[--user-nc]"
optionsAltList=("[--timeout|-t <timeout>]" "[--exec-command-on-timeout|--lax|-l]" "[--help|-h]" "[--config]" "[--bash-framework-config <bash-framework-config>]" "[--verbose|-v]" "[-vv]" "[-vvv]" "[--env-file <env-file>]" "[--log-level <log-level>]" "[--log-file <log-file>]" "[--display-level <display-level>]" "[--no-color]" "[--theme <theme>]" "[--version]" "[--quiet|-q]" "[--algorithm|--algo <algorithm>]" "[--user-nc]"
)
Array::wrap2 " " 80 2 "${__HELP_TITLE_COLOR}USAGE:${__RESET_COLOR}" \
"waitForIt" "${optionsAltList[@]}"
Expand Down Expand Up @@ -1854,6 +1854,12 @@ waitForItCommandHelp() {

Array::wrap2 ' ' 76 6 " Default value: " "15"
echo

echo -e " ${__HELP_OPTION_COLOR}--exec-command-on-timeout${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}--lax${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-l${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Execute sub-command even if timeout is reached."
echo


echo
echo -e "${__HELP_TITLE_COLOR}GLOBAL OPTIONS:${__RESET_COLOR}"
echo -e " ${__HELP_OPTION_COLOR}--help${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-h${__HELP_NORMAL} {single}"
Expand Down Expand Up @@ -1952,12 +1958,6 @@ waitForItCommandHelp() {



echo -e " ${__HELP_OPTION_COLOR}--exec-command-on-success-only${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}--strict${__HELP_NORMAL}, ${__HELP_OPTION_COLOR}-s${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Only execute sub-command if the test succeeds."
echo



echo -e " ${__HELP_OPTION_COLOR}--user-nc${__HELP_NORMAL} {single}"
Array::wrap2 ' ' 76 4 " " "Legacy mode using nc command or while loop (uses timeout command by default)."
echo
Expand Down Expand Up @@ -2046,7 +2046,7 @@ whileLoop() {
fi
if ((optionTimeout != 0 && SECONDS - start_ts >= optionTimeout)); then
if [[ "${reportTimeout}" = "1" ]]; then
Log::displayError "${SCRIPT_NAME} - timeout for ${hostOrIpArg}:${portArg} occurred after $((SECONDS - start_ts)) seconds"
Log::displayError "${SCRIPT_NAME} - timeout for ${hostOrIpArg}:${portArg} occurred after $((SECONDS - start_ts)) seconds > ${optionTimeout}"
fi
return 2
fi
Expand Down Expand Up @@ -2162,7 +2162,7 @@ else
"${algo}" || result=$?
# when timed out, call command if any
if [[ -n "${commandArgs+x}" && "${commandArgs[*]}" != "" ]]; then
if [[ "${result}" != "0" && "${optionStrict}" = "1" ]]; then
if [[ "${result}" != "0" && "${optionExecIfTimedOut}" = "0" ]]; then
Log::displayError "${SCRIPT_NAME} - failed to connect - strict mode - command not executed"
exit "${result}"
fi
Expand Down
Loading

0 comments on commit 2bd43f7

Please sign in to comment.