From b55081891347f9db926566b552f515141f995f88 Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Tue, 6 Sep 2016 12:03:18 +0200 Subject: [PATCH] Update README.md --- README.md | 68 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0e1c3fd..5f8598c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,21 @@ # json2hcl -Convert JSON to HCL via STDIN / STDOUT. +Convert JSON to HCL and HCL to JSON via STDIN / STDOUT. -This tool is in BETA. We'll update the readme from `go run main.go` -> `json2hcl` once we're -shipping binaries for all platforms. +## Install + +Check the [releases](https://github.com/kvz/json2hcl/releases) for the latest version. +Then it's just a matter of downloading the right one for you platform, extracting, making the binary +executable. Here's how it looks for 64 bits Linux: + +```bash +pushd /tmp +curl -SsLo json2hcl_linux_amd64.tar.gz https://github.com/kvz/json2hcl/releases/download/v0.0.5/json2hcl_linux_amd64.tar.gz +tar zxvf json2hcl_linux_amd64.tar.gz +sudo mv json2hcl_linux_amd64/json2hcl /usr/sbin/json2hcl +sudo chmod 755 /usr/sbin/json2hcl +popd +``` ## Use @@ -28,7 +40,7 @@ $ cat fixtures/infra.tf.json Now run it through json2hcl, and it will be converted to HCL ```bash -$ cat fixtures/infra.tf.json | go run main.go +$ cat fixtures/infra.tf.json | json2hcl "output" "arn" { "value" "${aws_dynamodb_table.basic-dynamodb-table.arn}" } @@ -42,7 +54,7 @@ $ cat fixtures/infra.tf.json | go run main.go Typical use would be ```bash -$ cat fixtures/infra.tf.json | go run main.go > infra.tf +$ cat fixtures/infra.tf.json | json2hcl > infra.tf ``` ## hcl2json @@ -50,7 +62,7 @@ $ cat fixtures/infra.tf.json | go run main.go > infra.tf As a bonus, the conversation the other way around is also supported via the `-reverse` flag: ```bash -cat fixtures/infra.tf | go run main.go -reverse +cat fixtures/infra.tf | json2hcl -reverse # Writes JSON to the STDOUT ``` @@ -67,25 +79,45 @@ go get ## Why? -We're building a tool called Frey, and we like HCL. We'd like configuration previously -built in YAML or TOML to be in HCL now as well. It's easy to convert those to JSON, -and HCL is able to read JSON natively, but for readability and maintainability, we wanted to save +If you don't know HCL, read [Why HCL](https://github.com/hashicorp/hcl#why). + +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. +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 but are interested in converting that -to the more human-being friendly HCL format, we thought we'd share. +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. -This tool uses already available HashiCorp libraries to support the conversion. +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. -## Todo +## Changelog + +### Ideabox (Unplanned) -- [ ] Should we perhaps also support the conversion the other way? Just for fun? -- [ ] Tests -- [ ] Error handling -- [ ] Tasks for cross-compiling and shipping releases - [ ] Give the README.md some love +### v0.0.6 (Unreleased) + +- [ ] Tests + +### v0.0.5 (2016-09-06) + +- [x] Add hcl2json via the `-reverse` flag + +### v0.0.4 (2016-09-05) + +- [x] Add hcl2json via the `-reverse` flag +- [x] Error handling +- [x] Cross-compiling and shipping releases + ## Contributors - [Marius Kleidl](https://github.com/Acconut)