hashicorp / hashicorp/nomad

Support optional object type attributes in Nomad HCL variables

Open
#25,317 6 comments 2 reactions 0 assignees View on GitHub
hcc/jira stage/accepted theme/hcl theme/jobspec type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal

Support `optional(...)` in object type attributes, similar to the [equivalent feature from Terraform](https://developer.hashicorp.com/terraform/language/expressions/type-constraints#optional-object-type-attributes)

### Use-cases

Variables that use complex types (e.g. `list(object({ ... }))`, where some fields are optional, currently have to be specified in full, or have to be defined as maps where the burden of type validation falls on the template author.

### Attempted Solutions

* Using a `type = map(string)` and checking each field for existence/type-correctness
* Using a `type = string`, setting the value to some structured data format, like JSON or YAML, which is then `(yaml|json)decode`d and its contents' fields checked for existence/type-correctness

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.