Skip to content

Latest commit

 

History

History
145 lines (105 loc) · 3.44 KB

Invoke-AvmFormat.md

File metadata and controls

145 lines (105 loc) · 3.44 KB

Invoke-AvmFormat

Synopsis

Format all source files in the resolved module under $Path.

Description

Routes to the engine matching the module's ecosystem:

  • bicep -> Format-AvmBicepModule (bicep format)
  • terraform -> Format-AvmTerraformModule (terraform fmt -recursive)

The ecosystem is determined by Get-AvmModuleContext, which honours the .avm/context.psd1 override file and the -Ecosystem filter.

The required tool binary (bicep or terraform) is resolved against the bundled avm.pins; install missing tools beforehand with 'avm tool install bicep' / 'avm tool install terraform'.

Routed by the dispatcher: 'avm format'.

CLI commands

  • avm format

Syntax

Invoke-AvmFormat [[-Path] <string>] [-Ecosystem <string>] [-AllowPathFallback] [-CheckDrift] [-SkipModuleVersionCheck] [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters

-AllowPathFallback

When set, accept a PATH-resolved tool binary that self-reports the lock-pinned version. Off by default; production callers usually want only the managed cache.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-CheckDrift

Report-only mode used by pr-check. Any file that is not already formatted makes the result Status 'fail' and is emitted as an Issue, instead of being silently rewritten. Without it a CI run fixes formatting in the throwaway working copy and reports a pass, so badly formatted sources merge unnoticed.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-Ecosystem

Force the ecosystem selector to 'bicep' or 'terraform' regardless of heuristics. Defaults to 'auto'.

Property Value
Type String
Required false
Position named
Default value auto
Accept pipeline input false
Accept wildcard characters false

-Path

Working directory whose enclosing module to format. Defaults to the current location.

Property Value
Type String
Required false
Position 1
Default value $PWD.Path
Accept pipeline input false
Accept wildcard characters false

-SkipModuleVersionCheck

Skip the PowerShell Gallery check that otherwise stops the command when a newer Avm.Authoring version is available. Writes a warning once.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

Examples

EXAMPLE 1

avm format
# Detect ecosystem from the current directory and format every
# source file under the module root.

EXAMPLE 2

avm format --check-drift
# Fail instead of rewriting: what pr-check runs.

EXAMPLE 3

Invoke-AvmFormat -Path C:\repos\my-module -Ecosystem bicep

EXAMPLE 4

avm format --allow-path-fallback
# Use bicep / terraform from the host PATH when the managed cache
# is empty (useful in tightly-controlled CI images).

Outputs

  • pscustomobject from the engine: Status, Engine, Tool, ToolPath, ToolSource, FilesProcessed, Changed, Issues.