Skip to content

Commit

Permalink
fix: wara case
Browse files Browse the repository at this point in the history
  • Loading branch information
kpoineal committed Oct 9, 2024
1 parent a294ac9 commit 56f46af
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 57 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.

0 comments on commit 56f46af

Please sign in to comment.