manifests/collectors/Containers/ContainerApp.psd1
|
# # GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Containers/ContainerApp.ps1 (AB#5660). # Field expressions are copied verbatim from the original collector and evaluate in an # equivalent scope -- see docs/design/decisions/declarative-collectors.md. # Review before trusting; regenerate rather than hand-patch if the source collector changes. # @{ ResourceTypes = @( 'microsoft.app/containerapps' ) ResourceTypeMatching = 'Grouped' AdditionalFilter = $null FilterPreamble = '' RowLoopVariable = '1' Preamble = @' $ResUCount = 1 # An EMPTY $sub1 -- a resource whose subscription is outside the requested scope -- # is not $null, and `.Name` on it throws under StrictMode. $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId } # The else arm is $null, NOT '': with StrictMode off $sub1.Name on an unmatched ($null) # $sub1 evaluated to $null, and the ~110 collectors that still read $sub1.Name directly # emit $null here. '' was a silent behaviour change -- the declarative equivalence proof # caught it on 11 collectors, and it would have been invisible on the rest (AB#5659). $SubscriptionName = if ($sub1) { @($sub1)[0].Name } else { $null } $data = $1.PROPERTIES $Retired = $Retirements | Where-Object { $_.id -eq $1.id } if ($Retired) { $RetiredFeature = foreach ($Retire in $Retired) { $RetiredServiceID = $Unsupported | Where-Object {$_.Id -eq $Retired.ServiceID} $tmp0 = [pscustomobject]@{ 'RetiredFeature' = $RetiredServiceID.RetiringFeature 'RetiredDate' = $RetiredServiceID.RetirementDate } $tmp0 } $RetiringFeature = if (@($RetiredFeature.RetiredFeature).count -gt 1) { $RetiredFeature.RetiredFeature | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredFeature} $RetiringFeature = [string]$RetiringFeature $RetiringFeature = if ($RetiringFeature -like '* ,*') { $RetiringFeature -replace ".$" }else { $RetiringFeature } $RetiringDate = if (@($RetiredFeature.RetiredDate).count -gt 1) { $RetiredFeature.RetiredDate | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredDate} $RetiringDate = [string]$RetiringDate $RetiringDate = if ($RetiringDate -like '* ,*') { $RetiringDate -replace ".$" }else { $RetiringDate } } else { $RetiringFeature = $null $RetiringDate = $null } # AB#5671. `ingress` is ABSENT on an internal-only container app (which is the # whole point of an internal app), `dapr` and `secrets` are absent unless # configured, and every read hanging off `ingress` -- targetPort, external, # allowInsecure, transport -- therefore threw on the first such app. $RowTags = Get-AZSCSafeProperty -InputObject $1 -Path 'tags' $TagProps = if ($null -ne $RowTags) { $RowTags.psobject.properties } else { $null } # The historic '0' sentinel only made this loop run once for an untagged resource; # `'0'.Name` throws under StrictMode, an empty tag object emits the identical row. $Tags = if(![string]::IsNullOrEmpty($TagProps)){$TagProps}else{[pscustomobject]@{ Name = $null; Value = $null }} $IngressConfig = Get-AZSCSafeProperty -InputObject $data -Path 'configuration.ingress' $DaprConfig = Get-AZSCSafeProperty -InputObject $data -Path 'configuration.dapr' $SecretsConfig = Get-AZSCSafeProperty -InputObject $data -Path 'configuration.secrets' $ingress = if(![string]::IsNullOrEmpty($IngressConfig)){$true}else{$false} $dapr = if(![string]::IsNullOrEmpty($DaprConfig)){$true}else{$false} $secrets = if(![string]::IsNullOrEmpty($SecretsConfig)){@($SecretsConfig).count}else{0} $Env = Get-AZSCIdSegment -Id (Get-AZSCSafeProperty -InputObject $data -Path 'environmentId') -Index 8 '@ AdditionalRowLoops = @( @{ Variable = '2' Source = '(Get-AZSCSafeProperty -InputObject $data -Path ''template'')' Preamble = '' } @{ Variable = '3' Source = '(Get-AZSCSafeProperty -InputObject $2 -Path ''containers'')' Preamble = '' } ) TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '$SubscriptionName' } @{ Name = 'Resource Group' Expression = '$1.RESOURCEGROUP' } @{ Name = 'Name' Expression = '$1.NAME' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Retiring Feature' Expression = '$RetiringFeature' } @{ Name = 'Retiring Date' Expression = '$RetiringDate' } @{ Name = 'Running Status' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''runningStatus'')' } @{ Name = 'Container App Environment' Expression = '$Env' } @{ Name = 'Workload Profile' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''workloadProfileName'')' } @{ Name = 'Ingress' Expression = '$ingress' } @{ Name = 'Ingress Port' Expression = '(Get-AZSCSafeProperty -InputObject $IngressConfig -Path ''targetPort'')' } @{ Name = 'External Ingress' Expression = '(Get-AZSCSafeProperty -InputObject $IngressConfig -Path ''external'')' } @{ Name = 'Insecure Connections' Expression = '(Get-AZSCSafeProperty -InputObject $IngressConfig -Path ''allowInsecure'')' } @{ Name = 'Ingress Transport' Expression = '(Get-AZSCSafeProperty -InputObject $IngressConfig -Path ''transport'')' } @{ Name = 'Dapr' Expression = '$dapr' } @{ Name = 'Secrets' Expression = '[string]$secrets' } @{ Name = 'Container' Expression = '(Get-AZSCSafeProperty -InputObject $3 -Path ''name'')' } @{ Name = 'CPU Cores' Expression = '(Get-AZSCSafeProperty -InputObject $3 -Path ''resources.cpu'')' } @{ Name = 'Memory Size (Gi)' Expression = '(Get-AZSCSafeProperty -InputObject $3 -Path ''resources.memory'')' } @{ Name = 'Ephemeral Storage (Gi)' Expression = '(Get-AZSCSafeProperty -InputObject $3 -Path ''resources.ephemeralStorage'')' } @{ Name = 'Container Image' Expression = '(Get-AZSCSafeProperty -InputObject $3 -Path ''image'')' } @{ Name = 'Resource U' Expression = '$ResUCount' } @{ Name = 'Tag Name' Expression = '[string]$Tag.Name' } @{ Name = 'Tag Value' Expression = '[string]$Tag.Value' } ) Export = @{ WorksheetName = 'Container Apps' TableNamePrefix = 'ContsTb_' Columns = @( 'Subscription' 'Resource Group' 'Name' 'Location' 'Retiring Feature' 'Retiring Date' 'Running Status' 'Container App Environment' 'Workload Profile' 'Ingress' 'Ingress Port' 'External Ingress' 'Insecure Connections' 'Ingress Transport' 'Dapr' 'Secrets' 'Container' 'CPU Cores' 'Memory Size (Gi)' 'Ephemeral Storage (Gi)' 'Container Image' 'Resource U' ) TagColumns = @( 'Tag Name' 'Tag Value' ) TagColumnsBefore = 'Resource U' NumberFormat = '0' ConditionalText = @( 'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText' 'New-ConditionalText true -Range L:L -ConditionalType ContainsText' 'New-ConditionalText true -Range M:M -ConditionalType ContainsText' ) } SourceCollector = 'Modules/Public/InventoryModules/Containers/ContainerApp.ps1' } |