Add colors to output

This commit is contained in:
Eric Nemchik 2020-07-01 14:00:05 -05:00
parent 4513b63eeb
commit 5142e0aebd
7 changed files with 119 additions and 90 deletions

View file

@ -54,8 +54,8 @@ ValidateInput()
# Validate GITHUB_WORKSPACE # # Validate GITHUB_WORKSPACE #
############################ ############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
@ -66,8 +66,8 @@ ValidateInput()
####################### #######################
if [ -z "$IMAGE_REPO" ]; then if [ -z "$IMAGE_REPO" ]; then
# No repo was pulled # No repo was pulled
echo "ERROR! Failed to get [IMAGE_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!"
echo "ERROR:[$IMAGE_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]"
exit 1 exit 1
elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then
# Found our main repo # Found our main repo
@ -82,8 +82,8 @@ ValidateInput()
# Validate IMAGE_VERSION # # Validate IMAGE_VERSION #
########################## ##########################
if [ -z "$IMAGE_VERSION" ]; then if [ -z "$IMAGE_VERSION" ]; then
echo "ERROR! Failed to get [IMAGE_VERSION]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!"
echo "ERROR:[$IMAGE_VERSION]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_VERSION]"
exit 1 exit 1
else else
echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]" echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]"
@ -93,8 +93,8 @@ ValidateInput()
# Validate DOCKER_USERNAME # # Validate DOCKER_USERNAME #
############################ ############################
if [ -z "$DOCKER_USERNAME" ]; then if [ -z "$DOCKER_USERNAME" ]; then
echo "ERROR! Failed to get [DOCKER_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!"
echo "ERROR:[$DOCKER_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
@ -104,8 +104,8 @@ ValidateInput()
# Validate DOCKER_PASSWORD # # Validate DOCKER_PASSWORD #
############################ ############################
if [ -z "$DOCKER_PASSWORD" ]; then if [ -z "$DOCKER_PASSWORD" ]; then
echo "ERROR! Failed to get [DOCKER_PASSWORD]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!"
echo "ERROR:[$DOCKER_PASSWORD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_PASSWORD], value:[********]" echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
@ -157,8 +157,8 @@ LoginToDocker()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to authenticate to DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!"
echo "ERROR:[$LOGIN_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -197,8 +197,8 @@ RemoveImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to gain token from DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!"
echo "ERROR:[$TOKEN]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$TOKEN]"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -222,8 +222,8 @@ RemoveImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to remove tag from DockerHub!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!"
echo "ERROR:[$REMOVE_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REMOVE_CMD]"
exit 1 exit 1
else else
# SUCCESS # SUCCESS

View file

@ -53,8 +53,8 @@ CheckGHEPid()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to sleep!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!"
echo "ERROR:[$SLEEP_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]"
echo "Will try to call apply as last effort..." echo "Will try to call apply as last effort..."
#################################### ####################################
# Call config apply as last effort # # Call config apply as last effort #
@ -117,8 +117,8 @@ CheckGHEProcess()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to sleep!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!"
echo "ERROR:[$SLEEP_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]"
echo "Will try to call apply as last effort..." echo "Will try to call apply as last effort..."
#################################### ####################################
# Call config apply as last effort # # Call config apply as last effort #
@ -161,8 +161,8 @@ RunConfigApply()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Errors # Errors
echo "ERROR! Failed to run config apply command!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!"
echo "ERROR:[$APPLY_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$APPLY_CMD]"
exit 1 exit 1
else else
# Success # Success

View file

