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

cleanup files created by deploy.sh #192 #199

Merged
merged 7 commits into from
May 11, 2021
Merged
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
16 changes: 16 additions & 0 deletions src/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ echo "INFO: destroying Terraform using ${mlz_config_file} and ${tfvars_path}..."
"${tfvars_path}" \
"y"

#function to remove files wherever they exist
delete_files_in_directory_by_name() {
directory_to_search=$1
file_name_to_match=$2

matches=$(find "$directory_to_search" -type f -name "$file_name_to_match")

for match in $matches
do
echo "INFO: deleting $match ..."
rm -f "$match"
done
}

# clean up MLZ config resources
delete_files_in_directory_by_name "$this_script_path" "$tfvars_filename"
echo "INFO: cleaning up MLZ resources with tag 'DeploymentName=${mlz_env_name}'..."
. "${this_script_path}/scripts/config/config_clean.sh" "${mlz_config_file}"
rm -rf "${configuration_output_path}/${mlz_env_name}.mlzconfig" "${configuration_output_path:?}/${tfvars_filename}"
Copy link
Contributor

@glennmusa glennmusa May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the unset validator :?? I want to say set -e should throw on a bad reference/path.

Suggested change
rm -rf "${configuration_output_path}/${mlz_env_name}.mlzconfig" "${configuration_output_path:?}/${tfvars_filename}"
rm -rf "${configuration_output_path}/${mlz_env_name}.mlzconfig" "${configuration_output_path}/${tfvars_filename}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with removing it. This is the output from running shellcheck.
$ shellcheck src/clean.sh

In src/clean.sh line 102:
rm -rf "${configuration_output_path}/${mlz_env_name}.mlzconfig" "${configuration_output_path}/${tfvars_filename}"
^-- SC2115: Use "${var:?}" to ensure this never expands to / .

.... So I added ':?' to resolve it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Thanks for sharing!