mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 14:10:56 -05:00
made it better to read
This commit is contained in:
parent
5d3c4a99c1
commit
b3e44a5c7e
1 changed files with 34 additions and 7 deletions
|
@ -454,24 +454,51 @@ DetectOpenAPIFile()
|
||||||
#### Function DetectCloudFormationFile #########################################
|
#### Function DetectCloudFormationFile #########################################
|
||||||
DetectCloudFormationFile()
|
DetectCloudFormationFile()
|
||||||
{
|
{
|
||||||
|
################
|
||||||
|
# Pull in Vars #
|
||||||
|
################
|
||||||
|
FILE="$1" # File that we need to validate
|
||||||
|
|
||||||
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html
|
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html
|
||||||
# AWSTemplateFormatVersion is optional
|
# AWSTemplateFormatVersion is optional
|
||||||
if grep 'AWSTemplateFormatVersion' "${1}" > /dev/null; then
|
#######################################
|
||||||
return 0
|
# Check if file has AWS Template info #
|
||||||
fi
|
#######################################
|
||||||
if cat "${1}" | shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null; then
|
if grep 'AWSTemplateFormatVersion' "$FILE" > /dev/null; then
|
||||||
|
# Found it
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if cat "${1}" | jq -e 'has("Resources")' > /dev/null 2>&1; then
|
###################################################
|
||||||
if cat "${1}" | jq ".Resources[].Type" 2>/dev/null | grep -q -E "(AWS|Alexa|Custom)"; then
|
# Check if file has AWSTemplateFormatVersion info #
|
||||||
|
###################################################
|
||||||
|
if shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null < "$FILE"; then
|
||||||
|
# Found it
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# check if file has resources #
|
||||||
|
###############################
|
||||||
|
if jq -e 'has("Resources")' > /dev/null 2>&1 < "$FILE"; then
|
||||||
|
# Check if AWS Alexa or custom
|
||||||
|
if jq ".Resources[].Type" 2>/dev/null | grep -q -E "(AWS|Alexa|Custom)" < "$FILE"; then
|
||||||
|
# Found it
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if cat "${1}" | shyaml values-0 Resources | grep -q -E "Type: (AWS|Alexa|Custom)"; then
|
|
||||||
|
################################
|
||||||
|
# See if it contains resources #
|
||||||
|
################################
|
||||||
|
if shyaml values-0 Resources | grep -q -E "Type: (AWS|Alexa|Custom)" < "$FILE"; then
|
||||||
|
# Found it
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# No identifiers of a CFN template found #
|
||||||
|
##########################################
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue