Skip to content

Commit 68b65f6

Browse files
authored
check config file exists before move (#713)
1 parent 951765e commit 68b65f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

scripts/sync-to-aws-eks-charts.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,21 @@ gh_client_config_dir="${HOME}/.config/gh"
8888
gh_client_config_path="${gh_client_config_dir}/config.yml"
8989
gh_client_config_backup_path="${gh_client_config_dir}/config.yml.backup"
9090

91+
mkdir -p "${gh_client_config_dir}"
92+
9193
restore_gh_config() {
9294
if [[ -f "${gh_client_config_backup_path}" ]]; then
9395
echo -e "🥑 Restore gh cli configuration"
9496
mv -f "${gh_client_config_backup_path}" "${gh_client_config_path}" || :
9597
fi
9698
}
9799

98-
trap restore_gh_config EXIT
99100

100-
echo "Backing up existing configuration"
101-
mkdir -p "${gh_client_config_dir}"
102-
mv -f "${gh_client_config_path}" "${gh_client_config_backup_path}"
101+
if [[ -e "${gh_client_config_path}" ]]; then
102+
echo "Backing up existing configuration"
103+
mv -f "${gh_client_config_path}" "${gh_client_config_backup_path}"
104+
trap restore_gh_config EXIT
105+
fi
103106

104107
echo "Writing custom configuration"
105108
cat << EOF > "${gh_client_config_path}"
@@ -133,8 +136,8 @@ echo -e "🥑 Check whether chart is in sync"
133136

134137
eks_charts_nth_path="${eks_charts_repo_path}/stable/${helm_chart_name}"
135138
if diff -x ".*" -r "${helm_chart_path}/" "${eks_charts_nth_path}/" &>/dev/null ; then
136-
echo " ✅ Charts already in sync; no updates needed"
137-
exit
139+
echo " ✅ Charts already in sync; no updates needed"
140+
exit
138141
fi
139142

140143
echo -e "🚨 Charts are NOT in sync"

0 commit comments

Comments
 (0)