Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: BASH_SHFMT linter + linter fixes #709

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ max_line_length = 120
indent_style = tab
indent_size = 4
tab_width = 4

[*.sh]
space_redirects = true
7 changes: 6 additions & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ APPLY_FIXES: none
# If you use ENABLE_LINTERS variable, all other linters will be disabled by default
ENABLE_LINTERS:
- BASH_EXEC
- BASH_SHFMT
- CLOUDFORMATION_CFN_LINT
- DOCKERFILE_HADOLINT
- EDITORCONFIG_EDITORCONFIG_CHECKER
Expand All @@ -30,16 +31,20 @@ FILEIO_REPORTER: false

# Install plugin for list handling.
JSON_PRETTIER_PRE_COMMANDS:
- command: "npm install prettier-plugin-multiline-arrays@3.0.0"
- command: "npm install prettier-plugin-multiline-arrays@3.0.4"
cwd: "workspace"

CLOUDFORMATION_CFN_LINT_CONFIG_FILE: '.cfnlintrc'
CLOUDFORMATION_CFN_LINT_FILE_EXTENSIONS: [".yml", ".yaml"]

EDITORCONFIG_EDITORCONFIG_CHECKER_CONFIG_FILE: '.ecrc.json'

MARKDOWN_MARKDOWN_LINK_CHECK_ARGUMENTS: '-q'
MARKDOWN_MARKDOWNLINT_DISABLE_ERRORS: false

SPELL_CSPELL_ARGUMENTS: '--gitignore --no-progress --show-suggestions'
SPELL_CSPELL_FILE_EXTENSIONS: ["*"]

TERRAFORM_TFLINT_UNSECURED_ENV_VARIABLES:
- GITHUB_TOKEN

Expand Down
2 changes: 1 addition & 1 deletion samples/sample-ec2-java-app-codedeploy/scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "Waiting for 15 seconds before checking health.."
sleep 15

status_code=$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:80)
if [[ "$status_code" -ne 200 ]] ; then
if [[ "$status_code" -ne 200 ]]; then
echo "App is not healthy - $status_code"
exit 1
else
Expand Down
33 changes: 16 additions & 17 deletions samples/sample-ec2-with-codedeploy/scripts/install-codedeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set -xe

## Code Deploy Agent Bootstrap Script ##

exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
exec > >(tee /var/log/user-data.log | logger -t user-data -s 2> /dev/console) 2>&1
AUTOUPDATE=false

