Merge pull request #9936 from hashicorp/b-hcl2-task-env
Allow expressing `meta` and `env` blocks as map attributes as well. `env` and `meta` should support arbitrary key and values, yet hcl2 restricts the keys to valid identifiers. For example, block attribute identifiers may not contain dots, `.`, which frequently used in meta fields, and sometimes in environment variable fields. By adding attribute syntax support, we maintain backward compatibility and relax the block attribute key restrictions. This change attempts to parse `env`/`meta` both as an attribute and as a block. Additionally, the change allows better expressivity for env/meta blocks, using functions and for expressions. For example, one can reuse a set of environment variables for multiple tasks, using a local `common_envs` value: ```hcl env = merge(local.common_envs, {"more_env_key", "..."}) ``` Note that the map/attribute compatibility workaround is currently a pattern we recommend for driver config blocks: https://www.nomadproject.io/docs/job-specification/hcl2#blocks . :( Sadly, the document isn't accurate, as only `meta` appearing inside driver config was handled in 1.0.1. Closes https://github.com/hashicorp/nomad/issues/9606
Showing
+296 -3
Please register or sign in to comment