@ -60,8 +60,8 @@ ValidateInput()
# Validate GITHUB_WORKSPACE # # Validate GITHUB_WORKSPACE #
############################# #############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
@ -71,8 +71,8 @@ ValidateInput()
# Validate REGISTRY # # Validate REGISTRY #
##################### #####################
if [ -z "$REGISTRY" ]; then if [ -z "$REGISTRY" ]; then
echo "ERROR! Failed to get [REGISTRY]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!"
echo "ERROR:[$REGISTRY]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REGISTRY]"
exit 1 exit 1
else else
echo "Successfully found:[REGISTRY], value:[$REGISTRY]" echo "Successfully found:[REGISTRY], value:[$REGISTRY]"
@ -86,8 +86,8 @@ ValidateInput()
# Validate GPR_USERNAME # # Validate GPR_USERNAME #
######################### #########################
if [ -z "$GPR_USERNAME" ]; then if [ -z "$GPR_USERNAME" ]; then
echo "ERROR! Failed to get [GPR_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!"
echo "ERROR:[$GPR_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_USERNAME]"
exit 1 exit 1
else else
echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]" echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]"
@ -97,8 +97,8 @@ ValidateInput()
# Validate GPR_TOKEN # # Validate GPR_TOKEN #
###################### ######################
if [ -z "$GPR_TOKEN" ]; then if [ -z "$GPR_TOKEN" ]; then
echo "ERROR! Failed to get [GPR_TOKEN]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!"
echo "ERROR:[$GPR_TOKEN]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_TOKEN]"
exit 1 exit 1
else else
echo "Successfully found:[GPR_TOKEN], value:[********]" echo "Successfully found:[GPR_TOKEN], value:[********]"
@ -111,8 +111,8 @@ ValidateInput()
# Validate DOCKER_USERNAME # # Validate DOCKER_USERNAME #
############################ ############################
if [ -z "$DOCKER_USERNAME" ]; then if [ -z "$DOCKER_USERNAME" ]; then
echo "ERROR! Failed to get [DOCKER_USERNAME]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!"
echo "ERROR:[$DOCKER_USERNAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]"
@ -122,8 +122,8 @@ ValidateInput()
# Validate DOCKER_PASSWORD # # Validate DOCKER_PASSWORD #
############################ ############################
if [ -z "$DOCKER_PASSWORD" ]; then if [ -z "$DOCKER_PASSWORD" ]; then
echo "ERROR! Failed to get [DOCKER_PASSWORD]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!"
echo "ERROR:[$DOCKER_PASSWORD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]"
exit 1 exit 1
else else
echo "Successfully found:[DOCKER_PASSWORD], value:[********]" echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
@ -132,7 +132,7 @@ ValidateInput()
# We were not passed a registry to update # # We were not passed a registry to update #
########################################### ###########################################
else else
echo "ERROR! Failed to find a valid registry!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!"
echo "Registry:[$REGISTRY]" echo "Registry:[$REGISTRY]"
exit 1 exit 1
fi fi
@ -142,8 +142,8 @@ ValidateInput()
# Validate IMAGE_REPO # # Validate IMAGE_REPO #
####################### #######################
if [ -z "$IMAGE_REPO" ]; then if [ -z "$IMAGE_REPO" ]; then
echo "ERROR! Failed to get [IMAGE_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!"
echo "ERROR:[$IMAGE_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]"
exit 1 exit 1
else else
echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]"
@ -177,8 +177,8 @@ ValidateInput()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to get branch name!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!"
echo "ERROR:[$BRANCH_NAME]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$BRANCH_NAME]"
exit 1 exit 1
fi fi
@ -224,8 +224,8 @@ ValidateInput()
# Validate DOCKERFILE_PATH # # Validate DOCKERFILE_PATH #
############################ ############################
if [ -z "$DOCKERFILE_PATH" ]; then if [ -z "$DOCKERFILE_PATH" ]; then
echo "ERROR! Failed to get [DOCKERFILE_PATH]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!"
echo "ERROR:[$DOCKERFILE_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKERFILE_PATH]"
exit 1 exit 1
else else
echo "Successfully found:[DOCKERFILE_PATH], value:[$DOCKERFILE_PATH]" echo "Successfully found:[DOCKERFILE_PATH], value:[$DOCKERFILE_PATH]"
@ -267,8 +267,8 @@ Authenticate()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to authenticate to $NAME!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to $NAME!"
echo "ERROR:[$LOGIN_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -293,7 +293,7 @@ BuildImage()
################################ ################################
if [ ! -f "$DOCKERFILE_PATH" ]; then if [ ! -f "$DOCKERFILE_PATH" ]; then
# No file found # No file found
echo "ERROR! failed to find Dockerfile at:[$DOCKERFILE_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[$DOCKERFILE_PATH]"
echo "Please make sure you give full path!" echo "Please make sure you give full path!"
echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
exit 1 exit 1
@ -314,7 +314,7 @@ BuildImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [build] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -338,7 +338,7 @@ BuildImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [tag] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -374,7 +374,7 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [upload] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -397,8 +397,8 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to get information about built Image!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!"
echo "ERROR:[$GET_INFO_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GET_INFO_CMD]"
exit 1 exit 1
else else
################ ################
@ -440,7 +440,7 @@ UploadImage()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!"
exit 1 exit 1
else else
# SUCCESS # SUCCESS
@ -495,7 +495,7 @@ else
######### #########
# ERROR # # ERROR #
######### #########
echo "ERROR! Registry not set correctly!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!"
echo "Registry:[$REGISTRY]" echo "Registry:[$REGISTRY]"
exit 1 exit 1
fi fi

