File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ function Decompile-GithubArmTemplate {
2
+ [CmdletBinding ()]
3
+ param (
4
+ [Parameter ()]
5
+ [string ]
6
+ $GithubPath ,
7
+
8
+ [Parameter ()]
9
+ [string ]
10
+ $Path ,
11
+
12
+ [Parameter ()]
13
+ [string ]
14
+ $FileName
15
+ )
16
+
17
+ if ($GithubPath.StartsWith (' https://raw.githubusercontent.com' )){
18
+ Write-Verbose " Well it looks like raw content URL"
19
+ } elseif ($GithubPath.StartsWith (' https://github.com' )) {
20
+ Write-Verbose " Well it looks like a base Github URL"
21
+ $GithubPath = $GithubPath -replace ' github' , ' raw.githubusercontent' -replace ' /blob' , ' '
22
+ $Name = $GithubPath.Split (' /' )[-2 ]
23
+
24
+ }else {
25
+ Write-Warning " Use the right path and start with https://"
26
+ Return
27
+ }
28
+
29
+ $DownloadFile = " $env: TEMP \{0}.{1}" -f $Name , ' json'
30
+
31
+ ($Path ) ? ($outputPath = $Path ) : ($outputPath = $Pwd.Path )
32
+ ($FileName ) ? ($FileName ) : ($FileName = " $Name .{0}" -f ' bicep' )
33
+
34
+ $wc = New-Object System.Net.WebClient
35
+ $wc.DownloadFile ($GithubPath , $DownloadFile )
36
+
37
+ bicep decompile $DownloadFile -- outfile " $outputPath \$FileName "
38
+
39
+ Write-Output " Decompiled $GithubPath to $outputPath \$FileName "
40
+ }
You can’t perform that action at this time.
0 commit comments