hashicorp / hashicorp/nomad-pack
Add support for locals
- Dominant language
- Go
- Stars
- 447
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to build a job that contains the following network and service resources and i currently have to specify the port number in both. Of course i can turn this into a pack variable and be done with it, but that feels weird/wrong since the port number is incredibly static in this particular case.
```
network {
mode = "bridge"
port "mysql" {
to = 3306
}
}
[[ if .my.register_consul_service ]]
service {
name = "[[ .my.consul_service_name ]]"
tags = [[ .my.consul_service_tags | toStringList ]]
port = "mysql"
connect {
sidecar_service {
tags = [""]
proxy {
local_service_port = 3306
}
}
}
}
[[ end ]]
```
In terraform we have something called [locals](https://developer.hashicorp.com/terraform/language/values/locals), this would be a nice solution to be able to use this with packs as well. While attempting to use a local block in the variables.hcl file nomad-pack fails with the following error
```
nomad-pack run packs/mysql -f vars/mysql.hcl -f vars/lab.hcl
! Failed To Process Pack
Error: Blocks of type "locals" are not expected here.
Type: *errors.errorString
Context:
- HCL Range:
/Users/attachmentgenie/DevShed/projects/attachmentgenie/nomad-pack-attachmentgenie-registry/pac
- Registry Name: <>
- Pack Name: mysql
- Pack Ref: <>
- Pack Path:
/Users/attachmentgenie/DevShed/projects/attachmentgenie/nomad-pack-attachmentgenie-registry/pac
- Deployment Name: mysql
```
Contributor guide
Assessment
This issue has not been assessed yet.