Open
Description
I'm not entirely sure if this is a bug or not. However, I was using https://github.com/kvz/json2hcl in reverse mode to convert a HCL example to JSON, and stumbled on this...
HCL Template
Taken directly from https://vagrantcloud.com/help/vault/vsi/configuration
environment "aws" {
}
vault {
address = "https://vault.service.consul:8200"
mount_path = "auth/aws"
}
serve "file" {
path = "/ramdisk/vault-token"
}
Expected behavior
What should have happened?
{
"environment": {
"aws": {}
},
"serve": {
"file": {
"path": "/ramdisk/vault-token"
}
},
"vault": {
"address": "https://vault.service.consul:8200",
"mount_path": "auth/aws"
}
}
Actual behavior
An invalid configuration, according to VSI:
{
"environment": [
{
"aws": [
{}
]
}
],
"serve": [
{
"file": [
{
"path": "/ramdisk/vault-token"
}
]
}
],
"vault": [
{
"address": "https://vault.service.consul:8200",
"mount_path": "auth/aws"
}
]
}
This JSON has an extra level of arrays inside each top-level object, which is detected as invalid.
Steps to reproduce
I was using https://github.com/kvz/json2hcl for this, which is a CLI wrapper around hcl.
- Clone and build https://github.com/kvz/json2hcl
- Write the hcl template example to a file
cat example.hcl | json2hcl -reverse