Improving a syntax for the Outputs section #150
Replies: 2 comments 3 replies
-
|
I feel that would fail when you output objects (which I do a lot) Also the I think output definitions could allow for simple syntax like this Output 'hostname' [string](reference $publicIPName).dnsSettings.fqdn
Output 'deploymentTime' [string]$deploymentTime
Output 'vnet' [object](reference $vnet)
Output 'nsgrules' [array]$nsgrulesusing your hashtable like method I'd see that being like this but for more complex output building I can see benefit in having dedicated object types that you can build like below #Output as object with 2 properties
$ARMOutput1 = [ARMOutput]::new('Out1', @{
hostname = [string](reference $publicIPName).dnsSettings.fqdn
deploymentTime = [string]$deploymentTime
}, [object])
#Output as String full type provided
$ARMOutput2 = [ARMOutput]::new('Hostname', [string](reference $publicIPName).dnsSettings.fqdn, [string])
#Output as String inferred from the value type
$ARMOutput3 = [ARMOutput]::new('deploymentTime', [string]$deploymentTime)
#Output as Array from the provided type
$ARMOutput4 = [ARMOutput]::new('nsgrules', [array]$nsgrules, [array])
#Output as Array inferred from the value's type
$ARMOutput5 = [ARMOutput]::new('nsgrules', [array]$nsgrules)
#Output as Array inferred from the value type
$ARMOutput6 = [ARMOutput]::new('deploymentTime', [string]$deploymentTime)
# Output of complex json object with sub objects, arrays and providing
$ARMOutput7 = [ARMOutput]::new('Out2', @{
vnet = [object](reference $vnet)
rg = [string]$rg.resourceID
nsgrules = [array]$nsgules
object = [Object] $object
}, [object])
which you could then build either like this $outs = [ARMOutputArray]@($ARMOutput1, $ARMOutput2, $ARMOutput3, $ARMOutput4,$ARMOutput3, $ARMOutput4, $ARMOutput5, $ARMOutput6, $ARMOutput7)
Output $outsor like this Output @($ARMOutput1, $ARMOutput2, $ARMOutput3, $ARMOutput4,$ARMOutput3, $ARMOutput4, $ARMOutput5, $ARMOutput6, $ARMOutput7)And before anyone says |
Beta Was this translation helpful? Give feedback.
-
I like the parsimony of the keyword here. My only reservation is the way the colon in the key is a magical string format; there's no real reification of the output type in the object itself. The only way to do that though is to make each entry a self-describing object (how all of PSArm works -- self-describing objects): Outputs @{
hostname = Output string (reference ...)
}But at that point you may as well be back to: Output hostname -Type string (reference ...) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
ATM, we define the output values as:
My suggestion is to use a syntax similar to the hash table, (e.g. $PSDefaultParameterValues):
Beta Was this translation helpful? Give feedback.
All reactions