From 5d3c4a99c136d1b081cfaa5456df447a5497d7eb Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Mon, 29 Jun 2020 14:38:24 -0500 Subject: [PATCH] adding cloud formation --- lib/buildFileList.sh | 37 +++++++++++++++++++++++++++++-------- lib/linter.sh | 5 +++-- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index d39f7a64..dde4c70c 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -100,18 +100,26 @@ function BuildFileList() #echo "FILE_TYPE:[$FILE_TYPE]" ##################### - # Get the YML files # + # Get the CFN files # ##################### - if [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ]; then + if [ "$FILE_TYPE" == "json" ] || [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ] && DetectCloudFormationFile "$FILE"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_YML+=("$FILE") - ############################ - # Check if file is OpenAPI # - ############################ - if DetectOpenAPIFile "$FILE"; then - FILE_ARRAY_OPENAPI+=("$FILE") + FILE_ARRAY_CFN+=("$FILE") + ########################################################## + # Set the READ_ONLY_CHANGE_FLAG since this could be exec # + ########################################################## + READ_ONLY_CHANGE_FLAG=1 + + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "$FILE"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CFN+=("$FILE") fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # @@ -129,8 +137,21 @@ function BuildFileList() # Check if file is OpenAPI # ############################ if DetectOpenAPIFile "$FILE"; then + ################################ + # Append the file to the array # + ################################ FILE_ARRAY_OPENAPI+=("$FILE") fi + + ##################################### + # Check if the file is CFN template # + ##################################### + if DetectCloudFormationFile "$FILE"; then + ################################ + # Append the file to the array # + ################################ + FILE_ARRAY_CFN+=("$FILE") + fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## diff --git a/lib/linter.sh b/lib/linter.sh index 11431dcd..62d0752f 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -450,11 +450,11 @@ DetectOpenAPIFile() return 1 fi } - +################################################################################ #### Function DetectCloudFormationFile ######################################### -# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html DetectCloudFormationFile() { + # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html # AWSTemplateFormatVersion is optional if grep 'AWSTemplateFormatVersion' "${1}" > /dev/null; then return 0 @@ -677,6 +677,7 @@ Footer() [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || \ [ "$ERRORS_FOUND_RUBY" -ne 0 ] || \ [ "$ERRORS_FOUND_CSS" -ne 0 ] || \ + [ "$ERRORS_FOUND_CFN" -ne 0 ] || \ [ "$ERRORS_FOUND_ENV" -ne 0 ] || \ [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || \ [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || \