variable "image_name" {
  type    = string
  default = "docker.io/democraticcsi/democratic-csi:latest"
}

variable "csi_version" {
  type    = string
  default = "1.5.0"
}

locals {
  democratic_nfs_config = file("${path.module}/democratic-nfs-config.yml")
}

# resource "nomad_job" "nfs-monolith" {
#   hcl2 {
#     enabled = true
#     vars = {
#       "image_name" = "${var.image_name}",
#       "csi_version" = "${var.csi_version}",
#     }
#   }
#
#   jobspec = file("${path.module}/democratic-nfs.nomad")
# }

resource "nomad_job" "storage-controller" {
  hcl2 {
    enabled = true
    vars = {
      "image_name"  = var.image_name,
      "csi_version" = var.csi_version,
      "config_data" = local.democratic_nfs_config
    }
  }

  jobspec = file("${path.module}/democratic-csi-nfs-controller.nomad")
}

resource "nomad_job" "storage-node" {
  hcl2 {
    enabled = true
    vars = {
      "image_name"  = var.image_name,
      "csi_version" = var.csi_version,
      "config_data" = local.democratic_nfs_config
    }
  }

  jobspec = file("${path.module}/democratic-csi-nfs-node.nomad")
}