Hcl.psm1
|
[CmdletBinding()] param() $baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) $script:PSModuleInfo = Import-PowerShellDataFile -Path "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" #region [functions] - [public] Write-Debug "[$scriptName] - [functions] - [public] - Processing folder" #region [functions] - [public] - [ConvertFrom-Hcl] Write-Debug "[$scriptName] - [functions] - [public] - [ConvertFrom-Hcl] - Importing" function ConvertFrom-Hcl { <# .SYNOPSIS Converts an HCL string to a PowerShell object. .DESCRIPTION Converts a HashiCorp Configuration Language (HCL) formatted string into a PowerShell object. Supports HCL syntax as used in Terraform configuration files (.tf), variable files (.tfvars), and other infrastructure-as-code tooling. .EXAMPLE ConvertFrom-Hcl -InputObject 'locals { environment = "production" }' Converts an HCL string to a PowerShell object. #> [CmdletBinding()] param ( # The HCL string to convert. [Parameter(Mandatory)] [string] $InputObject ) $null = $InputObject throw [System.NotImplementedException] 'ConvertFrom-Hcl is not yet implemented.' } Write-Debug "[$scriptName] - [functions] - [public] - [ConvertFrom-Hcl] - Done" #endregion [functions] - [public] - [ConvertFrom-Hcl] #region [functions] - [public] - [ConvertTo-Hcl] Write-Debug "[$scriptName] - [functions] - [public] - [ConvertTo-Hcl] - Importing" function ConvertTo-Hcl { <# .SYNOPSIS Converts a PowerShell object to an HCL string. .DESCRIPTION Converts a PowerShell object into a HashiCorp Configuration Language (HCL) formatted string, suitable for use in Terraform configuration files (.tf), variable files (.tfvars), and other infrastructure-as-code tooling. .EXAMPLE @{ environment = 'production' } | ConvertTo-Hcl Converts a PowerShell hashtable to an HCL string. #> [CmdletBinding()] param ( # The PowerShell object to convert to HCL. [Parameter( Mandatory, ValueFromPipeline )] [object] $InputObject ) process { $null = $InputObject throw [System.NotImplementedException] 'ConvertTo-Hcl is not yet implemented.' } } Write-Debug "[$scriptName] - [functions] - [public] - [ConvertTo-Hcl] - Done" #endregion [functions] - [public] - [ConvertTo-Hcl] Write-Debug "[$scriptName] - [functions] - [public] - Done" #endregion [functions] - [public] #region Member exporter $exports = @{ Alias = '*' Cmdlet = '' Function = @( 'ConvertFrom-Hcl' 'ConvertTo-Hcl' ) Variable = '' } Export-ModuleMember @exports #endregion Member exporter |