Skip to content

Commit

Permalink
fix: clone policies repo once per build (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliocc authored and bharathkkb committed Mar 31, 2021
1 parent c3b19e8 commit 3e95111
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build/tf-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ tf_validate() {
cd "$path" || exit
terraform show -json "${tmp_plan}/${tf_component}-${tf_env}.tfplan" > "${tf_env}.json" || exit 32
if [[ "$policy_type" == "CLOUDSOURCE" ]]; then
gcloud source repos clone gcp-policies "${policy_file_path}" --project="${project_id}" || exit 34
# Check if $policy_file_path is empty so we clone the policies repo only once
if [ -z "$(ls -A "${policy_file_path}" 2> /dev/null)" ]; then
gcloud source repos clone gcp-policies "${policy_file_path}" --project="${project_id}" || exit 34
fi
fi
terraform-validator validate "${tf_env}.json" --policy-path="${policy_file_path}" --project="${project_id}" || exit 33
cd "$base_dir" || exit
Expand Down

0 comments on commit 3e95111

Please sign in to comment.