hcl2json

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 9 Imported by: 0

README

hcl2json

Convert HCL to JSON , and vice versa. Use the latest version hcl source to build.

Build Status

Language

简体中文|English

Install

Linux

Here's how it could look for 64 bits Linux, if you wanted hcl2json available globally inside /usr/local/bin:

curl -SsL https://github.com/gorpher/hcl2json/releases/download/v1.0.0/hcl2json_v1.0.0_linux_amd64 \
  | sudo tee /usr/local/bin/hcl2json > /dev/null && sudo chmod 755 /usr/local/bin/hcl2json && hcl2json -version
OSX

Here's how it could look for 64 bits Darwin, if you wanted hcl2json available globally inside /usr/local/bin:

curl -SsL https://github.com/gorpher/hcl2json/releases/download/v0.0.6/hcl2json_v1.0.1_darwin_amd64 \
  | sudo tee /usr/local/bin/hcl2json > /dev/null && sudo chmod 755 /usr/local/bin/hcl2json && hcl2json -version

Use

Single file convert

Here's an example test-fixtures/hcl_outputs/outputs.tf being converted to JSON:

$ hcl2json -i test-fixtures/hcl_outputs/outputs.tf

{
  "output": [
    {
      "public_ip": [
        {
          "value": "${tencentcloud_instance.cvm_test[0].public_ip}"
        }
      ]
    }
  ]
}

Typical use would be

$ hcl2json -i test-fixtures/hcl_outputs/outputs.tf -o outputs.tf.json

Multi files convert

$ hcl2json -i test-fixtures/ -o test-fixtures-10/

json2hcl

As a bonus, the conversion the other way around is also supported via the -reverse flag:

$ hclwjson -i test-fixtures/json_outputs/outputs.tf.json -reverse


output "public_ip" {
  value = "${tencentcloud_instance.cvm_test[0].public_ip}"
}

Development

git clone git@github.com:gorpher/hcl2json.git
cd json2hcl
go mod tidy

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL