Skip to content
/ hcl4j Public
forked from bertramdev/hcl4j

HCL is the Hashicorp Configuration Language used in Terraform. This is a java Parser for parsing HCL and converting to Map objects.

Notifications You must be signed in to change notification settings

ascheman/hcl4j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Gradle Project

HCL4j

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

Installation

Using gradle one can include the hcl4j dependency like so:

dependencies {
	compile "net.aschemann.iac:hcl4j:0.4.4"
}

What's New

  • 0.4.0 Primitive Types are now appended into the Map. These are of an extended PrimitiveType class. These Types include StringPrimitiveType, NumberPrimitiveType, BooleanPrimitiveType, MapPrimitiveType, and lastly ListPrimitiveType with a subType capable property.

Usage

Using the HCL Parser is fairly straight forward. 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

Things to be Done

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 followup step using some type of HCL runtime engine

Development

Known Bugs

  • If a block is completely on one line (cf. TODOs in HCLParserSpec, it cannot be parsed correctly)

About

HCL is the Hashicorp Configuration Language used in Terraform. This is a java Parser for parsing HCL and converting to Map objects.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 41.5%
  • Groovy 29.5%
  • Lex 29.0%