Functions/Public/Get-GocdConfigurationHistory.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Get-GocdConfigurationHistory {
    [CmdletBinding()]
    param(
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Offset = ''
        ,
        [Parameter()]
        [switch]
        $Raw
    )

    $Response = Invoke-GocdApi -Path "/api/config/revisions$Offset"
    $Revisions = $Response | Select-Object -ExpandProperty Content | ConvertFrom-Json

    if ($Raw) {
        $Revisions
        return
    }

    foreach ($Revision in $Revisions) {
        [pscustomobject]@{
            Time       = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($Revision.time / 1000))
            MD5        = $Revision.MD5
            CommitHash = $Revision.commitSHA
        }
    }
}