-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
57 additions
and
57 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
114 changes: 57 additions & 57 deletions
114
src/modules/WARA/runbook/runbook.psm1 → src/modules/wara2/runbook/runbook.psm1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
<# | ||
.SYNOPSIS | ||
WARA Runbook module | ||
.DESCRIPTION | ||
Enables developers to consume WARA runbook files | ||
#> | ||
|
||
function Read-Runbook { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$RunbookPath | ||
) | ||
|
||
# First, check to make sure the runbook actually exists... | ||
if (!(Test-Path $RunbookPath -PathType Leaf)) { | ||
|
||
# If not, fail early. | ||
Write-Error "[-RunbookPath]: No runbook found at [$RunbookPath]." | ||
$null | ||
|
||
} else { | ||
|
||
# If so, let's read this runbook! | ||
$runbook = @{ | ||
Parameters = @{} | ||
Selectors = @{} | ||
Checks = @{} | ||
QueryOverrides = @() | ||
} | ||
|
||
# Read the runbook JSON | ||
$runbookJson = Get-Content -Raw $RunbookPath | ConvertFrom-Json | ||
|
||
# Try to load parameters | ||
$runbookJson.parameters.PSObject.Properties | ForEach-Object { | ||
$runbook.Parameters[$_.Name] = $_.Value | ||
} | ||
|
||
# Try to load selectors | ||
$runbookJson.selectors.PSObject.Properties | ForEach-Object { | ||
$runbook.Selectors[$_.Name.ToLower()] = $_.Value | ||
} | ||
|
||
# Try to load checks | ||
$runbookJson.checks.PSObject.Properties | ForEach-Object { | ||
$runbook.Checks[$_.Name.ToLower()] = $_.Value | ||
} | ||
|
||
# Try to load query overrides | ||
$runbookJson.query_overrides | ForEach-Object { | ||
$runbook.QueryOverrides += [string]$_ | ||
} | ||
|
||
return [pscustomobject]$runbook | ||
} | ||
} | ||
<# | ||
.SYNOPSIS | ||
WARA Runbook module | ||
.DESCRIPTION | ||
Enables developers to consume WARA runbook files | ||
#> | ||
|
||
function Read-Runbook { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$RunbookPath | ||
) | ||
|
||
# First, check to make sure the runbook actually exists... | ||
if (!(Test-Path $RunbookPath -PathType Leaf)) { | ||
|
||
# If not, fail early. | ||
Write-Error "[-RunbookPath]: No runbook found at [$RunbookPath]." | ||
$null | ||
|
||
} else { | ||
|
||
# If so, let's read this runbook! | ||
$runbook = @{ | ||
Parameters = @{} | ||
Selectors = @{} | ||
Checks = @{} | ||
QueryOverrides = @() | ||
} | ||
|
||
# Read the runbook JSON | ||
$runbookJson = Get-Content -Raw $RunbookPath | ConvertFrom-Json | ||
|
||
# Try to load parameters | ||
$runbookJson.parameters.PSObject.Properties | ForEach-Object { | ||
$runbook.Parameters[$_.Name] = $_.Value | ||
} | ||
|
||
# Try to load selectors | ||
$runbookJson.selectors.PSObject.Properties | ForEach-Object { | ||
$runbook.Selectors[$_.Name.ToLower()] = $_.Value | ||
} | ||
|
||
# Try to load checks | ||
$runbookJson.checks.PSObject.Properties | ForEach-Object { | ||
$runbook.Checks[$_.Name.ToLower()] = $_.Value | ||
} | ||
|
||
# Try to load query overrides | ||
$runbookJson.query_overrides | ForEach-Object { | ||
$runbook.QueryOverrides += [string]$_ | ||
} | ||
|
||
return [pscustomobject]$runbook | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.