An error occurred while loading the file. Please try again.
  • Wilken Rivera's avatar
    Add packer fmt command (#10225) · acabc1c1
    Wilken Rivera authored
    * Add packer fmt command
    
    This change adds a new command that allows users to format one or more
    HCL2 Packer configuration template files.
    
    Related to: #9174
    
    * command/fmt: Add check flag
    
    Packer's fmt command now supports a check flag that will output the name
    of any file that would be changed by the HCL2 formatting engine. The
    check flag is mutually exclusive with the write flag and will only check
    if formatting is needed.
    
    The update write flag will now overwrite the source files with the newly
    formatted HCL2 source unless the `-write=false` or `-check` is passed at
    the command line.
    
    * Returns a diagnostic error if Format is unable to show a diff - equivalent to `terraform fmt`
    * Updates testing to run against #Format and not the private methods of the HCL2Formatter; fixes ShowDiff test failure on Windows
    * Updates comments for exported functions
    
    * Add docs for fmt command
    acabc1c1