From 5142e0aebdc282e6ac73a07d4793e0fa4bd9ff01 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Wed, 1 Jul 2020 14:00:05 -0500 Subject: [PATCH] Add colors to output --- .automation/cleanup-docker.sh | 32 +++++----- .../templates/ghe-config-apply.sh | 12 ++-- .automation/upload-docker.sh | 58 +++++++++---------- lib/buildFileList.sh | 8 +-- lib/linter.sh | 36 ++++++------ lib/termColors.sh | 27 +++++++++ lib/worker.sh | 36 ++++++------ 7 files changed, 119 insertions(+), 90 deletions(-) create mode 100644 lib/termColors.sh diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index 838119c4..f493bd6c 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -54,8 +54,8 @@ ValidateInput() # Validate GITHUB_WORKSPACE # ############################ if [ -z "$GITHUB_WORKSPACE" ]; then - echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" - echo "ERROR:[$GITHUB_WORKSPACE]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]" exit 1 else echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" @@ -66,8 +66,8 @@ ValidateInput() ####################### if [ -z "$IMAGE_REPO" ]; then # No repo was pulled - echo "ERROR! Failed to get [IMAGE_REPO]!" - echo "ERROR:[$IMAGE_REPO]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]" exit 1 elif [[ "$IMAGE_REPO" == "github/super-linter" ]]; then # Found our main repo @@ -82,8 +82,8 @@ ValidateInput() # Validate IMAGE_VERSION # ########################## if [ -z "$IMAGE_VERSION" ]; then - echo "ERROR! Failed to get [IMAGE_VERSION]!" - echo "ERROR:[$IMAGE_VERSION]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_VERSION]" exit 1 else echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]" @@ -93,8 +93,8 @@ ValidateInput() # Validate DOCKER_USERNAME # ############################ if [ -z "$DOCKER_USERNAME" ]; then - echo "ERROR! Failed to get [DOCKER_USERNAME]!" - echo "ERROR:[$DOCKER_USERNAME]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]" exit 1 else echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" @@ -104,8 +104,8 @@ ValidateInput() # Validate DOCKER_PASSWORD # ############################ if [ -z "$DOCKER_PASSWORD" ]; then - echo "ERROR! Failed to get [DOCKER_PASSWORD]!" - echo "ERROR:[$DOCKER_PASSWORD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]" exit 1 else echo "Successfully found:[DOCKER_PASSWORD], value:[********]" @@ -157,8 +157,8 @@ LoginToDocker() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to authenticate to DockerHub!" - echo "ERROR:[$LOGIN_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]" exit 1 else # SUCCESS @@ -197,8 +197,8 @@ RemoveImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to gain token from DockerHub!" - echo "ERROR:[$TOKEN]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$TOKEN]" exit 1 else # SUCCESS @@ -222,8 +222,8 @@ RemoveImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to remove tag from DockerHub!" - echo "ERROR:[$REMOVE_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REMOVE_CMD]" exit 1 else # SUCCESS diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index f33f0475..4a25c0ca 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -53,8 +53,8 @@ CheckGHEPid() # Check the shell for errors # ############################## if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to sleep!" - echo "ERROR:[$SLEEP_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -117,8 +117,8 @@ CheckGHEProcess() # Check the shell for errors # ############################## if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to sleep!" - echo "ERROR:[$SLEEP_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -161,8 +161,8 @@ RunConfigApply() ############################## if [ $ERROR_CODE -ne 0 ]; then # Errors - echo "ERROR! Failed to run config apply command!" - echo "ERROR:[$APPLY_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$APPLY_CMD]" exit 1 else # Success diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 55719d6b..03f02a91 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -60,8 +60,8 @@ ValidateInput() # Validate GITHUB_WORKSPACE # ############################# if [ -z "$GITHUB_WORKSPACE" ]; then - echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" - echo "ERROR:[$GITHUB_WORKSPACE]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]" exit 1 else echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" @@ -71,8 +71,8 @@ ValidateInput() # Validate REGISTRY # ##################### if [ -z "$REGISTRY" ]; then - echo "ERROR! Failed to get [REGISTRY]!" - echo "ERROR:[$REGISTRY]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REGISTRY]" exit 1 else echo "Successfully found:[REGISTRY], value:[$REGISTRY]" @@ -86,8 +86,8 @@ ValidateInput() # Validate GPR_USERNAME # ######################### if [ -z "$GPR_USERNAME" ]; then - echo "ERROR! Failed to get [GPR_USERNAME]!" - echo "ERROR:[$GPR_USERNAME]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_USERNAME]" exit 1 else echo "Successfully found:[GPR_USERNAME], value:[$GPR_USERNAME]" @@ -97,8 +97,8 @@ ValidateInput() # Validate GPR_TOKEN # ###################### if [ -z "$GPR_TOKEN" ]; then - echo "ERROR! Failed to get [GPR_TOKEN]!" - echo "ERROR:[$GPR_TOKEN]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_TOKEN]" exit 1 else echo "Successfully found:[GPR_TOKEN], value:[********]" @@ -111,8 +111,8 @@ ValidateInput() # Validate DOCKER_USERNAME # ############################ if [ -z "$DOCKER_USERNAME" ]; then - echo "ERROR! Failed to get [DOCKER_USERNAME]!" - echo "ERROR:[$DOCKER_USERNAME]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]" exit 1 else echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" @@ -122,8 +122,8 @@ ValidateInput() # Validate DOCKER_PASSWORD # ############################ if [ -z "$DOCKER_PASSWORD" ]; then - echo "ERROR! Failed to get [DOCKER_PASSWORD]!" - echo "ERROR:[$DOCKER_PASSWORD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]" exit 1 else echo "Successfully found:[DOCKER_PASSWORD], value:[********]" @@ -132,7 +132,7 @@ ValidateInput() # We were not passed a registry to update # ########################################### 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]" exit 1 fi @@ -142,8 +142,8 @@ ValidateInput() # Validate IMAGE_REPO # ####################### if [ -z "$IMAGE_REPO" ]; then - echo "ERROR! Failed to get [IMAGE_REPO]!" - echo "ERROR:[$IMAGE_REPO]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]" exit 1 else echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" @@ -177,8 +177,8 @@ ValidateInput() # Check the shell for errors # ############################## if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to get branch name!" - echo "ERROR:[$BRANCH_NAME]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$BRANCH_NAME]" exit 1 fi @@ -224,8 +224,8 @@ ValidateInput() # Validate DOCKERFILE_PATH # ############################ if [ -z "$DOCKERFILE_PATH" ]; then - echo "ERROR! Failed to get [DOCKERFILE_PATH]!" - echo "ERROR:[$DOCKERFILE_PATH]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKERFILE_PATH]" exit 1 else echo "Successfully found:[DOCKERFILE_PATH], value:[$DOCKERFILE_PATH]" @@ -267,8 +267,8 @@ Authenticate() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to authenticate to $NAME!" - echo "ERROR:[$LOGIN_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to $NAME!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]" exit 1 else # SUCCESS @@ -293,7 +293,7 @@ BuildImage() ################################ if [ ! -f "$DOCKERFILE_PATH" ]; then # 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 "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" exit 1 @@ -314,7 +314,7 @@ BuildImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! failed to [build] Dockerfile!" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!" exit 1 else # SUCCESS @@ -338,7 +338,7 @@ BuildImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! failed to [tag] Dockerfile!" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!" exit 1 else # SUCCESS @@ -374,7 +374,7 @@ UploadImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! failed to [upload] Dockerfile!" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!" exit 1 else # SUCCESS @@ -397,8 +397,8 @@ UploadImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to get information about built Image!" - echo "ERROR:[$GET_INFO_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GET_INFO_CMD]" exit 1 else ################ @@ -440,7 +440,7 @@ UploadImage() ############################## if [ $ERROR_CODE -ne 0 ]; then # 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 else # SUCCESS @@ -495,7 +495,7 @@ else ######### # ERROR # ######### - echo "ERROR! Registry not set correctly!" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!" echo "Registry:[$REGISTRY]" exit 1 fi diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index c10284c8..d0948419 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -39,7 +39,7 @@ function BuildFileList() if [ $ERROR_CODE -ne 0 ]; then # Error 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 fi @@ -67,8 +67,8 @@ function BuildFileList() ############################## if [ $ERROR_CODE -ne 0 ]; then # Error - echo "ERROR! Failed to gain a list of all files changed!" - echo "ERROR:[${RAW_FILE_ARRAY[*]}]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]" exit 1 fi @@ -429,7 +429,7 @@ function BuildFileList() if [ $ERROR_CODE -ne 0 ]; then # Error echo "Failed to switch back to branch!" - echo "ERROR:[$SWITCH2_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH2_CMD]" exit 1 fi diff --git a/lib/linter.sh b/lib/linter.sh index 0801a9ee..01e937d3 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -10,6 +10,8 @@ # Source Function Files # ######################### # 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) # shellcheck source=/dev/null source /action/lib/validation.sh # Source the function script(s) @@ -322,8 +324,8 @@ GetLinterRules() # Check the shell for errors # ############################## if [ $ERROR_CODE -ne 0 ]; then - echo "ERROR! Failed to set file:[$FILE_NAME] as default!" - echo "ERROR:[$CP_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to set file:[$FILE_NAME] as default!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$CP_CMD]" exit 1 fi else @@ -373,8 +375,8 @@ GetStandardRules() ############################## if [ $ERROR_CODE -ne 0 ]; then # ERROR - echo "ERROR! Failed to gain list of ENV vars to load!" - echo "ERROR:[${GET_ENV_ARRAY[*]}]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]" exit 1 fi @@ -575,8 +577,8 @@ GetGitHubVars() # Validate we have a value # ############################ if [ -z "$GITHUB_SHA" ]; then - echo "ERROR! Failed to get [GITHUB_SHA]!" - echo "ERROR:[$GITHUB_SHA]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_SHA]" exit 1 else echo "Successfully found:[GITHUB_SHA], value:[$GITHUB_SHA]" @@ -586,8 +588,8 @@ GetGitHubVars() # Validate we have a value # ############################ if [ -z "$GITHUB_WORKSPACE" ]; then - echo "ERROR! Failed to get [GITHUB_WORKSPACE]!" - echo "ERROR:[$GITHUB_WORKSPACE]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]" exit 1 else echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" @@ -597,8 +599,8 @@ GetGitHubVars() # Validate we have a value # ############################ if [ -z "$GITHUB_EVENT_PATH" ]; then - echo "ERROR! Failed to get [GITHUB_EVENT_PATH]!" - echo "ERROR:[$GITHUB_EVENT_PATH]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_EVENT_PATH]" exit 1 else echo "Successfully found:[GITHUB_EVENT_PATH], value:[$GITHUB_EVENT_PATH]" @@ -617,8 +619,8 @@ GetGitHubVars() # Validate we have a value # ############################ if [ -z "$GITHUB_ORG" ]; then - echo "ERROR! Failed to get [GITHUB_ORG]!" - echo "ERROR:[$GITHUB_ORG]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_ORG]" exit 1 else echo "Successfully found:[GITHUB_ORG], value:[$GITHUB_ORG]" @@ -633,8 +635,8 @@ GetGitHubVars() # Validate we have a value # ############################ if [ -z "$GITHUB_REPO" ]; then - echo "ERROR! Failed to get [GITHUB_REPO]!" - echo "ERROR:[$GITHUB_REPO]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPO]" exit 1 else echo "Successfully found:[GITHUB_REPO], value:[$GITHUB_REPO]" @@ -668,7 +670,7 @@ Footer() ################## if [ "${!ERROR_COUNTER}" -ne 0 ]; then # 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 done @@ -676,7 +678,7 @@ Footer() # Exit with 0 if errors disabled # ################################## 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 with 1 if errors found # @@ -715,7 +717,7 @@ Footer() # Footer prints # ################# 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 "" # Successful exit diff --git a/lib/termColors.sh b/lib/termColors.sh new file mode 100644 index 00000000..ce3e0e66 --- /dev/null +++ b/lib/termColors.sh @@ -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 diff --git a/lib/worker.sh b/lib/worker.sh index fc1d65f1..b58324a6 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -50,8 +50,8 @@ function LintCodebase() ############################## if [ $ERROR_CODE -ne 0 ]; then # Failed - echo "ERROR! Failed to find [$LINTER_NAME] in system!" - echo "ERROR:[$VALIDATE_INSTALL_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]" exit 1 else # Success @@ -187,8 +187,8 @@ function LintCodebase() ######### # Error # ######### - echo "ERROR! Found errors in [$LINTER_NAME] linter!" - echo "ERROR:[$LINT_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]" # Increment the error count (("ERRORS_FOUND_$FILE_TYPE++")) else @@ -240,8 +240,8 @@ function TestCodebase() ############################## if [ $ERROR_CODE -ne 0 ]; then # Failed - echo "ERROR! Failed to find [$LINTER_NAME] in system!" - echo "ERROR:[$VALIDATE_INSTALL_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]" exit 1 else # Success @@ -358,9 +358,9 @@ function TestCodebase() ######### # Error # ######### - echo "ERROR! Found errors in [$LINTER_NAME] linter!" - echo "ERROR:[$LINT_CMD]" - echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]" # Increment the error count (("ERRORS_FOUND_$FILE_TYPE++")) # Increment counter that check was ran @@ -384,10 +384,10 @@ function TestCodebase() ######### # Error # ######### - echo "ERROR! Found errors in [$LINTER_NAME] linter!" - echo "ERROR! This file should have failed test case!" - echo "ERROR:[$LINT_CMD]" - echo "ERROR: Linter CMD:[$LINTER_COMMAND $FILE]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]" # Increment the error count (("ERRORS_FOUND_$FILE_TYPE++")) # Increment counter that check was ran @@ -410,7 +410,7 @@ function TestCodebase() ################################################# # 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!" exit 1 fi @@ -513,8 +513,8 @@ function LintAnsibleFiles() ############################## if [ $ERROR_CODE -ne 0 ]; then # Failed - echo "ERROR! Failed to find $LINTER_NAME in system!" - echo "ERROR:[$VALIDATE_INSTALL_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find $LINTER_NAME in system!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]" exit 1 else # Success @@ -619,8 +619,8 @@ function LintAnsibleFiles() ######### # Error # ######### - echo "ERROR! Found errors in [$LINTER_NAME] linter!" - echo "ERROR:[$LINT_CMD]" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]" # Increment error count ((ERRORS_FOUND_ANSIBLE++)) else