public/Add-WpcDefaultCloneSettings.ps1
|
function Add-WpcDefaultCloneSettings { [CmdletBinding()] param( [Parameter(Mandatory)] [object] $Pipeline, [string] $CloneImage = 'woodpeckerci/plugin-git', [bool] $Lfs = $false, [bool] $Partial = $false, [int] $Depth = 1 ) if ($Pipeline -isnot [System.Collections.IDictionary]) { return $Pipeline } if (Test-WpcDictionaryKey -Dictionary $Pipeline -Key 'clone') { return $Pipeline } $cloneSettings = [ordered]@{ git = [ordered]@{ image = $CloneImage settings = [ordered]@{ lfs = $Lfs partial = $Partial depth = $Depth } } } $result = [ordered]@{} foreach ($key in $Pipeline.Keys) { if ($key -eq 'steps') { $result['clone'] = $cloneSettings } $result[$key] = $Pipeline[$key] } if (-not $result.Contains('clone')) { $result['clone'] = $cloneSettings } return $result } |