Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new attributes to the quota spec resource #332

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions nomad/resource_quota_specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func resourceQuotaSpecificationLimits() *schema.Resource {
MaxItems: 1,
Elem: resourceQuotaSpecificationRegionLimits(),
},
"variables_limit": {
Description: "The maximum total size of all variables.",
Type: schema.TypeInt,
Optional: true,
},
},
}
}
Expand All @@ -74,10 +79,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,
},
},
}
}
Expand Down
45 changes: 45 additions & 0 deletions website/docs/r/quota_specification.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ the following arguments:
- `region_limit` `(block: <required>)` - 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

Expand All @@ -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: <optional>)` -
- `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: <optional>)` -

### `device` blocks

- `affinity` `(black: <optional>)` -
- `count` `(int: 0)` -
- `constraint` `(black: <optional>)` -
- `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: <optional>)` -
- `hostname` `(string: "")` -
- `ip` `(string: "")` -
- `mode` `(string: "")` -
- `reserved_port` `(black: <optional>)` -

### `network_port` blocks

- `label` `(string: "")` -
- `static` `(int: 0)` -
- `to` `(int: 0)` -
- `host_network` `(string: "")` -