Fix FILE_STATUS for Dockerfiles

This commit is contained in:
Marco Ferrari 2020-10-24 16:13:16 +02:00
parent c5ba851b72
commit 5be174d8d9

View file

@ -21,8 +21,6 @@ function LintCodebase() {
TEST_CASE_RUN="${1}" && shift TEST_CASE_RUN="${1}" && shift
FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON})
debug "Running LintCodebase. FILE_TYPE: ${FILE_TYPE}. Linter name: ${LINTER_NAME}, linter command: ${LINTER_COMMAND}, TEST_CASE_RUN: ${TEST_CASE_RUN}, FILTER_REGEX_INCLUDE: ${FILTER_REGEX_INCLUDE}, FILTER_REGEX_EXCLUDE: ${FILTER_REGEX_EXCLUDE} files to lint: ${FILE_ARRAY[*]}"
################ ################
# print header # # print header #
################ ################
@ -30,6 +28,8 @@ function LintCodebase() {
info "----------------------------------------------" info "----------------------------------------------"
info "----------------------------------------------" info "----------------------------------------------"
debug "Running LintCodebase. FILE_TYPE: ${FILE_TYPE}. Linter name: ${LINTER_NAME}, linter command: ${LINTER_COMMAND}, TEST_CASE_RUN: ${TEST_CASE_RUN}, FILTER_REGEX_INCLUDE: ${FILTER_REGEX_INCLUDE}, FILTER_REGEX_EXCLUDE: ${FILTER_REGEX_EXCLUDE} files to lint: ${FILE_ARRAY[*]}"
if [ "${TEST_CASE_RUN}" = "true" ]; then if [ "${TEST_CASE_RUN}" = "true" ]; then
info "Testing Codebase [${FILE_TYPE}] files..." info "Testing Codebase [${FILE_TYPE}] files..."
else else
@ -106,6 +106,7 @@ function LintCodebase() {
# Lint the files # # Lint the files #
################## ##################
for FILE in "${LIST_FILES[@]}"; do for FILE in "${LIST_FILES[@]}"; do
debug "Linting FILE: ${FILE}"
################################### ###################################
# Get the file name and directory # # Get the file name and directory #
################################### ###################################
@ -118,23 +119,19 @@ function LintCodebase() {
# Example: markdown_good_1.md -> good # Example: markdown_good_1.md -> good
FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_')
######################################################### ###################
# If not found, assume it should be linted successfully # # Check if docker #
######################################################### ###################
if [ -z "${FILE_STATUS}" ] || { [ "${FILE_STATUS}" != "good" ] && [ "${FILE_STATUS}" != "bad" ]; }; then
FILE_STATUS="good"
fi
#######################################
# Check if docker and get folder name #
#######################################
if [[ ${FILE_TYPE} == *"DOCKER"* ]]; then if [[ ${FILE_TYPE} == *"DOCKER"* ]]; then
debug "FILE_TYPE for FILE ${FILE} is related to Docker: ${FILE_TYPE}"
if [[ ${FILE} == *"good"* ]]; then if [[ ${FILE} == *"good"* ]]; then
debug "Setting FILE_STATUS for FILE ${FILE} to 'good'"
############# #############
# Good file # # Good file #
############# #############
FILE_STATUS='good' FILE_STATUS='good'
else elif [[ ${FILE} == *"bad"* ]]; then
debug "Setting FILE_STATUS for FILE ${FILE} to 'bad'"
############ ############
# Bad file # # Bad file #
############ ############
@ -142,6 +139,14 @@ function LintCodebase() {
fi fi
fi fi
#########################################################
# If not found, assume it should be linted successfully #
#########################################################
if [ -z "${FILE_STATUS}" ] || { [ "${FILE_STATUS}" != "good" ] && [ "${FILE_STATUS}" != "bad" ]; }; then
debug "FILE_STATUS (${FILE_STATUS}) is empty, or not set to 'good' or 'bad'. Assuming it should be linted correctly. Setting FILE_STATUS to 'good'..."
FILE_STATUS="good"
fi
INDIVIDUAL_TEST_FOLDER="${FILE_TYPE,,}" # Folder for specific tests. By convention, it's the lowercased FILE_TYPE INDIVIDUAL_TEST_FOLDER="${FILE_TYPE,,}" # Folder for specific tests. By convention, it's the lowercased FILE_TYPE
debug "File: ${FILE}, FILE_NAME: ${FILE_NAME}, DIR_NAME:${DIR_NAME}, FILE_STATUS: ${FILE_STATUS}, INDIVIDUAL_TEST_FOLDER: ${INDIVIDUAL_TEST_FOLDER}" debug "File: ${FILE}, FILE_NAME: ${FILE_NAME}, DIR_NAME:${DIR_NAME}, FILE_STATUS: ${FILE_STATUS}, INDIVIDUAL_TEST_FOLDER: ${INDIVIDUAL_TEST_FOLDER}"