Documentation

format does for a .glaze file what gofmt does for Go: one canonical layout, so a diff shows what changed and not how someone’s editor feels about indentation. Add --validate and it also decodes the profile, which makes it the cheapest CI check you will add this year.

Console
$ glaze format                                   # format ./.glaze in place
$ glaze format --stdout                          # print the formatted output; do not write
$ glaze format --validate                        # decode and report diagnostics, then format
$ glaze format --validate --var region=us-east-1 # supply declared variables

Flags

FlagDescription
--stdoutPrint the formatted output. Do not write the file.
--validateDecode the profile and report diagnostics before the format step.
--profile-pathThe path to a .glaze file. See Profile resolution.
--var key=valueSet a variable. The flag is repeatable. See Variables.
--var-file <path>An HCL file of variable values.

Validation

The --validate flag enforces the full variable contract. A required variable must get a value from --var or from a default. A profile fails validation without one. One run reports each problem that Glazier can find, for example a duplicate variable, a malformed block or a local that cannot resolve. It does not stop at the first problem. See Diagnostics.

How format writes the file

format writes the new profile to a temporary file and then renames it over the old one. Thus a failed write, for example on a full disk, keeps the old profile. format writes through a symlink and keeps the permissions of the file. It does not write a profile that is already formatted, so the modification time does not change.

A profile that is not a regular file, for example a pipe or /dev/stdin, cannot be formatted in place. Use --stdout for it. format --stdout and format --validate --stdout read a pipe, for example glaze format --validate --stdout --profile-path <(envsubst < gig.glaze).

The temporary file is there because the obvious approach, open the file and write into it, truncates it first. A full disk or a kill in the middle then leaves you with an empty profile and a lesson. Glazier skips the lesson.

Exit codes

CodeMeaning
0The profile is formatted and, with --validate, has no errors.
1Glazier could not write the profile.
3The profile has errors, or Glazier cannot find the profile.

A failed write is a plain error, not a diagnostic, so a script can tell “the profile is wrong” from “the disk is full”.

In CI

Run glaze format --validate --stdout in a pipeline step. Each error-severity diagnostic causes exit code 3, so the step fails on a broken profile. Supply each required variable with --var or a --var-file. With --stdout, the step does not write to the file in the checkout. See Scripting.