From 7714c05cba9f2b3fee7e79668c4dc566eded0e25 Mon Sep 17 00:00:00 2001 From: Regner Blok-Andersen Date: Tue, 6 Jun 2023 14:41:32 +0100 Subject: [PATCH 1/2] Adding new attributes to the quota spec resource Just a first pass adding the attributes. --- nomad/resource_quota_specification.go | 153 ++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/nomad/resource_quota_specification.go b/nomad/resource_quota_specification.go index a7de0660..55892107 100644 --- a/nomad/resource_quota_specification.go +++ b/nomad/resource_quota_specification.go @@ -63,6 +63,10 @@ func resourceQuotaSpecificationLimits() *schema.Resource { MaxItems: 1, Elem: resourceQuotaSpecificationRegionLimits(), }, + "variables_limit": { + Type: schema.TypeInt, + Optional: true, + }, }, } } @@ -74,10 +78,159 @@ func resourceQuotaSpecificationRegionLimits() *schema.Resource { Type: schema.TypeInt, Optional: true, }, + "cores": { + Type: schema.TypeInt, + Optional: true, + }, + "device": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationDeviceLimits(), + }, + "disk_mb": { + Type: schema.TypeInt, + Optional: true, + }, "memory_mb": { Type: schema.TypeInt, Optional: true, }, + "memory_max_mb": { + Type: schema.TypeInt, + Optional: true, + }, + "network": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationNetworkLimits(), + }, + }, + } +} + +func resourceQuotaSpecificationNetworkLimits() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Optional: true, + }, + "device": { + Type: schema.TypeString, + Optional: true, + }, + "dynamic_port": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationNetworkPortLimits(), + }, + "hostname": { + Type: schema.TypeString, + Optional: true, + }, + "ip": { + Type: schema.TypeString, + Optional: true, + }, + "mode": { + Type: schema.TypeString, + Optional: true, + }, + "reserved_port": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationNetworkPortLimits(), + }, + }, + } +} + +func resourceQuotaSpecificationNetworkPortLimits() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label": { + Type: schema.TypeString, + Required: true, + }, + "static": { + Type: schema.TypeInt, + Optional: true, + }, + "to": { + Type: schema.TypeInt, + Optional: true, + }, + "host_network": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func resourceQuotaSpecificationDeviceLimits() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "affinity": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationDeviceAffinity(), + }, + "count": { + Type: schema.TypeInt, + Optional: true, + }, + "constraint": { + Type: schema.TypeSet, + Optional: true, + Elem: resourceQuotaSpecificationDeviceConstraint(), + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func resourceQuotaSpecificationDeviceConstraint() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "attribute": { + Type: schema.TypeString, + Optional: true, + }, + "operator": { + Type: schema.TypeString, + Optional: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + } +} + +func resourceQuotaSpecificationDeviceAffinity() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "attribute": { + Type: schema.TypeString, + Optional: true, + }, + "operator": { + Type: schema.TypeString, + Optional: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + "weight": { + Type: schema.TypeInt, + Optional: true, + }, }, } } From 784dbabfa13bf74f12c9de7665bbe65660a2d51b Mon Sep 17 00:00:00 2001 From: Regner Blok-Andersen Date: Fri, 9 Jun 2023 12:46:22 +0100 Subject: [PATCH 2/2] Starting docs for quota spec update --- nomad/resource_quota_specification.go | 5 ++- .../docs/r/quota_specification.html.markdown | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/nomad/resource_quota_specification.go b/nomad/resource_quota_specification.go index 55892107..e0a4dbee 100644 --- a/nomad/resource_quota_specification.go +++ b/nomad/resource_quota_specification.go @@ -64,8 +64,9 @@ func resourceQuotaSpecificationLimits() *schema.Resource { Elem: resourceQuotaSpecificationRegionLimits(), }, "variables_limit": { - Type: schema.TypeInt, - Optional: true, + Description: "The maximum total size of all variables.", + Type: schema.TypeInt, + Optional: true, }, }, } diff --git a/website/docs/r/quota_specification.html.markdown b/website/docs/r/quota_specification.html.markdown index 8536af54..a9bbc0b6 100644 --- a/website/docs/r/quota_specification.html.markdown +++ b/website/docs/r/quota_specification.html.markdown @@ -49,6 +49,9 @@ the following arguments: - `region_limit` `(block: )` - The limits to enforce. This block may only be specified once in the `limits` block. Its structure is documented below. +- `variables_limit` `(int: 0)` - The maximum total size of all + variables. A value of zero is treated as unlimited, and a negative value + is treated as fully disallowed. ### `region_limit` blocks @@ -57,6 +60,48 @@ It supports the following arguments: - `cpu` `(int: 0)` - The amount of CPU to limit allocations to. A value of zero is treated as unlimited, and a negative value is treated as fully disallowed. +- `cores` `(int: 0)` - +- `device` `(block: )` - +- `disk_mb` `(int: 0)` - - `memory_mb` `(int: 0)` - The amount of memory (in megabytes) to limit allocations to. A value of zero is treated as unlimited, and a negative value is treated as fully disallowed. +- `memory_max_mb` `(int: 0)` - +- `network` `(block: )` - + +### `device` blocks + +- `affinity` `(black: )` - +- `count` `(int: 0)` - +- `constraint` `(black: )` - +- `name` `(string: "")` - + +### `device_affinity` blocks + +- `attribute` `(string: "")` - +- `operator` `(string: "")` - +- `value` `(string: "")` - +- `weight` `(int: 0)` - + +### `device_constraint` blocks + +- `attribute` `(string: "")` - +- `operator` `(string: "")` - +- `value` `(string: "")` - + +### `network` blocks + +- `cidr` `(string: "")` - +- `device` `(string: "")` - +- `dynamic_port` `(black: )` - +- `hostname` `(string: "")` - +- `ip` `(string: "")` - +- `mode` `(string: "")` - +- `reserved_port` `(black: )` - + +### `network_port` blocks + +- `label` `(string: "")` - +- `static` `(int: 0)` - +- `to` `(int: 0)` - +- `host_network` `(string: "")` -