Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

hclalign

License

NotificationsYou must be signed in to change notification settings

oferchen/hclalign

Repository files navigation

hclalign is a Command Line Interface (CLI) application designed to organize and align HCL (HashiCorp Configuration Language) files.

Features

  • 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.

Getting Started

Prerequisites

You must have Go installed on your system to build and runhclalign.

Installation

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.

Basic Commands

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.

Usage

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"

Command Line Flags

  • --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).

Examples

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"}

Contributing

Contributions tohclalign are welcome! Feel free to fork the repository, submit pull requests, or open issues for any bugs, feature suggestions, or improvements.


[8]ページ先頭

©2009-2025 Movatter.jp