在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:kvz/json2hcl开源软件地址:https://github.com/kvz/json2hcl开源编程语言:HCL 57.8%开源软件介绍:json2hcl (and hcl2json)Convert JSON to HCL and HCL to JSON via STDIN / STDOUT. WarningWe don't use json2hcl anymore ourselves, so we can't invest time into it. However, we're still welcoming PRs. InstallCheck the releases for the latest version. Then it's just a matter of downloading the right one for you platform, and making the binary executable. LinuxHere's how it could look for 64 bits Linux, if you wanted curl -SsL https://github.com/kvz/json2hcl/releases/download/v0.0.6/json2hcl_v0.0.6_linux_amd64 \
| sudo tee /usr/local/bin/json2hcl > /dev/null && sudo chmod 755 /usr/local/bin/json2hcl && json2hcl -version OSXHere's how it could look for 64 bits Darwin, if you wanted curl -SsL https://github.com/kvz/json2hcl/releases/download/v0.0.6/json2hcl_v0.0.6_darwin_amd64 \
| sudo tee /usr/local/bin/json2hcl > /dev/null && sudo chmod 755 /usr/local/bin/json2hcl && json2hcl -version UseHere's an example $ json2hcl < fixtures/infra.tf.json
"output" "arn" {
"value" = "${aws_dynamodb_table.basic-dynamodb-table.arn}"
}
... rest of HCL truncated Typical use would be $ json2hcl < fixtures/infra.tf.json > fixtures/infra.tf hcl2jsonAs a bonus, the conversion the other way around is also supported via the $ json2hcl -reverse < fixtures/infra.tf
{
"output": [
{
"arn": [
{
"value": "${aws_dynamodb_table.basic-dynamodb-table.arn}"
}
]
},
... rest of JSON truncated
]
} Developmentmkdir -p ~/go/src/github.com/kvz
cd ~/go/src/github.com/kvz
git clone [email protected]:kvz/json2hcl.git
cd json2hcl
go get Why?If you don't know HCL, read Why HCL. As for why json2hcl and hcl2json, we're building a tool called Frey that marries multiple underlying tools. We'd like configuration previously written in YAML or TOML to now be in HCL now as well. It's easy enough to convert the mentioned formats to JSON, and strictly speaking HCL is already able to read JSON natively, so why the extra step? We're doing this for readability and maintainability, we wanted to save our infra recipes as HCL directly in our repos, instead of only having machine readable intermediate JSON that we'd need to hack on. This saves time spotting problems, and makes the experience somewhat enjoyable even. In the off-chance you too have machine-readable JSON and are interested in converting that to the more human-being friendly HCL format, we thought we'd share this. It's no rocket science, we're using already available HashiCorp libraries to support the conversion, HashiCorp could have easily released their own tools around this, and perhaps they will, but so far, they haven't. ChangelogIdeabox (Unplanned)
v0.0.7 (Unreleased)
v0.0.6 (2016-09-06)
v0.0.5 (2016-09-06)
v0.0.4 (2016-09-05)
Contributors |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论