HCL4j is a Parser for the Hashicorp Configuration Language on the JVM. This provides a mechanism for converting HCL syntax into an Object Map that can be used for further inspection.
Features:
- Support for Syntax parsing
- Nested Array and Map support
Using gradle one can include the hcl4j dependency like so:
dependencies {
compile "com.bertramlabs.plugins:hcl4j:0.4.0"
}
- 0.4.0 Primitive Types are now appended into the Map. These are of an extended
PrimitiveType
class. These Types includeStringPrimitiveType
,NumberPrimitiveType
,BooleanPrimitiveType
,MapPrimitiveType
, and lastlyListPrimitiveType
with asubType
capable property.
Using the HCL Parser is fairly straightfoward. Most calls are still limited to use of the HCLParser
class itself. There are several parse
method helpers supporting both File
, InputStream
, String
, and Reader
as inputs.
import com.bertramlabs.plugins.hcl4j.HCLParser;
File terraformFile = new File("terraform.tf");
Map results = new HCLParser().parse(terraformFile, "UTF-8");
For More Information on the HCL Syntax Please see the project page:
https://github.com/hashicorp/hcl
This plugin does not yet handle processing of the interpolated string syntax. While it does generate it into the result map, Parsing the values of the interpolation syntax needs to be done in a follow up step using some type of HCL runtime engine