Skip to content

Commit 46f84ae

Browse files
[Fixes] Fixed template spec name gen & added documentation (#2605)
* Fixed template spec name gen & added documentation * Update utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 Co-authored-by: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> * Update utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 Co-authored-by: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com> Co-authored-by: Ahmad Abdalla <28486158+ahmadabdalla@users.noreply.github.com>
1 parent 8e03278 commit 46f84ae

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ function Get-TemplateSpecsName {
2929
# This is requried as certain modules generate names such as `MS.RecoveryServices.vaults.replicationFabrics.replicationProtectionContainers.replicationProtectionContainerMappings` which are longer than the allowed 90 characters for template specs
3030
# Using the logic below, the name is shortened to `MS.RecoveryServices.vaults.replicationFabrics.replicationProtectionContainers.Mappings` which has 'only' 86 characters
3131
$nameElems = $templateSpecIdentifier -split '\.'
32-
for ($index = 0; $index -lt $nameElems.Count; $index++) {
32+
# Starting at index 2 to skip the resource provider
33+
for ($index = 2; $index -lt $nameElems.Count; $index++) {
3334
if ($index -lt ($nameElems.count - 1)) {
3435
$stringToRemove = $nameElems[($index)]
3536
$stringToCheck = $nameElems[($index + 1)]
3637

38+
# If a name is replicated in a path, it is usually plural in the parent, and singular in the child path.
39+
# For example: /virtualNetworks/ (plural) & /virtualNetworks/virtualNetworkPeerings/ (singular)
40+
# In this case we want to remove the singular version from the subsequent string & format it accordingly
3741
if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) {
3842
$singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1)
3943
$rest = $stringToCheck.length - $singularString.Length

0 commit comments

Comments
 (0)