Skip to content

Commit 19e7281

Browse files
committed
Apply recommendations from gemini to user_kustomization
1 parent 391aff0 commit 19e7281

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

modules/user_kustomizations/main.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ resource "null_resource" "kustomization_user_deploy" {
4242
inline = [
4343
<<-EOT
4444
#!/bin/bash
45+
set -e
46+
47+
function cleanup {
48+
echo "Cleaning up ${local.base_destination_folder}..."
49+
rm -rf ${local.base_destination_folder}
50+
}
51+
trap cleanup EXIT
52+
4553
for dest_folder in ${join(" ", local.sorted_kustomization_destination_folders)}; do
4654
if [ -d "$dest_folder" ]; then
4755
echo "Running pre-install script from $dest_folder"
@@ -58,8 +66,6 @@ resource "null_resource" "kustomization_user_deploy" {
5866
/bin/bash "$dest_folder/postinstall.sh"
5967
fi
6068
done
61-
echo "Cleaning up ${local.base_destination_folder}..."
62-
rm -rf ${local.base_destination_folder}/*
6369
EOT
6470
]
6571
}

modules/user_kustomizations/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ variable "kustomizations_map" {
2626
validation {
2727
condition = alltrue([
2828
for key in keys(var.kustomizations_map) :
29-
tonumber(key) > 0 && floor(tonumber(key)) == tonumber(key) && can(regex("^[0-9]+$", key))
29+
can(regex("^[0-9]+$", key)) && tonumber(key) > 0
3030
])
3131
error_message = "All keys in kustomizations_map must be numeric strings (e.g., '1', '2')."
3232
}

0 commit comments

Comments
 (0)