forked from embryonik-io/kubeadm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.psm1
47 lines (42 loc) · 1.43 KB
/
utils.psm1
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Requires -Version 5.0
$ErrorActionPreference = 'Stop'
$WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$InformationPreference = 'SilentlyContinue'
function Write-LogInfo {
Write-Host -NoNewline -ForegroundColor Blue "INFO: "
Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " "))
}
function Write-LogWarn {
Write-Host -NoNewline -ForegroundColor DarkYellow "WARN: "
Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " "))
}
function Write-LogError {
Write-Host -NoNewline -ForegroundColor DarkRed "ERROR: "
Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " "))
}
function Write-LogFatal {
Write-Host -NoNewline -ForegroundColor DarkRed "FATA: "
Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " "))
exit 255
}
function Invoke-Script {
param (
[parameter(Mandatory = $true)] [string]$File
)
try {
Invoke-Expression -Command $File
if (-not $?) {
Write-LogFatal "Failed to invoke $File"
}
}
catch {
Write-LogFatal "Could not invoke $File, $($_.Exception.Message)"
}
}
Export-ModuleMember -Function Write-LogInfo
Export-ModuleMember -Function Write-LogWarn
Export-ModuleMember -Function Write-LogError
Export-ModuleMember -Function Write-LogFatal
Export-ModuleMember -Function Invoke-Script