Skip to content

Commit 04ef2c4

Browse files
author
dacodev
committed
feat: add validation regex to allow for local container templates to be used
1 parent a39dc2a commit 04ef2c4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

variables.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ variable "node_name" {
1515
}
1616
}
1717
variable "container_template_file" {
18-
# todo: figure out local pathing for pre-downloaded
19-
description = "A .tar.zst/.tar.gz/.tar.xz as found at https://us.lxd.images.canonical.com/images/ or http://download.proxmox.com/images/system/"
18+
description = "A .tar.zst/.tar.gz/.tar.xz as found at https://us.lxd.images.canonical.com/images/ or http://download.proxmox.com/images/system/. Container templates pre-downloaded to the Terraform-running machine can also be used."
2019
type = string
2120
validation {
22-
condition = can(regex("(http|https):\\/\\/(.*)(.tar.gz|.tar.zst|.tar.xz)", var.container_template_file))
23-
error_message = "URL should start with HTTP or HTTPS and end with one of .tar.gz, .tar.zst, or .tar.xz."
21+
condition = can(regex("(https?:\\/\\/(.*)\\.(tar\\.gz|tar\\.zst|tar\\.xz))|(([^\\0]+\\.((tar\\.gz)|(tar\\.zst)|(tar\\.xz))))", var.container_template_file))
22+
error_message = "URL should start with HTTP or HTTPS and end with one of .tar.gz, .tar.zst, or .tar.xz. Local file paths should be absolute and start with a /."
2423
}
2524
}
2625
variable "datastore_id" {

0 commit comments

Comments
 (0)