hashicorp / hashicorp/hcl

Inconsistent formatting in Nomad template

Open
#279 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug formatter v1
Dominant language
Go
Stars
5.8k
Forks
659
Avg merge
20h 36m
Merged PRs (30d)
6

Description

HCL Template
resources {
  cpu    = 100
  memory = 64

  network {
    mbits = 1
    port  "https"{}
  }
}
Expected behavior

I would expect there to be one space between port and "https" and one space between "https" and the curly braces after formatting (I'm using hclfmt).

Actual behavior

See hcl above for results. Though if you put a newline between mbits and port, you do see the expected formatting after hclfmt.

resources {
  cpu    = 100
  memory = 64

  network {
    mbits = 1

    port "https" {}
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the formatting difference with the two HCL snippets using hclfmt, focusing on the network block and the adjacent mbits and port attributes. Trace the formatter entry point that handles these attributes and verify the result against the expected spacing, including the case where no blank line separates them.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.