Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Backport of add -check flag to fmt into release/0.10.x #4080

Conversation

hc-github-team-waypoint
Copy link
Collaborator

Backport

This PR is auto-generated from #4020 to be assessed for backporting due to the inclusion of the label backport/0.10.x.

The below text is copied from the body of the original PR.


This PR is meant to handle #3817 and add check support to the fmt command. There's not much to it but in local testing with waypoint.hcl files it seemed to perform as expected, though it's kinda funny that the default config is generated needing formatting.

matt$ ./waypoint fmt -h
Usage: waypoint fmt [options] [FILE]

  Rewrite a waypoint.hcl file to a canonical format.

  This only works for HCL-formatted Waypoint configuration files. JSON-formatted
  files do not work and will result in an error.

  If FILE is not specified, then the current directory will be searched
  for a "waypoint.hcl" file. If FILE is "-" then the content will be read
  from stdin.

  This command does not validate the waypoint.hcl configuration. This will
  work for older and newer configuration formats.

Global Options:

  -app=<string>
      App to target. Certain commands require a single app target for Waypoint
      configurations with multiple apps. If you have a single app, then this
      can be ignored. This is aliased as "-a".

  -plain
      Plain output: no colors, no animation. The default is false.

  -project=<string>
      Project to target. This is aliased as "-p".

  -workspace=<string>
      Workspace to operate in. This is aliased as "-w".

Command Options:

  -check
      Check if the input is formatted. Exit status will be 0 if all input is
      properly formatted and non-zero otherwise. The default is false.

  -write
      Overwrite the input file. If this is false, the formatted output will be
      written to STDOUT. This has no effect when formatting from STDIN or when
      using the -check flag. The default is true.

nick-cage:waypoint on 3817-fmt-check 
matt$ ./waypoint init
Do you want help generating a waypoint.hcl file? Type 'yes' to initialize the interactive generator or 'no' to generate a template waypoint.hcl file: no

Generating template file

Initial Waypoint configuration created!
No Waypoint configuration was found in this directory.

A sample configuration has been created in the file "waypoint.hcl". This
file is heavily commented to help you get started.

Once you've setup your initial configuration, run "waypoint init" again to
validate the configuration and initialize your project.


nick-cage:waypoint on 3817-fmt-check 
matt$ ./waypoint fmt -check waypoint.hcl 


nick-cage:waypoint on 3817-fmt-check 
matt$ echo $?
3

nick-cage:waypoint on 3817-fmt-check 
matt$ ./waypoint fmt
waypoint.hcl

nick-cage:waypoint on 3817-fmt-check 
matt$ ./waypoint fmt -check waypoint.hcl 

nick-cage:waypoint on 3817-fmt-check 
matt$ echo $?
0

@hc-github-team-waypoint hc-github-team-waypoint force-pushed the backport/3817-fmt-check/officially-topical-ferret branch from 8227c95 to e1aa530 Compare October 20, 2022 20:44
@hc-github-team-waypoint hc-github-team-waypoint merged commit e865bab into release/0.10.x Oct 20, 2022
@hc-github-team-waypoint hc-github-team-waypoint deleted the backport/3817-fmt-check/officially-topical-ferret branch October 20, 2022 20:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants