Resolving comments from PR in SaltStackConfig module
Promoting properties on the connection object as requested in PR comment. Signed-off-by: Brian Wuchner <brian.wuchner@gmail.com>
This commit is contained in:
@@ -24,13 +24,13 @@
|
|||||||
<TableRowEntry>
|
<TableRowEntry>
|
||||||
<TableColumnItems>
|
<TableColumnItems>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<PropertyName>SscServer</PropertyName>
|
<PropertyName>Server Name</PropertyName>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.ConnectionDetail.attributes.config_name +'\'+ $_.ConnectionDetail.attributes.username</ScriptBlock>
|
<PropertyName>Connected As</PropertyName>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.ConnectionDetail.authenticated</ScriptBlock>
|
<PropertyName>Authenticated</PropertyName>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
</TableColumnItems>
|
</TableColumnItems>
|
||||||
</TableRowEntry>
|
</TableRowEntry>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause
|
|||||||
RootModule = 'SaltStackConfig.psm1'
|
RootModule = 'SaltStackConfig.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '0.0.4'
|
ModuleVersion = '0.0.5'
|
||||||
|
|
||||||
# Supported PSEditions
|
# Supported PSEditions
|
||||||
# CompatiblePSEditions = @()
|
# CompatiblePSEditions = @()
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ Function Connect-SscServer {
|
|||||||
$ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken')
|
$ws.headers.Add('X-Xsrftoken', $webRequest.headers.'x-xsrftoken')
|
||||||
$webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody)
|
$webRequest = Invoke-WebRequest -Uri "https://$server/account/login" -WebSession $ws -method POST -body (ConvertTo-Json $loginBody)
|
||||||
$webRequestJson = ConvertFrom-JSON $webRequest.Content
|
$webRequestJson = ConvertFrom-JSON $webRequest.Content
|
||||||
$global:DefaultSscConnection = New-Object psobject -property @{ "SscWebSession"=$ws; "SscServer"=$server; "ConnectionDetail"=$webRequestJson; PSTypeName='SscConnection' }
|
$global:DefaultSscConnection = New-Object psobject -property @{ 'SscWebSession'=$ws; 'Server Name'=$server; 'ConnectionDetail'=$webRequestJson;
|
||||||
|
'Connected As'=$webRequestJson.attributes.config_driver +'\'+ $username; 'Authenticated'=$webRequestJson.authenticated; PSTypeName='SscConnection' }
|
||||||
|
|
||||||
# Return the connection object
|
# Return the connection object
|
||||||
$global:DefaultSscConnection
|
$global:DefaultSscConnection
|
||||||
@@ -104,7 +105,7 @@ Function Get-SscData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.SscServer)/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json'
|
$output = Invoke-WebRequest -WebSession $global:DefaultSscConnection.SscWebSession -Method POST -Uri "https://$($global:DefaultSscConnection.'Server Name')/rpc" -body $(ConvertTo-Json $body) -ContentType 'application/json'
|
||||||
$outputJson = (ConvertFrom-Json $output.Content)
|
$outputJson = (ConvertFrom-Json $output.Content)
|
||||||
|
|
||||||
if ($outputJson.error) { Write-Error $outputJson.error }
|
if ($outputJson.error) { Write-Error $outputJson.error }
|
||||||
|
|||||||
Reference in New Issue
Block a user