View file

@ -39,7 +39,7 @@ function BuildFileList()
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!" echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!"
echo "ERROR:[$SWITCH_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH_CMD]"
exit 1 exit 1
fi fi
@ -67,8 +67,8 @@ function BuildFileList()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "ERROR! Failed to gain a list of all files changed!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!"
echo "ERROR:[${RAW_FILE_ARRAY[*]}]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]"
exit 1 exit 1
fi fi
@ -429,7 +429,7 @@ function BuildFileList()
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Error # Error
echo "Failed to switch back to branch!" echo "Failed to switch back to branch!"
echo "ERROR:[$SWITCH2_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH2_CMD]"
exit 1 exit 1
fi fi

View file

@ -10,6 +10,8 @@
# Source Function Files # # Source Function Files #
######################### #########################
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /action/lib/termColors.sh # Source the function script(s)
# shellcheck source=/dev/null
source /action/lib/buildFileList.sh # Source the function script(s) source /action/lib/buildFileList.sh # Source the function script(s)
# shellcheck source=/dev/null # shellcheck source=/dev/null
source /action/lib/validation.sh # Source the function script(s) source /action/lib/validation.sh # Source the function script(s)
@ -322,8 +324,8 @@ GetLinterRules()
# Check the shell for errors # # Check the shell for errors #
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to set file:[$FILE_NAME] as default!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to set file:[$FILE_NAME] as default!"
echo "ERROR:[$CP_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$CP_CMD]"
exit 1 exit 1
fi fi
else else
@ -373,8 +375,8 @@ GetStandardRules()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# ERROR # ERROR
echo "ERROR! Failed to gain list of ENV vars to load!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!"
echo "ERROR:[${GET_ENV_ARRAY[*]}]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]"
exit 1 exit 1
fi fi
@ -575,8 +577,8 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_SHA" ]; then if [ -z "$GITHUB_SHA" ]; then
echo "ERROR! Failed to get [GITHUB_SHA]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!"
echo "ERROR:[$GITHUB_SHA]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_SHA]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_SHA], value:[$GITHUB_SHA]" echo "Successfully found:[GITHUB_SHA], value:[$GITHUB_SHA]"
@ -586,8 +588,8 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_WORKSPACE" ]; then if [ -z "$GITHUB_WORKSPACE" ]; then
echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!"
echo "ERROR:[$GITHUB_WORKSPACE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]"
@ -597,8 +599,8 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_EVENT_PATH" ]; then if [ -z "$GITHUB_EVENT_PATH" ]; then
echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!"
echo "ERROR:[$GITHUB_EVENT_PATH]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_EVENT_PATH]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_EVENT_PATH], value:[$GITHUB_EVENT_PATH]" echo "Successfully found:[GITHUB_EVENT_PATH], value:[$GITHUB_EVENT_PATH]"
@ -617,8 +619,8 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_ORG" ]; then if [ -z "$GITHUB_ORG" ]; then
echo "ERROR! Failed to get [GITHUB_ORG]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!"
echo "ERROR:[$GITHUB_ORG]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_ORG]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_ORG], value:[$GITHUB_ORG]" echo "Successfully found:[GITHUB_ORG], value:[$GITHUB_ORG]"
@ -633,8 +635,8 @@ GetGitHubVars()
# Validate we have a value # # Validate we have a value #
############################ ############################
if [ -z "$GITHUB_REPO" ]; then if [ -z "$GITHUB_REPO" ]; then
echo "ERROR! Failed to get [GITHUB_REPO]!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!"
echo "ERROR:[$GITHUB_REPO]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPO]"
exit 1 exit 1
else else
echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]" echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]"
@ -668,7 +670,7 @@ Footer()
################## ##################
if [ "${!ERROR_COUNTER}" -ne 0 ]; then if [ "${!ERROR_COUNTER}" -ne 0 ]; then
# Print the goods # Print the goods
echo "ERRORS FOUND in $LANGUAGE:[${!ERROR_COUNTER}]" echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in $LANGUAGE:[${!ERROR_COUNTER}]"
fi fi
done done
@ -676,7 +678,7 @@ Footer()
# Exit with 0 if errors disabled # # Exit with 0 if errors disabled #
################################## ##################################
if [ "$DISABLE_ERRORS" == "true" ]; then if [ "$DISABLE_ERRORS" == "true" ]; then
echo "WARN! Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]" echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]"
exit 0 exit 0
############################### ###############################
# Exit with 1 if errors found # # Exit with 1 if errors found #
@ -715,7 +717,7 @@ Footer()
# Footer prints # # Footer prints #
################# #################
echo "" echo ""
echo "All file(s) linted successfully with no errors detected" echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}"
echo "----------------------------------------------" echo "----------------------------------------------"
echo "" echo ""
# Successful exit # Successful exit

