hashicorp / hashicorp/nomad

`nomad fmt` fails against topology segments in volume examples

Open
#15,072 1 comment 0 reactions 0 assignees View on GitHub
stage/accepted theme/cli theme/docs theme/hcl type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version

```
$ nomad version
Nomad v1.4.2 (039d70eeef5888164cad05e7ddfd8b6f8220923b)
```

### Operating system and Environment details

n/a

### Issue

I ran `nomad fmt` against the volume example at https://developer.hashicorp.com/nomad/docs/other-specifications/volume, and it failed:

```
Error: Argument definition required

on example_volume.nomad line 27:
27: topology { segments { "rack" = "R2" } }

A single-line block definition can contain only a single argument. If you meant to define argument "segments", use an equals sign to assign it a
value. To define a nested block, place it on a line of its own within its parent block.

Error: Argument definition required

on example_volume.nomad line 31:
31: topology { segments { "rack" = "R1", "zone" = "us-east-1a"} }

A single-line block definition can contain only a single argument. If you meant to define argument "segments", use an equals sign to assign it a
value. To define a nested block, place it on a line of its own within its parent block.
```

If I change the topology definition to use `segments =`, i.e.

```
preferred {
topology {
segments = { "rack" = "R1", "zone" = "us-east-1a"}
}
}
```

then `nomad fmt` completes successfully; but since the official examples use the one-line format, I don't know if the examples are misformatted or if `nomad fmt` is misbehaving.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the volume example at the linked Nomad documentation and reproduce the failure using `nomad fmt` on `example_volume.nomad`, especially lines 27 and 31. Compare the one-line `topology { segments { ... } }` form with the working `segments =` form; done means the official example and formatter behavior agree, with the appropriate example or formatter issue corrected.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.