function installdep(){
function installdep() {
if [ ${PLAT} = "ubuntu" ]; then
apt-get -y update
# Satisfying even Ubuntu older versions.
Expand All @@ -18,7 +18,7 @@ function installdep(){
fi
}

function platformize(){
function platformize() {
# Linux OS detection
if hash lsb_release; then
echo "Ubuntu server OS detected"
Expand All @@ -32,21 +32,20 @@ function platformize(){
fi
}


function execute(){
function execute() {
if [ ${PLAT} = "ubuntu" ]; then
cd /tmp/
wget https://aws-codedeploy-${REGION}.s3.${REGION}.amazonaws.com/latest/install
chmod +x ./install

if ./install auto; then
echo "Installation completed"
if ! ${AUTOUPDATE}; then
echo "Disabling Auto Update"
sed -i '/@reboot/d' /etc/cron.d/codedeploy-agent-update
chattr +i /etc/cron.d/codedeploy-agent-update
rm -f /tmp/install
fi
if ! ${AUTOUPDATE}; then
echo "Disabling Auto Update"
sed -i '/@reboot/d' /etc/cron.d/codedeploy-agent-update
chattr +i /etc/cron.d/codedeploy-agent-update
rm -f /tmp/install
fi
exit 0
else
echo "Installation script failed, please investigate"
Expand All @@ -61,12 +60,12 @@ function execute(){

if ./install auto; then
echo "Installation completed"
if ! ${AUTOUPDATE}; then
echo "Disabling auto update"
sed -i '/@reboot/d' /etc/cron.d/codedeploy-agent-update
chattr +i /etc/cron.d/codedeploy-agent-update
rm -f /tmp/install
fi
if ! ${AUTOUPDATE}; then
echo "Disabling auto update"
sed -i '/@reboot/d' /etc/cron.d/codedeploy-agent-update
chattr +i /etc/cron.d/codedeploy-agent-update
rm -f /tmp/install
fi
exit 0
else
echo "Installation script failed, please investigate"
Expand Down
6 changes: 4 additions & 2 deletions samples/sample-ec2-with-codedeploy/scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ sudo useradd springboot
sudo chsh -s /sbin/nologin springboot

# forward port 80 to 8080
echo "<VirtualHost *:80>
echo "
<VirtualHost *:80>
ProxyRequests Off
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>" >> sudo /etc/httpd/conf/httpd.conf
</VirtualHost>
" | sudo tee -a /etc/httpd/conf/httpd.conf > /dev/null

# start the httpd service now and stop it until userdata
sudo service httpd start
Expand Down
3 changes: 2 additions & 1 deletion samples/sample-fargate-node-app/build/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
docker push $REPOSITORY_URI:latest
docker push $REPOSITORY_URI:$IMAGE_TAG

tmp=$(mktemp); jq --arg REPOSITORY_URI "$REPOSITORY_URI" --arg IMAGE_TAG "$IMAGE_TAG" '.Parameters.Image = $REPOSITORY_URI+":"+$IMAGE_TAG' params/global.json > "$tmp" && mv "$tmp" params/global.json
tmp=$(mktemp)
jq --arg REPOSITORY_URI "$REPOSITORY_URI" --arg IMAGE_TAG "$IMAGE_TAG" '.Parameters.Image = $REPOSITORY_URI+":"+$IMAGE_TAG' params/global.json > "$tmp" && mv "$tmp" params/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ set -e
SKIP_BUILD=0

# Walk through the options passed to this script
for i in "$@"
do
for i in "$@"; do
case $i in
--no-build)
SKIP_BUILD=1
;;
*)
echo "Unknown option: $i"
exit 1
;;
--no-build)
SKIP_BUILD=1
;;
*)
echo "Unknown option: $i"
exit 1
;;
esac
done

Expand All @@ -34,16 +33,15 @@ fi

# Get list of regions supported by this application
echo "Determine which regions need to be prepared"
app_regions=`aws ssm get-parameters --names /adf/deployment/$ADF_DEPLOYMENT_MAP_SOURCE/$ADF_PROJECT_NAME/regions --with-decryption --output=text --query='Parameters[0].Value'`
app_regions=$(aws ssm get-parameters --names /adf/deployment/$ADF_DEPLOYMENT_MAP_SOURCE/$ADF_PROJECT_NAME/regions --with-decryption --output=text --query='Parameters[0].Value')
# Convert json list to bash list (space delimited regions)
regions="`echo $app_regions | sed -e 's/\[\([^]]*\)\]/\1/g' | sed 's/,/ /g' | sed "s/'//g"`"
regions="$(echo $app_regions | sed -e 's/\[\([^]]*\)\]/\1/g' | sed 's/,/ /g' | sed "s/'//g")"

for region in $regions
do
for region in $regions; do
if [ $CONTAINS_TRANSFORM ]; then
echo "Packaging templates for region $region"
ssm_bucket_name="/adf/cross_region/s3_regional_bucket/$region"
bucket=`aws ssm get-parameters --names $ssm_bucket_name --with-decryption --output=text --query='Parameters[0].Value'`
bucket=$(aws ssm get-parameters --names $ssm_bucket_name --with-decryption --output=text --query='Parameters[0].Value')
sam package --s3-bucket $bucket --output-template-file $CODEBUILD_SRC_DIR/template_$region.yml --region $region
else
# If package is not needed, just copy the file for each region
Expand Down
Loading