27
lib/termColors.sh Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
declare -Agr B=(
[B]=$(echo -e "\e[44m")
[C]=$(echo -e "\e[46m")
[G]=$(echo -e "\e[42m")
[K]=$(echo -e "\e[40m")
[M]=$(echo -e "\e[45m")
[R]=$(echo -e "\e[41m")
[W]=$(echo -e "\e[47m")
[Y]=$(echo -e "\e[43m")
)
declare -Agr F=(
[B]=$(echo -e "\e[0;34m")
[C]=$(echo -e "\e[0;36m")
[G]=$(echo -e "\e[0;32m")
[K]=$(echo -e "\e[0;30m")
[M]=$(echo -e "\e[0;35m")
[R]=$(echo -e "\e[0;31m")
[W]=$(echo -e "\e[0;37m")
[Y]=$(echo -e "\e[0;33m")
)
readonly NC=$(echo -e "\e[0m")
export B
export F
export NC

View file

@ -50,8 +50,8 @@ function LintCodebase()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find [$LINTER_NAME] in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]"
exit 1 exit 1
else else
# Success # Success
@ -187,8 +187,8 @@ function LintCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
else else
@ -240,8 +240,8 @@ function TestCodebase()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find [$LINTER_NAME] in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]"
exit 1 exit 1
else else
# Success # Success
@ -358,9 +358,9 @@ function TestCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]"
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
# Increment counter that check was ran # Increment counter that check was ran
@ -384,10 +384,10 @@ function TestCodebase()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!"
echo "ERROR! This file should have failed test case!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]"
echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]"
# Increment the error count # Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++")) (("ERRORS_FOUND_$FILE_TYPE++"))
# Increment counter that check was ran # Increment counter that check was ran
@ -410,7 +410,7 @@ function TestCodebase()
################################################# #################################################
# We failed to find files and no tests were ran # # We failed to find files and no tests were ran #
################################################# #################################################
echo "ERROR! Failed to find any tests ran for the Linter:[$LINTER_NAME]"! echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[$LINTER_NAME]"!
echo "Please validate logic or that tests exist!" echo "Please validate logic or that tests exist!"
exit 1 exit 1
fi fi
@ -513,8 +513,8 @@ function LintAnsibleFiles()
############################## ##############################
if [ $ERROR_CODE -ne 0 ]; then if [ $ERROR_CODE -ne 0 ]; then
# Failed # Failed
echo "ERROR! Failed to find $LINTER_NAME in system!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find $LINTER_NAME in system!"
echo "ERROR:[$VALIDATE_INSTALL_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]"
exit 1 exit 1
else else
# Success # Success
@ -619,8 +619,8 @@ function LintAnsibleFiles()
######### #########
# Error # # Error #
######### #########
echo "ERROR! Found errors in [$LINTER_NAME] linter!" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!"
echo "ERROR:[$LINT_CMD]" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]"
# Increment error count # Increment error count
((ERRORS_FOUND_ANSIBLE++)) ((ERRORS_FOUND_ANSIBLE++))
else else