synology-community / terraform-provider-synology

Terraform provider to manage DSM APIs on Synology NAS
https://registry.terraform.io/providers/synology-community/synology/latest
MIT License
12 stars 1 forks source link

synology_container_project doesn't like it when no share quota is set #40

Open cyclingwithelephants opened 2 weeks ago

cyclingwithelephants commented 2 weeks ago

Using the following config to set up a container, I receive an error about type casting, I wonder if Share.data.shares.share_quota_logical_size should be a float, or perhaps automatically floor() the number it gets? I have not set any quotas in Synology, and haven't yet figured out how to get this working

resource "synology_container_project" "kopia" {
  name = "kopia"

  service {
    name    = "kopia"
    user    = "root"
    restart = "unless-stopped"

    image {
      name = "kopia/kopia"
      tag  = "20240904.0.45815"
    }

    port {
      target = 51515
    }

    logging {
      driver = "json-file"
    }

    dynamic "volume" {
      for_each = local.volumes
      iterator = each
      content {
        type   = "bind"
        source = each.key
        target = each.value
      }
    }
    environment = {
      TZ = "UTC"
    }

    command = [
      "server",
      "start",
      "--disable-csrf-token-checks",
      "--insecure",
      "--address=0.0.0.0:51515",
      "--server-username=${var.kopia_username}",
      "--server-password=${var.kopia_password}"
    ]
  }
}

produces the following error

╷
│ Error: Failed to create project share
│
│   with synology_container_project.kopia,
│   on main.tf line 2, in resource "synology_container_project" "kopia":
│    2: resource "synology_container_project" "kopia" {
│
│ json: cannot unmarshal number 594513.1875 into Go struct field Share.data.shares.share_quota_logical_size of type int
cyclingwithelephants commented 2 weeks ago

This also fails using the example, updating the port settings to reflect the new schema

cyclingwithelephants commented 2 weeks ago

I have also tried setting share_path = "/volume2/docker", volume2 is my SSD pool, and /volume2/docker is where the container application stores configuration

appkins commented 1 week ago

I'm working on a refactor of this resource. The example is stale at the moment.

This also fails using the example, updating the port settings to reflect the new schema

published (String) The published of the port. target (Number) The target of the port.

I have a working branch I plan to push to main soon that switches from blocks to maps and dynamic objects. Should be much simpler to work out the state drift and get all supported compose properties into the schema.

I also plan to support a content input that takes raw yaml. I'm using the schema at the moment to do things like support config.content, secret.content etc, where the Synology API falls short.