All Projects → alecthomas → hcl

alecthomas / hcl

Licence: MIT license
Parsing, encoding and decoding of HCL to and from Go types and an AST.

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Labels

Projects that are alternatives of or similar to hcl

Terragrunt Reference Architecture
Terragrunt Reference Architecture (upd: May 2020)
Stars: ✭ 204 (+436.84%)
Mutual labels:  hcl
Multi Container Nginx React Node Mongo
Multi container application with Nginx, React, Node and Mongo DB. This repository also contains Terraform IaC (Infrastructure as Code) for a CICD pipeline to build and push images to DockerHub.
Stars: ✭ 217 (+471.05%)
Mutual labels:  hcl
Terraform validate
Assists in the enforcement of user-defined standards in Terraform
Stars: ✭ 245 (+544.74%)
Mutual labels:  hcl
Terraform Fargate Example
Example repository to run an ECS cluster on Fargate
Stars: ✭ 206 (+442.11%)
Mutual labels:  hcl
Terraform Aws Elastic Beanstalk Environment
Terraform module to provision an AWS Elastic Beanstalk Environment
Stars: ✭ 211 (+455.26%)
Mutual labels:  hcl
Terraform Aws Ecs Container Definition
Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource
Stars: ✭ 217 (+471.05%)
Mutual labels:  hcl
Hclfmt
Format and prettify HCL files
Stars: ✭ 200 (+426.32%)
Mutual labels:  hcl
awesome-json-next
A Collection of What's Next for Awesome JSON (JavaScript Object Notation) for Structured (Meta) Data in Text - JSON5, HJSON, HanSON, TJSON, SON, CSON, USON, JSONX/JSON11 & Many More
Stars: ✭ 50 (+31.58%)
Mutual labels:  hcl
Tf aws vpc
[DEPRECATED] Use https://github.com/terraform-aws-modules/terraform-aws-vpc
Stars: ✭ 214 (+463.16%)
Mutual labels:  hcl
Terraform Aws Tfstate Backend
Terraform module that provision an S3 bucket to store the `terraform.tfstate` file and a DynamoDB table to lock the state file to prevent concurrent modifications and state corruption.
Stars: ✭ 229 (+502.63%)
Mutual labels:  hcl
Intellij Hcl
HCL language support for IntelliJ platform based IDEs
Stars: ✭ 207 (+444.74%)
Mutual labels:  hcl
Terraform Website S3 Cloudfront Route53
Terraform scripts to setup an S3 based static website, with a CloudFront distribution and the required Route53 entries.
Stars: ✭ 210 (+452.63%)
Mutual labels:  hcl
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+492.11%)
Mutual labels:  hcl
Quickstart
Stars: ✭ 206 (+442.11%)
Mutual labels:  hcl
Terraform Aws Atlantis
Terraform configurations for running Atlantis on AWS Fargate. Github, Gitlab and BitBucket are supported
Stars: ✭ 246 (+547.37%)
Mutual labels:  hcl
Terraform Aws Ecs
Terraform module which creates AWS ECS resources
Stars: ✭ 203 (+434.21%)
Mutual labels:  hcl
Terraform Aws Alb
Terraform module to create an AWS Application/Network Load Balancer (ALB/NLB) and associated resources
Stars: ✭ 217 (+471.05%)
Mutual labels:  hcl
terraform-aws-labels
This terraform module is designed to generate consistent label names and tags for resources. You can use terraform-labels to implement a strict naming convention.
Stars: ✭ 32 (-15.79%)
Mutual labels:  hcl
Converge
A powerful and easy-to-use configuration management system.
Stars: ✭ 254 (+568.42%)
Mutual labels:  hcl
Azure arc
Automated Azure Arc environments
Stars: ✭ 224 (+489.47%)
Mutual labels:  hcl

Parsing, encoding and decoding of HCL to and from Go types

CircleCI Go Report Card Slack chat

This package provides idiomatic Go functions for marshalling and unmarshalling HCL, as well as an AST

It supports the same tags as the Hashicorp hcl2 gohcl package, but is much less complex.

Unlike gohcl it also natively supports time.Duration, time.Time, encoding.TextUnmarshaler and json.Unmarshaler.

It is HCL1 compatible and does not support any HCL2 specific features.

Design

HCL -> AST -> Go -> AST -> HCL

Mapping can start from any point in this cycle.

Marshalling, unmarshalling, parsing and serialisation are all structurally isomorphic operations. That is, HCL can be deserialised into an AST or Go, or vice versa, and the structure on both ends will be identical.

HCL is always parsed into an AST before unmarshaling and, similarly, Go structures are always mapped to an AST before being serialised to HCL.

Between And Preserves
HCL AST Structure, values, order, comments.
HCL Go Structure, values, partial comments (via the help:"" tag).
AST Go Structure, values.

Schema reflection

HCL has no real concept of schemas (that I can find), but there is precedent for something similar in Terraform variable definition files. This package supports reflecting a rudimentary schema from Go, where the value for each attribute is one of the scalar types number, string or boolean. Lists and maps are typed by example.

Here's an example schema.

// A string field.
str = string
num = number
bool = boolean
list = [string]

// A map.
map = {
  string: number,
}

// A block.
block "name" {
  attr = string
}

// Repeated blocks.
block_slice "label0" "label1" {
  attr = string
}

Comments are from help:"" tags. See schema_test.go for details.

Struct field tags

The tag format is as with other similar serialisation packages:

hcl:"[<name>][,<option>]"

The supported options are:

Tag Description
attr (default) Specifies that the value is to be populated from an attribute.
block Specifies that the value is to populated from a block.
label Specifies that the value is to populated from a block label.
optional As with attr, but the field is optional.
remain Specifies that the value is to be populated from the remaining body after populating other fields. The field must be of type []hcl.Entry.

Additionally, a separate help:"" tag can be specified to populate comment fields in the AST when serialising Go structures.

Position

Any block with a field named Pos of the type hcl.Position will have that field populated with positional information:

Pos Position `hcl:"-"`
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].