variable "wait_on" {
  type        = any
  description = "Resources to wait on"
  default     = true
}

variable "server_ip" {
  type = string
}

variable "ssh_private_key_path" {
  type = string
}

variable "server_domain" {
  type = string
}

module "beets" {
  source = "../quadlet-app"
  wait_on = var.wait_on

  server_ip            = var.server_ip
  ssh_private_key_path = var.ssh_private_key_path

  app_name = "beets"
  image    = "lscr.io/linuxserver/beets:latest"
  ports    = ["8337:8337"]
  volumes = [
    "/opt/storage/data/beets/config:/config:Z",
    "/opt/storage/media/music:/music:z",
    "/opt/storage/media/downloads:/downloads:z"
  ]

  environment = {
    PUID = "1001"
    PGID = "1001"
    TZ   = "Europe/Amsterdam"
  }

  haproxy_services = [
    {
      name   = "beets"
      domain = "beets.${var.server_domain}"
      port   = "8337"
      host   = "127.0.0.1"
      tls    = false
    }
  ]
}

output "app_urls" {
  value = module.beets.app_urls
}

output "installed" {
  value = true
  depends_on = [module.beets.installed]
}