public/Add-WpcStepEnvironmentDefaults.ps1

function Add-WpcStepEnvironmentDefaults {
    param(
        [Parameter(Mandatory)]
        [System.Collections.IDictionary] $Step,

        [Parameter(Mandatory)]
        [object] $EnvironmentDefaults
    )

    if ($EnvironmentDefaults -isnot [System.Collections.IDictionary]) {
        return
    }

    if (-not (Test-WpcDictionaryKey -Dictionary $Step -Key 'environment') -or -not $Step['environment']) {
        $Step['environment'] = [ordered]@{}
    }

    if ($Step['environment'] -isnot [System.Collections.IDictionary]) {
        return
    }

    foreach ($key in $EnvironmentDefaults.Keys) {
        if (Test-WpcDictionaryKey -Dictionary $Step['environment'] -Key $key) {
            continue
        }

        $Step['environment'][$key] = Copy-WpcNode $EnvironmentDefaults[$key]
    }
}