Skip to content

Commit

Permalink
nits: validate terraform snapshot_type input
Browse files Browse the repository at this point in the history
Signed-off-by: samuelarogbonlo <[email protected]>
  • Loading branch information
samuelarogbonlo committed May 6, 2024
1 parent e183cff commit 092dac1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tf-managed/modules/daily-snapshot/service/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ bash newrelic_fail2ban.sh
# Setup cron job
case "$SNAPSHOT_TYPE" in
mainnet)
cp mainnet_cron_job /etc/cron.hourly/ && rm calibnet_cron_job
mv mainnet_cron_job /etc/cron.hourly/
;;
calibnet)
cp calibnet_cron_job /etc/cron.hourly/ && rm mainnet_cron_job
mv calibnet_cron_job /etc/cron.hourly/
;;
both)
cp calibnet_cron_job mainnet_cron_job /etc/cron.hourly/
mv calibnet_cron_job mainnet_cron_job /etc/cron.hourly/
;;
*)
echo "Error: Invalid SNAPSHOT_TYPE. Please specify 'mainnet', 'calibnet', or 'both'."
Expand Down
12 changes: 9 additions & 3 deletions tf-managed/modules/daily-snapshot/variable.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,17 @@ variable "environment" {


variable "snapshot_type" {
description = "The type of snapshot the node should generate. Options are 'mainnet', 'calibnet', or 'both'."
default = "both"
type = string
type = list(string)
description = "List of network types for snapshot generation. Valid options: 'mainnet', 'calibnet'."
default = ["both"]

validation {
condition = alltrue([for val in var.snapshot_type : contains(["mainnet", "calibnet", "both"], val)])
error_message = "Only 'mainnet', 'calibnet', or 'both' are allowed for snapshot_type."
}
}


# Monitoring properties of the service. Can be declared partially.
variable "monitoring" {
description = "Service monitoring properties"
Expand Down

0 comments on commit 092dac1

Please sign in to comment.