forked from Azure/bicep-registry-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
315 additions
and
223 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
avm/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<# | ||
.SYNOPSIS | ||
Get a list of all resources (provider + service) in the given template content | ||
.DESCRIPTION | ||
Get a list of all resources (provider + service) in the given template content. Crawls through any children & nested deployment templates. | ||
.PARAMETER TemplateFileContent | ||
Mandatory. The template file content object to crawl data from | ||
.EXAMPLE | ||
Get-NestedResourceList -TemplateFileContent @{ resource = @{}; ... } | ||
Returns a list of all resources in the given template object | ||
#> | ||
function Get-NestedResourceList { | ||
|
||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory)] | ||
[Alias('Path')] | ||
[hashtable] $TemplateFileContent | ||
) | ||
|
||
$res = @() | ||
$currLevelResources = @() | ||
if ($TemplateFileContent.resources) { | ||
$currLevelResources += $TemplateFileContent.resources | ||
} | ||
foreach ($resource in $currLevelResources) { | ||
$res += $resource | ||
|
||
if ($resource.type -eq 'Microsoft.Resources/deployments') { | ||
$res += Get-NestedResourceList -TemplateFileContent $resource.properties.template | ||
} else { | ||
$res += Get-NestedResourceList -TemplateFileContent $resource | ||
} | ||
} | ||
return $res | ||
} |
38 changes: 38 additions & 0 deletions
38
avm/utilities/pipelines/sharedScripts/Get-PipelineFileName.ps1
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<# | ||
.SYNOPSIS | ||
Find the correct yml pipeline naming for a given resource identifier. | ||
.DESCRIPTION | ||
Find the correct yml pipeline naming for a given resource identifier. | ||
If a child resource type is provided, the corresponding yml pipeline name is the one of its parent resource type | ||
.PARAMETER ResourceIdentifier | ||
Mandatory. The resource identifier to search for, i.e. the relative module file path starting from the resource provider folder. | ||
.EXAMPLE | ||
Get-PipelineFileName -ResourceIdentifier 'storage/storage-account/blob-service/container/immutability-policy'. | ||
Returns 'ms.storage.storageaccounts.yml'. | ||
.EXAMPLE | ||
Get-PipelineFileName -ResourceIdentifier 'storage/storage-account'. | ||
Returns 'ms.storage.storageaccounts.yml'. | ||
#> | ||
function Get-PipelineFileName { | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $ResourceIdentifier | ||
) | ||
|
||
. (Join-Path $PSScriptRoot 'Get-SpecsAlignedResourceName.ps1') | ||
|
||
$provider, $parentType, $childTypeString = $ResourceIdentifier -split '[\/|\\]', 3 | ||
$parentResourceIdentifier = $provider, $parentType -join '/' | ||
$formattedParentResourceType = Get-SpecsAlignedResourceName -ResourceIdentifier $parentResourceIdentifier | ||
$pipelineFileName = '{0}.yml' -f (($formattedParentResourceType -replace 'Microsoft\.', 'ms.') -replace '\/', '.').ToLower() | ||
|
||
return $pipelineFileName | ||
} |
Oops, something went wrong.