Created
July 20, 2018 15:55
-
-
Save ssougnez/dc5030b013ef972a0ad47bfd8e070b99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Error { | |
Param([string]$message) | |
return @{ | |
Type = [ResultType]::Error | |
Message = $message | |
} | |
} | |
Function Success { | |
return @{ | |
Type = [ResultType]::Success | |
} | |
} | |
Function Warning { | |
Param([string]$message) | |
return @{ | |
Type = [ResultType]::Warning | |
Message = $message | |
} | |
} | |
Function HandleResult { | |
Param( | |
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[Hashtable]$result | |
) | |
Process { | |
if ($result.Type -eq [ResultType]::Success) { | |
Write-Host "Done!" -ForegroundColor Cyan | |
} | |
if ($result.Type -eq [ResultType]::Warning) { | |
Write-Host $result.Message -ForegroundColor Yellow | |
} | |
if ($result.Type -eq [ResultType]::Error) { | |
Write-Host $result.Message -ForegroundColor Red | |
throw "Deployment can't continue..." | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment