mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-26 02:31:00 -05:00
First pass at log functions
This commit is contained in:
parent
9fc054ab16
commit
af13245484
6 changed files with 160 additions and 209 deletions
|
@ -52,9 +52,8 @@ ValidateInput() {
|
||||||
# Validate GITHUB_WORKSPACE #
|
# Validate GITHUB_WORKSPACE #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]"
|
echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]"
|
||||||
fi
|
fi
|
||||||
|
@ -64,15 +63,14 @@ ValidateInput() {
|
||||||
#######################
|
#######################
|
||||||
if [ -z "${IMAGE_REPO}" ]; then
|
if [ -z "${IMAGE_REPO}" ]; then
|
||||||
# No repo was pulled
|
# No repo was pulled
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
error "Failed to get [IMAGE_REPO]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}"
|
fatal "[${IMAGE_REPO}]${NC}"
|
||||||
exit 1
|
|
||||||
elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then
|
elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then
|
||||||
# Found our main repo
|
# Found our main repo
|
||||||
echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]"
|
echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]"
|
||||||
else
|
else
|
||||||
# This is a fork and we cant pull vars or any info
|
# This is a fork and we cant pull vars or any info
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}"
|
warn "No image to cleanup as this is a forked branch, and not being built with current automation!${NC}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -80,9 +78,8 @@ ValidateInput() {
|
||||||
# Validate IMAGE_VERSION #
|
# Validate IMAGE_VERSION #
|
||||||
##########################
|
##########################
|
||||||
if [ -z "${IMAGE_VERSION}" ]; then
|
if [ -z "${IMAGE_VERSION}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
error "Failed to get [IMAGE_VERSION]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_VERSION}]${NC}"
|
fatal "[${IMAGE_VERSION}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]"
|
echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]"
|
||||||
fi
|
fi
|
||||||
|
@ -91,9 +88,8 @@ ValidateInput() {
|
||||||
# Validate DOCKER_USERNAME #
|
# Validate DOCKER_USERNAME #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_USERNAME}" ]; then
|
if [ -z "${DOCKER_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
error "Failed to get [DOCKER_USERNAME]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}"
|
fatal "[${DOCKER_USERNAME}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]"
|
echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]"
|
||||||
fi
|
fi
|
||||||
|
@ -102,9 +98,8 @@ ValidateInput() {
|
||||||
# Validate DOCKER_PASSWORD #
|
# Validate DOCKER_PASSWORD #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_PASSWORD}" ]; then
|
if [ -z "${DOCKER_PASSWORD}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
error "Failed to get [DOCKER_PASSWORD]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}"
|
fatal "[${DOCKER_PASSWORD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
echo "Successfully found:[DOCKER_PASSWORD], value:[********]"
|
||||||
fi
|
fi
|
||||||
|
@ -121,10 +116,9 @@ ValidateInput() {
|
||||||
#############################################
|
#############################################
|
||||||
# Image is 'latest' and we will not destroy #
|
# Image is 'latest' and we will not destroy #
|
||||||
#############################################
|
#############################################
|
||||||
echo "Image Tag is set to:[latest]..."
|
error "Image Tag is set to:[latest]..."
|
||||||
echo "We will never destroy latest..."
|
error "We will never destroy latest..."
|
||||||
echo "Bye!"
|
fatal "Bye!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -154,9 +148,8 @@ LoginToDocker() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}"
|
error "Failed to authenticate to DockerHub!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}"
|
fatal "[${LOGIN_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully authenticated to DockerHub!"
|
echo "Successfully authenticated to DockerHub!"
|
||||||
|
@ -193,9 +186,8 @@ RemoveImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}"
|
error "Failed to gain token from DockerHub!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${TOKEN}]${NC}"
|
fatal "[${TOKEN}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully gained auth token from DockerHub!"
|
echo "Successfully gained auth token from DockerHub!"
|
||||||
|
@ -218,9 +210,8 @@ RemoveImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}"
|
error "Failed to remove tag from DockerHub!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REMOVE_CMD}]${NC}"
|
fatal "[${REMOVE_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!"
|
echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!"
|
||||||
|
|
|
@ -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 -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
error "Failed to sleep!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}"
|
error "[${SLEEP_CMD}]${NC}"
|
||||||
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 -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}"
|
error "Failed to sleep!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}"
|
error "[${SLEEP_CMD}]${NC}"
|
||||||
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,12 +161,11 @@ RunConfigApply()
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Errors
|
# Errors
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}"
|
error "Failed to run config apply command!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${APPLY_CMD}]${NC}"
|
fatal "[${APPLY_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}"
|
notice "Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -58,22 +58,20 @@ ValidateInput() {
|
||||||
# Validate GITHUB_WORKSPACE #
|
# Validate GITHUB_WORKSPACE #
|
||||||
#############################
|
#############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# Validate REGISTRY #
|
# Validate REGISTRY #
|
||||||
#####################
|
#####################
|
||||||
if [ -z "${REGISTRY}" ]; then
|
if [ -z "${REGISTRY}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}"
|
error "Failed to get [REGISTRY]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REGISTRY}]${NC}"
|
fatal "[${REGISTRY}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}"
|
notice "Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
|
@ -84,22 +82,20 @@ ValidateInput() {
|
||||||
# Validate GPR_USERNAME #
|
# Validate GPR_USERNAME #
|
||||||
#########################
|
#########################
|
||||||
if [ -z "${GPR_USERNAME}" ]; then
|
if [ -z "${GPR_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}"
|
error "Failed to get [GPR_USERNAME]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_USERNAME}]${NC}"
|
fatal "[${GPR_USERNAME}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}"
|
notice "Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Validate GPR_TOKEN #
|
# Validate GPR_TOKEN #
|
||||||
######################
|
######################
|
||||||
if [ -z "${GPR_TOKEN}" ]; then
|
if [ -z "${GPR_TOKEN}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}"
|
error "Failed to get [GPR_TOKEN]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_TOKEN}]${NC}"
|
fatal "[${GPR_TOKEN}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}"
|
notice "Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}"
|
||||||
fi
|
fi
|
||||||
########################################
|
########################################
|
||||||
# See if we need values for Ducker hub #
|
# See if we need values for Ducker hub #
|
||||||
|
@ -109,41 +105,37 @@ ValidateInput() {
|
||||||
# Validate DOCKER_USERNAME #
|
# Validate DOCKER_USERNAME #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_USERNAME}" ]; then
|
if [ -z "${DOCKER_USERNAME}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}"
|
error "Failed to get [DOCKER_USERNAME]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}"
|
fatal "[${DOCKER_USERNAME}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}"
|
notice "Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate DOCKER_PASSWORD #
|
# Validate DOCKER_PASSWORD #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKER_PASSWORD}" ]; then
|
if [ -z "${DOCKER_PASSWORD}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}"
|
error "Failed to get [DOCKER_PASSWORD]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}"
|
fatal "[${DOCKER_PASSWORD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}"
|
notice "Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}"
|
||||||
fi
|
fi
|
||||||
###########################################
|
###########################################
|
||||||
# We were not passed a registry to update #
|
# We were not passed a registry to update #
|
||||||
###########################################
|
###########################################
|
||||||
else
|
else
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}"
|
error "Failed to find a valid registry!${NC}"
|
||||||
echo "Registry:[${REGISTRY}]"
|
fatal "Registry:[${REGISTRY}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Validate IMAGE_REPO #
|
# Validate IMAGE_REPO #
|
||||||
#######################
|
#######################
|
||||||
if [ -z "${IMAGE_REPO}" ]; then
|
if [ -z "${IMAGE_REPO}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}"
|
error "Failed to get [IMAGE_REPO]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}"
|
fatal "[${IMAGE_REPO}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}"
|
notice "Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}"
|
||||||
###############################################
|
###############################################
|
||||||
# Need to see if GPR registry and update name #
|
# Need to see if GPR registry and update name #
|
||||||
###############################################
|
###############################################
|
||||||
|
@ -158,7 +150,7 @@ ValidateInput() {
|
||||||
# Validate IMAGE_VERSION #
|
# Validate IMAGE_VERSION #
|
||||||
##########################
|
##########################
|
||||||
if [ -z "${IMAGE_VERSION}" ]; then
|
if [ -z "${IMAGE_VERSION}" ]; then
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}"
|
warn "Failed to get [IMAGE_VERSION]!${NC}"
|
||||||
echo "Pulling from Branch Name..."
|
echo "Pulling from Branch Name..."
|
||||||
##############################
|
##############################
|
||||||
# Get the name of the branch #
|
# Get the name of the branch #
|
||||||
|
@ -174,9 +166,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 -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}"
|
error "Failed to get branch name!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${BRANCH_NAME}]${NC}"
|
fatal "[${BRANCH_NAME}]${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
@ -190,7 +181,7 @@ ValidateInput() {
|
||||||
IMAGE_VERSION="${BRANCH_NAME}"
|
IMAGE_VERSION="${BRANCH_NAME}"
|
||||||
echo "Tag:[${IMAGE_VERSION}]"
|
echo "Tag:[${IMAGE_VERSION}]"
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}"
|
notice "Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
@ -221,11 +212,10 @@ ValidateInput() {
|
||||||
# Validate DOCKERFILE_PATH #
|
# Validate DOCKERFILE_PATH #
|
||||||
############################
|
############################
|
||||||
if [ -z "${DOCKERFILE_PATH}" ]; then
|
if [ -z "${DOCKERFILE_PATH}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}"
|
error "Failed to get [DOCKERFILE_PATH]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKERFILE_PATH}]${NC}"
|
fatal "[${DOCKERFILE_PATH}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}"
|
notice "Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -263,12 +253,11 @@ Authenticate() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to ${NAME}!${NC}"
|
error "Failed to authenticate to ${NAME}!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}"
|
fatal "[${LOGIN_CMD}]${NC}"
|
||||||
exit 1
|
fatal else
|
||||||
else
|
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}"
|
notice "Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -288,10 +277,9 @@ BuildImage() {
|
||||||
################################
|
################################
|
||||||
if [ ! -f "${DOCKERFILE_PATH}" ]; then
|
if [ ! -f "${DOCKERFILE_PATH}" ]; then
|
||||||
# No file found
|
# No file found
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}"
|
error "failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}"
|
||||||
echo "Please make sure you give full path!"
|
error "Please make sure you give full path!"
|
||||||
echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
|
fatal "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
###################
|
||||||
|
@ -309,11 +297,10 @@ BuildImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}"
|
fatal "failed to [build] Dockerfile!${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Built image!${NC}"
|
notice "Successfully Built image!${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
|
@ -333,11 +320,10 @@ BuildImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}"
|
fatal "failed to [tag] Dockerfile!${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully tagged image!${NC}"
|
notice "Successfully tagged image!${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -368,11 +354,10 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}"
|
fatal "failed to [upload] Dockerfile!${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
notice "Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -391,9 +376,8 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}"
|
error "Failed to get information about built Image!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_INFO_CMD}]${NC}"
|
fatal "[${GET_INFO_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
################
|
################
|
||||||
# Get the data #
|
# Get the data #
|
||||||
|
@ -434,11 +418,10 @@ UploadImage() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}"
|
fatal "failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# SUCCESS
|
# SUCCESS
|
||||||
echo -e "${NC}${F[B]}Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
notice "Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -488,9 +471,8 @@ else
|
||||||
#########
|
#########
|
||||||
# ERROR #
|
# ERROR #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}"
|
error "Registry not set correctly!${NC}"
|
||||||
echo "Registry:[${REGISTRY}]"
|
fatal "Registry:[${REGISTRY}]"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
|
|
@ -41,8 +41,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 -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH_CMD}]${NC}"
|
fatal "[${SWITCH_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -69,9 +68,8 @@ function BuildFileList() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Error
|
# Error
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}"
|
error "Failed to gain a list of all files changed!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}"
|
fatal "[${RAW_FILE_ARRAY[*]}]${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
@ -472,7 +470,7 @@ function BuildFileList() {
|
||||||
#######################
|
#######################
|
||||||
# It is a bash script #
|
# It is a bash script #
|
||||||
#######################
|
#######################
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Found bash script without extension:[.sh]${NC}"
|
warn "Found bash script without extension:[.sh]${NC}"
|
||||||
echo "Please update file with proper extensions."
|
echo "Please update file with proper extensions."
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
|
@ -486,7 +484,7 @@ function BuildFileList() {
|
||||||
#######################
|
#######################
|
||||||
# It is a Ruby script #
|
# It is a Ruby script #
|
||||||
#######################
|
#######################
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Found ruby script without extension:[.rb]${NC}"
|
warn "Found ruby script without extension:[.rb]${NC}"
|
||||||
echo "Please update file with proper extensions."
|
echo "Please update file with proper extensions."
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
|
@ -500,7 +498,7 @@ function BuildFileList() {
|
||||||
############################
|
############################
|
||||||
# Extension was not found! #
|
# Extension was not found! #
|
||||||
############################
|
############################
|
||||||
echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[${FILE}]!${NC}"
|
warn "Failed to get filetype for:[${FILE}]!${NC}"
|
||||||
##########################################################
|
##########################################################
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
@ -526,9 +524,8 @@ function BuildFileList() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Error
|
# Error
|
||||||
echo "Failed to switch back to branch!"
|
error "Failed to switch back to branch!"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH2_CMD}]${NC}"
|
fatal "[${SWITCH2_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -536,5 +533,5 @@ function BuildFileList() {
|
||||||
################
|
################
|
||||||
echo ""
|
echo ""
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo -e "${NC}${F[B]}Successfully gathered list of files...${NC}"
|
notice "Successfully gathered list of files...${NC}"
|
||||||
}
|
}
|
||||||
|
|
100
lib/linter.sh
100
lib/linter.sh
|
@ -386,12 +386,12 @@ GetLinterVersions() {
|
||||||
# Check the shell for errors #
|
# Check the shell for errors #
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then
|
if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then
|
||||||
echo -e "${NC}[${LINTER}]: ${F[Y]}WARN!${NC} Failed to get version info for:${NC}"
|
warn "[${LINTER}]: Failed to get version info for:${NC}"
|
||||||
else
|
else
|
||||||
##########################
|
##########################
|
||||||
# Print the version info #
|
# Print the version info #
|
||||||
##########################
|
##########################
|
||||||
echo -e "${NC}${F[B]}Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}"
|
notice "Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -474,9 +474,8 @@ GetStandardRules() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# ERROR
|
# ERROR
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}"
|
error "Failed to gain list of ENV vars to load!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}"
|
fatal "[${GET_ENV_ARRAY[*]}]${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -691,8 +690,7 @@ GetGitHubVars() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "${GITHUB_WORKSPACE}" ]; then
|
if [ ! -d "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Provided volume is not a directory!${NC}"
|
fatal "Provided volume is not a directory!${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]"
|
echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]"
|
||||||
|
@ -711,33 +709,30 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_SHA}" ]; then
|
if [ -z "${GITHUB_SHA}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}"
|
error "Failed to get [GITHUB_SHA]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_SHA}]${NC}"
|
fatal "[${GITHUB_SHA}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
if [ -z "${GITHUB_WORKSPACE}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}"
|
error "Failed to get [GITHUB_WORKSPACE]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}"
|
fatal "[${GITHUB_WORKSPACE}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_EVENT_PATH}" ]; then
|
if [ -z "${GITHUB_EVENT_PATH}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}"
|
error "Failed to get [GITHUB_EVENT_PATH]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_EVENT_PATH}]${NC}"
|
fatal "[${GITHUB_EVENT_PATH}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
|
@ -753,11 +748,10 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_ORG}" ]; then
|
if [ -z "${GITHUB_ORG}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}"
|
error "Failed to get [GITHUB_ORG]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_ORG}]${NC}"
|
fatal "[${GITHUB_ORG}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -769,11 +763,10 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_REPO}" ]; then
|
if [ -z "${GITHUB_REPO}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}"
|
error "Failed to get [GITHUB_REPO]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPO}]${NC}"
|
fatal "[${GITHUB_REPO}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -781,16 +774,16 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
if [ -z "${GITHUB_TOKEN}" ] && [[ ${RUN_LOCAL} == "false" ]]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_TOKEN]!${NC}"
|
error "Failed to get [GITHUB_TOKEN]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_TOKEN}]${NC}"
|
error "[${GITHUB_TOKEN}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}"
|
error "Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}"
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Need to set MULTI_STATUS to false as we cant hit API endpoints without token #
|
# Need to set MULTI_STATUS to false as we cant hit API endpoints without token #
|
||||||
################################################################################
|
################################################################################
|
||||||
MULTI_STATUS='false'
|
MULTI_STATUS='false'
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_TOKEN]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_TOKEN]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
|
@ -806,22 +799,20 @@ GetGitHubVars() {
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_REPOSITORY}" ]; then
|
if [ -z "${GITHUB_REPOSITORY}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPOSITORY]!${NC}"
|
error "Failed to get [GITHUB_REPOSITORY]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPOSITORY}]${NC}"
|
fatal "[${GITHUB_REPOSITORY}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Validate we have a value #
|
# Validate we have a value #
|
||||||
############################
|
############################
|
||||||
if [ -z "${GITHUB_RUN_ID}" ]; then
|
if [ -z "${GITHUB_RUN_ID}" ]; then
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_RUN_ID]!${NC}"
|
error "Failed to get [GITHUB_RUN_ID]!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_RUN_ID}]${NC}"
|
fatal "[${GITHUB_RUN_ID}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}"
|
notice "Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -833,16 +824,14 @@ function ValidatePowershellModules() {
|
||||||
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then
|
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then
|
||||||
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
||||||
else
|
else
|
||||||
# Failed to find module
|
fatal "Failed to find module."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# validate we found the script analyzer #
|
# validate we found the script analyzer #
|
||||||
#########################################
|
#########################################
|
||||||
if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then
|
if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then
|
||||||
# Failed to find module
|
fatal "Failed to find module."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -855,14 +844,13 @@ function ValidatePowershellModules() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}"
|
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}"
|
fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
||||||
echo -e "${NC}${F[B]}Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}"
|
notice "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}"
|
||||||
echo -e "${NC}${F[B]}Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}"
|
notice "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -944,7 +932,7 @@ Reports() {
|
||||||
# Prints for warnings if found #
|
# Prints for warnings if found #
|
||||||
################################
|
################################
|
||||||
for TEST in "${WARNING_ARRAY_TEST[@]}"; do
|
for TEST in "${WARNING_ARRAY_TEST[@]}"; do
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} Expected file to compare with was not found for ${TEST}${NC}"
|
warn "Expected file to compare with was not found for ${TEST}${NC}"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -981,7 +969,7 @@ Footer() {
|
||||||
###################
|
###################
|
||||||
# Print the goods #
|
# Print the goods #
|
||||||
###################
|
###################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}"
|
error "ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}"
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Create status API for Failed language #
|
# Create status API for Failed language #
|
||||||
|
@ -1000,7 +988,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 -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}"
|
warn "Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1014,8 +1002,7 @@ Footer() {
|
||||||
# Check if error was found
|
# Check if error was found
|
||||||
if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then
|
if [ "${!ERRORS_FOUND_LANGUAGE}" -ne 0 ]; then
|
||||||
# Failed exit
|
# Failed exit
|
||||||
echo -e "${NC}${F[R]}Exiting with errors found!${NC}"
|
fatal "Exiting with errors found!${NC}"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1023,7 +1010,7 @@ Footer() {
|
||||||
# Footer prints Exit 0 #
|
# Footer prints Exit 0 #
|
||||||
########################
|
########################
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${NC}${F[G]}All file(s) linted successfully with no errors detected${NC}"
|
notice "All file(s) linted successfully with no errors detected${NC}"
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
# Successful exit
|
# Successful exit
|
||||||
|
@ -1057,9 +1044,8 @@ Header
|
||||||
##############################################################
|
##############################################################
|
||||||
if [ -n "${OUTPUT_FORMAT}" ]; then
|
if [ -n "${OUTPUT_FORMAT}" ]; then
|
||||||
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then
|
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then
|
||||||
echo "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
|
error "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
|
||||||
echo "Please remove the folder and try again."
|
fatal "Please remove the folder and try again."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,12 @@ function LintCodebase() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}"
|
error "Failed to find [${LINTER_NAME}] in system!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
||||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -226,9 +225,9 @@ function LintCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
|
|
||||||
|
@ -243,7 +242,7 @@ function LintCodebase() {
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
|
@ -302,12 +301,11 @@ function TestCodebase() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}"
|
error "Failed to find [${LINTER_NAME}] in system!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
notice "Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -454,16 +452,16 @@ function TestCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
else
|
else
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
||||||
fi
|
fi
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
|
@ -482,18 +480,18 @@ function TestCodebase() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}"
|
error "This file should have failed test case!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}Command run:${NC}[\$${LINT_CMD}]${NC}"
|
error "Command run:${NC}[\$${LINT_CMD}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}"
|
||||||
# Increment the error count
|
# Increment the error count
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
else
|
else
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
notice " - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
||||||
fi
|
fi
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
|
@ -523,16 +521,16 @@ function TestCodebase() {
|
||||||
#############################################
|
#############################################
|
||||||
# We failed to compare the reporting output #
|
# We failed to compare the reporting output #
|
||||||
#############################################
|
#############################################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to assert TAP output:[${LINTER_NAME}]${NC}"!
|
error "Failed to assert TAP output:[${LINTER_NAME}]${NC}"!
|
||||||
echo "Please validate the asserts!"
|
echo "Please validate the asserts!"
|
||||||
cat "${TMPFILE}"
|
cat "${TMPFILE}"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}"
|
notice "Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} No TAP expected file found at:[${EXPECTED_FILE}]${NC}"
|
warn "No TAP expected file found at:[${EXPECTED_FILE}]${NC}"
|
||||||
echo "skipping report assertions"
|
echo "skipping report assertions"
|
||||||
#####################################
|
#####################################
|
||||||
# Append the file type to the array #
|
# Append the file type to the array #
|
||||||
|
@ -548,9 +546,8 @@ function TestCodebase() {
|
||||||
#################################################
|
#################################################
|
||||||
# We failed to find files and no tests were ran #
|
# We failed to find files and no tests were ran #
|
||||||
#################################################
|
#################################################
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"!
|
error "Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"!
|
||||||
echo "Please validate logic or that tests exist!"
|
fatal "Please validate logic or that tests exist!"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -658,14 +655,13 @@ function LintAnsibleFiles() {
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
# Failed
|
# Failed
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find ${LINTER_NAME} in system!${NC}"
|
error "Failed to find ${LINTER_NAME} in system!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}"
|
fatal "[${VALIDATE_INSTALL_CMD}]${NC}"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
# Success
|
# Success
|
||||||
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then
|
||||||
# Success
|
# Success
|
||||||
echo -e "${NC}${F[B]}Successfully found binary in system${NC}"
|
notice "Successfully found binary in system${NC}"
|
||||||
echo "Location:[${VALIDATE_INSTALL_CMD}]"
|
echo "Location:[${VALIDATE_INSTALL_CMD}]"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -777,8 +773,8 @@ function LintAnsibleFiles() {
|
||||||
#########
|
#########
|
||||||
# Error #
|
# Error #
|
||||||
#########
|
#########
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}"
|
error "Found errors in [${LINTER_NAME}] linter!${NC}"
|
||||||
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}"
|
error "[${LINT_CMD}]${NC}"
|
||||||
# Increment error count
|
# Increment error count
|
||||||
((ERRORS_FOUND_ANSIBLE++))
|
((ERRORS_FOUND_ANSIBLE++))
|
||||||
|
|
||||||
|
@ -794,7 +790,7 @@ function LintAnsibleFiles() {
|
||||||
###########
|
###########
|
||||||
# Success #
|
# Success #
|
||||||
###########
|
###########
|
||||||
echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
notice " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}"
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
|
@ -820,7 +816,7 @@ function LintAnsibleFiles() {
|
||||||
########################
|
########################
|
||||||
# No Ansible dir found #
|
# No Ansible dir found #
|
||||||
########################
|
########################
|
||||||
echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}"
|
warn "No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}"
|
||||||
echo "skipping ansible lint"
|
echo "skipping ansible lint"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue