- Notifications
You must be signed in to change notification settings - Fork0
oferchen/hclalign
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
hclalign
is a Command Line Interface (CLI) application designed to organize and align HCL (HashiCorp Configuration Language) files.
- Flexible File Selection: Use glob patterns to target specific files or groups of files for alignment.
- Customizable Field Order: Define your preferred order of variable block fields to maintain a consistent format across HCL files.
- Concurrent Processing: Leverages Go's concurrency capabilities to process files in parallel, optimizing performance on multicore systems.
- Debugging Support: Includes a debug mode for additional logging, useful for troubleshooting and development.
You must have Go installed on your system to build and runhclalign
.
Clone thehclalign
repository and use the Makefile to build the project:
git clone https://github.com/oferchen/hclalign.gitcd hclalignmake initmake tidymake build
This will compile the project, creating an executable namedhclalign
in the current directory.
To get started withhclalign
, here are some Makefile commands you might find useful:
- Build:
make build
compiles the project into an executable. - Run:
make run
builds and executeshclalign
. - Dependencies:
make deps
downloads the required project dependencies. - Tidy:
make tidy
cleans and verifies the module dependencies. - Test:
make test
runs all configured tests. - Clean:
make clean
removes temporary files and the executable to clean up the project space. - Init:
make init
initializes a new Go module for the project. - Help:
make help
displays available Makefile commands.
Executehclalign
with your target directory or file and optional flags for criteria and order:
./hclalign [target file or directory] --criteria"*.tf,*.hcl" --order"description,type,default,sensitive,nullable,validation"
--criteria, -c
: Glob patterns for selecting files (default:*.tf
).--order, -o
: Specify the order of variable block fields (default:description,type,default,sensitive,nullable,validation
).
Beforehclalign
, a Terraform variable file might look like this:
variable"instance_type" {type=stringdefault="t2.micro"description="EC2 instance type"}variable"instance_count" {type=numberdefault=1description="Number of instances to launch"}variable"ami" {type=stringdefault="ami-0c94855ba95c71c99"description="AMI to use for the instances"}
After runninghclalign
, the file would be reorganized for improved clarity:
variable"instance_type" {description="EC2 instance type"type=stringdefault="t2.micro"}variable"instance_count" {description="Number of instances to launch"type=numberdefault=1}variable"ami" {description="AMI to use for the instances"type=stringdefault="ami-0c94855ba95c71c99"}
Contributions tohclalign
are welcome! Feel free to fork the repository, submit pull requests, or open issues for any bugs, feature suggestions, or improvements.