Skip to content
This repository was archived by the owner on Aug 17, 2021. It is now read-only.

Fix ability for ConvertFrom-ArmTemplate to accept relative path (or wildcards) #158

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Commands/ConvertFromArmTemplateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using PSArm.Serialization;
using PSArm.Templates;
using System;
using System.Collections.ObjectModel;
using System.Management.Automation;

namespace PSArm.Commands
Expand Down Expand Up @@ -49,9 +50,13 @@ protected override void ProcessRecord()
return;

case "Path":
ProviderInfo provider = null;
foreach (string path in Path)
{
WriteObject(_parser.ParseFile(path));
foreach (string resolvedPath in SessionState.Path.GetResolvedProviderPathFromPSPath(path, out provider))
{
WriteObject(_parser.ParseFile(resolvedPath));
}
}
return;

Expand Down
10 changes: 10 additions & 0 deletions test/pester/Conversion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ Describe "ARM conversion cmdlets" {

Assert-StructurallyEqual -ComparisonObject $original -JsonObject $created
}

It 'Can accept relative path' {
try {
Push-Location "$PSScriptRoot/assets"
ConvertFrom-ArmTemplate -Path ./roundtrip-template.json | Should -Not -BeNullOrEmpty
}
finally {
Pop-Location
}
}
}