Private/Config-Helpers/Convert-BicepConfigToInputConfig.ps1

function Convert-BicepConfigToInputConfig {
    [CmdletBinding(SupportsShouldProcess = $true)]
    param (
        [Parameter(Mandatory = $false)]
        [PSCustomObject]$bicepConfig,

        [Parameter(Mandatory = $false)]
        [PSCustomObject]$appendToObject = $null
    )

    if ($PSCmdlet.ShouldProcess("Parse Interface Variables into Config", "modify")) {

        $configItems = [PSCustomObject]@{}
        if ($appendToObject -ne $null) {
            $configItems = $appendToObject
        }

        foreach ($variable in $bicepConfig.inputs.PSObject.Properties) {
            Write-Verbose "Parsing variable $($variable.Name)"
            $description = $variable.Value.description

            $configItem = [PSCustomObject]@{}
            $configItem | Add-Member -NotePropertyName "Source" -NotePropertyValue $variable.Value.source
            $configItem | Add-Member -NotePropertyName "Value" -NotePropertyValue ""

            if ($variable.Value.PSObject.Properties.Name -contains "sourceInput") {
                $configItem | Add-Member -NotePropertyName "SourceInput" -NotePropertyValue $variable.Value.sourceInput
            }

            if ($variable.Value.PSObject.Properties.Name -contains "pattern") {
                $configItem | Add-Member -NotePropertyName "Pattern" -NotePropertyValue $variable.Value.pattern
            }

            if ($variable.Value.PSObject.Properties.Name -contains "process") {
                $configItem | Add-Member -NotePropertyName "Process" -NotePropertyValue $variable.Value.process
            }

            if ($variable.Value.PSObject.Properties.Name -contains "default") {
                $defaultValue = $variable.Value.default
                $configItem | Add-Member -NotePropertyName "DefaultValue" -NotePropertyValue $defaultValue
            }

            if ($variable.Value.PSObject.Properties.Name -contains "targets") {
                $configItem | Add-Member -NotePropertyName "targets" -NotePropertyValue $variable.Value.targets
            }

            $configItem | Add-Member -NotePropertyName "Sensitive" -NotePropertyValue $false

            $configItem | Add-Member -NotePropertyName "Description" -NotePropertyValue $description
            $configItems | Add-Member -NotePropertyName $variable.Name -NotePropertyValue $configItem
        }
    }

    return $configItems
}