{{ $useHeaderRow := .Get "header" }} {{ $csv := .Get "csv" }} {{ $file := readFile $csv }} {{ $rows := $file | transform.Unmarshal (dict "delimiter" ",") }} {{ $rows = after 1 $rows }} {{ $useLinks := .Get "useLinks" | default true }} {{ $language := .Get "language" }} {{ $moduleType := .Get "moduleType" }} {{ $exclude := .Get "exclude" }} {{ $monthsToShow := .Get "monthsToShow" }} {{ $ProviderNamespaceColumnId := 0 }} {{ $ResourceTypeColumnId := 0 }} {{ $ModuleDisplayNameColumnId := 0 }} {{ $AlternativeNamesColumnId := 0 }} {{ $ModuleNameColumnId := 0 }} {{ $ParentModuleColumnId := 0 }} {{ $ModuleStatusColumnId := 0 }} {{ $RepoURLColumnId := 0 }} {{ $PublicRegistryReferenceColumnId := 0 }} {{ $TelemetryIdPrefixColumnId := 0 }} {{ $PrimaryModuleOwnerGHHandleColumnId := 0 }} {{ $PrimaryModuleOwnerDisplayNameColumnId := 0 }} {{ $SecondaryModuleOwnerGHHandleColumnId := 0 }} {{ $SecondaryModuleOwnerDisplayNameColumnId := 0 }} {{ $ModuleOwnersGHTeamColumnId := 0 }} {{ $DescriptionColumnId := 0 }} {{ $CommentsColumnId := 0 }} {{ $FirstPublishedInColumnId := 0 }} {{ $hasModulesAvailable := false }} {{ $modules := slice }} {{ $publicationDates := slice }} {{ $i := 1 }} {{ $moduleLatestVersion := "N/A" }} {{ if eq $moduleType "resource" }} {{ $ProviderNamespaceColumnId = 0 }} {{ $ResourceTypeColumnId = 1 }} {{ $ModuleDisplayNameColumnId = 2 }} {{ $AlternativeNamesColumnId = 3 }} {{ $ModuleNameColumnId = 4 }} {{ $ParentModuleColumnId = 5 }} {{ $ModuleStatusColumnId = 6 }} {{ $RepoURLColumnId = 7 }} {{ $PublicRegistryReferenceColumnId = 8 }} {{ if eq $language "Bicep" }} {{ $TelemetryIdPrefixColumnId = 9 }} {{ $PrimaryModuleOwnerGHHandleColumnId = 10 }} {{ $PrimaryModuleOwnerDisplayNameColumnId = 11 }} {{ $SecondaryModuleOwnerGHHandleColumnId = 12 }} {{ $SecondaryModuleOwnerDisplayNameColumnId = 13 }} {{ $ModuleOwnersGHTeamColumnId = 14 }} {{ $DescriptionColumnId = 15 }} {{ $CommentsColumnId = 16 }} {{ $FirstPublishedInColumnId = 17 }} {{ else }} {{ $PrimaryModuleOwnerGHHandleColumnId = 9 }} {{ $PrimaryModuleOwnerDisplayNameColumnId = 10 }} {{ $SecondaryModuleOwnerGHHandleColumnId = 11 }} {{ $SecondaryModuleOwnerDisplayNameColumnId = 12 }} {{ $DescriptionColumnId = 13 }} {{ $CommentsColumnId = 14 }} {{ $FirstPublishedInColumnId = 15 }} {{ end }} {{ range $row, $rows }} {{ $module := dict "ProviderNamespace" (index $row $ProviderNamespaceColumnId) "ResourceType" (index $row $ResourceTypeColumnId) "ModuleDisplayName" (index $row $ModuleDisplayNameColumnId) "AlternativeNames" (index $row $AlternativeNamesColumnId) "ModuleName" (index $row $ModuleNameColumnId) "ParentModule" (index $row $ParentModuleColumnId) "ModuleStatus" (index $row $ModuleStatusColumnId) "RepoURL" (index $row $RepoURLColumnId) "PublicRegistryReference" (index $row $PublicRegistryReferenceColumnId) "PrimaryModuleOwnerGHHandle" (index $row $PrimaryModuleOwnerGHHandleColumnId) "PrimaryModuleOwnerDisplayName" (index $row $PrimaryModuleOwnerDisplayNameColumnId) "SecondaryModuleOwnerGHHandle" (index $row $SecondaryModuleOwnerGHHandleColumnId) "SecondaryModuleOwnerDisplayName" (index $row $SecondaryModuleOwnerDisplayNameColumnId) "Description" (index $row $DescriptionColumnId) "Comments" (index $row $CommentsColumnId) "FirstPublishedInColumnId" (index $row $FirstPublishedInColumnId) }} {{ $modules = $modules | append $module }} {{ if and (ne $module.FirstPublishedInColumnId "") (not ( in $publicationDates $module.FirstPublishedInColumnId )) }} {{ $publicationDates = $publicationDates | append $module.FirstPublishedInColumnId }} {{ end }} {{ end }} {{ else if or (eq $moduleType "pattern") (eq $moduleType "utility") }} {{ $ModuleDisplayNameColumnId = 0 }} {{ $AlternativeNamesColumnId = 1 }} {{ $ModuleNameColumnId = 2 }} {{ $ModuleStatusColumnId = 3 }} {{ $RepoURLColumnId = 4 }} {{ $PublicRegistryReferenceColumnId = 5 }} {{ if eq $language "Bicep" }} {{ $TelemetryIdPrefixColumnId = 6 }} {{ $PrimaryModuleOwnerGHHandleColumnId = 7 }} {{ $PrimaryModuleOwnerDisplayNameColumnId = 8 }} {{ $SecondaryModuleOwnerGHHandleColumnId = 9 }} {{ $SecondaryModuleOwnerDisplayNameColumnId = 10 }} {{ $ModuleOwnersGHTeamColumnId = 11 }} {{ $DescriptionColumnId = 12 }} {{ $CommentsColumnId = 13 }} {{ $FirstPublishedInColumnId = 14 }} {{ else }} {{ $PrimaryModuleOwnerGHHandleColumnId = 6 }} {{ $PrimaryModuleOwnerDisplayNameColumnId = 7 }} {{ $SecondaryModuleOwnerGHHandleColumnId = 8 }} {{ $SecondaryModuleOwnerDisplayNameColumnId = 9 }} {{ $DescriptionColumnId = 10 }} {{ $CommentsColumnId = 11 }} {{ $FirstPublishedInColumnId = 12 }} {{ end }} {{ range $row, $rows }} {{ $module := dict "ModuleDisplayName" (index $row $ModuleDisplayNameColumnId) "AlternativeNames" (index $row $AlternativeNamesColumnId) "ModuleName" (index $row $ModuleNameColumnId) "ModuleStatus" (index $row $ModuleStatusColumnId) "RepoURL" (index $row $RepoURLColumnId) "PublicRegistryReference" (index $row $PublicRegistryReferenceColumnId) "PrimaryModuleOwnerGHHandle" (index $row $PrimaryModuleOwnerGHHandleColumnId) "PrimaryModuleOwnerDisplayName" (index $row $PrimaryModuleOwnerDisplayNameColumnId) "SecondaryModuleOwnerGHHandle" (index $row $SecondaryModuleOwnerGHHandleColumnId) "SecondaryModuleOwnerDisplayName" (index $row $SecondaryModuleOwnerDisplayNameColumnId) "Description" (index $row $DescriptionColumnId) "Comments" (index $row $CommentsColumnId) "FirstPublishedInColumnId" (index $row $FirstPublishedInColumnId) }} {{ $modules = $modules | append $module }} {{ if and (ne $module.FirstPublishedInColumnId "") (not ( in $publicationDates $module.FirstPublishedInColumnId )) }} {{ $publicationDates = $publicationDates | append $module.FirstPublishedInColumnId }} {{ end }} {{ end }} {{ else }} {{ errorf "The %q shortcode requires a moduleType parameter to bet set to either 'resource', 'pattern' or 'utility'. See %s" .Name .Position }} {{ end }} {{ $publicationDates = sort $publicationDates "value" "desc" }} {{ $publicationDates := first $monthsToShow $publicationDates }} {{ $modules = sort $modules "ModuleName" }} {{ if eq $language "Bicep" }} {{ range $publicationDate, $publicationDates }} {{ $i = 1 }} {{ $date := time (printf "%s-01" $publicationDate) }} {{ $formattedDate := $date.Format "January 2006" }} {{ printf "### Modules published in %s" $formattedDate | markdownify }} {{/* {{ printf "**Modules published in %s**" $formattedDate | markdownify }} */}} {{ if $useHeaderRow }} {{ end }} {{ range $item, $modules }} {{ if and (eq $item.FirstPublishedInColumnId $publicationDate) (not ( in $exclude $item.ModuleStatus )) (ne $item.PublicRegistryReference "n/a") }} {{ $moduleLatestVersion = "N/A" }} {{ if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") }} {{ $moduleMcrUrl := printf "https://mcr.microsoft.com/v2/bicep/%s/tags/list" $item.ModuleName }} {{ $moduleMcrData := dict }} {{ with resources.GetRemote $moduleMcrUrl }} {{ with .Err }} {{ errorf "%s" . }} {{ else }} {{ $moduleMcrData = . | transform.Unmarshal }} {{ end }} {{ else }} {{ errorf "Unable to get remote resource %q" $moduleMcrUrl }} {{ end }} {{ $moduleVersions := $moduleMcrData.tags }} {{ if $moduleVersions }} {{ $moduleLatestVersion = index $moduleVersions (sub (len $moduleVersions) 1) }} {{ end }} {{ end }} {{ $trimmedModuleStatus := replace $item.ModuleStatus "Module " "" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Deprecated" "Deprecated :red_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Available" "Available :green_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Orphaned" "Orphaned :yellow_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Proposed" "Proposed :white_circle:" }} {{ $trimmedAlternativeNames := replace $item.AlternativeNames " " " " }} {{ $trimmedAlternativeNames = replace $trimmedAlternativeNames ", " "," }} {{ $trimmedAlternativeNames = replace $trimmedAlternativeNames "," ", " }} {{ end }} {{ end }}
No. Module Name Display Name Status & Versions Owner(s)
{{/* row index */}} {{- printf "%02d" $i -}} {{- $i = add $i 1 -}} {{/* module name and link to the repo */}} {{- if $useLinks -}} {{- if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") -}} {{ $item.ModuleName }} {{- else -}} {{ $item.ModuleName }} {{- end -}} {{- else -}} {{ $item.ModuleName }} {{- end -}} {{/* display name and alternative names */}} {{- $ModuleDisplayName := $item.ModuleDisplayName -}} {{- if and (ne $ParentModuleColumnId 0) (ne $item.ParentModule "n/a") -}} {{ $ModuleDisplayName = print $ModuleDisplayName " (Child of " $item.ParentModule ")" }} {{- end -}} {{- with $trimmedAlternativeNames -}} {{ $ModuleDisplayName }}
{{ $trimmedAlternativeNames }} {{- else -}} {{ $ModuleDisplayName }} {{- end -}}
{{/* availability badge and versions */}} {{- if and (or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned")) (ne $item.PublicRegistryReference "n/a") -}} {{- else -}} {{- end -}} {{/* module owners */}} {{- if ne $item.PrimaryModuleOwnerGHHandle "" -}} {{ $item.PrimaryModuleOwnerGHHandle }} {{- if and (ne $item.PrimaryModuleOwnerGHHandle "") (ne $item.PrimaryModuleOwnerDisplayName "") -}}
{{ $item.PrimaryModuleOwnerDisplayName }} {{- end -}} {{- end -}}
{{- if ne $item.SecondaryModuleOwnerGHHandle "" -}} {{ $item.SecondaryModuleOwnerGHHandle }} {{- if and (ne $item.SecondaryModuleOwnerGHHandle "") (ne $item.SecondaryModuleOwnerDisplayName "") -}}
{{ $item.SecondaryModuleOwnerDisplayName }} {{- end -}} {{- end -}} {{- if and (ne $ParentModuleColumnId 0) (ne $item.ParentModule "n/a") -}} {{- $parentModule := index (where $modules "ModuleName" $item.ParentModule) 0 -}} {{- if $parentModule -}} (Inherited): {{- if ne $parentModule.PrimaryModuleOwnerGHHandle "" -}} {{ $parentModule.PrimaryModuleOwnerGHHandle }} {{- if and (ne $parentModule.PrimaryModuleOwnerGHHandle "") (ne $parentModule.PrimaryModuleOwnerDisplayName "") -}}
{{ $parentModule.PrimaryModuleOwnerDisplayName }} {{- end -}}
{{- if ne $parentModule.SecondaryModuleOwnerGHHandle "" -}} {{ $parentModule.SecondaryModuleOwnerGHHandle }} {{- if and (ne $parentModule.SecondaryModuleOwnerGHHandle "") (ne $parentModule.SecondaryModuleOwnerDisplayName "") -}}
{{ $parentModule.SecondaryModuleOwnerDisplayName }} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}}

{{ $hasModulesAvailable = true }} {{ end }} {{- else if eq $language "Terraform" -}} {{- range $publicationDate, $publicationDates -}} {{ $i = 1 }} {{ $date := time (printf "%s-01" $publicationDate) }} {{ $formattedDate := $date.Format "January 2006" }} {{ printf "### Modules published in %s" $formattedDate | markdownify }} {{/* {{ printf "**Modules published in %s**" $formattedDate | markdownify }} */}} {{- if $useHeaderRow -}} {{- end -}} {{- range $item, $modules -}} {{- if and (eq $item.FirstPublishedInColumnId $publicationDate) (not ( in $exclude $item.ModuleStatus )) -}} {{ $moduleLatestVersion = "N/A" }} {{- if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") -}} {{ $repoURLSplit := strings.Split $item.RepoURL "/" }} {{ $repoName := index $repoURLSplit (sub (len $repoURLSplit) 1) }} {{ $repoNameSplit := strings.Split $repoName "-" }} {{ $moduleProvider := index $repoNameSplit 1 }} {{ $moduleTfRegApiUrl := printf "https://registry.terraform.io/v1/modules/Azure/%s/%s/versions" $item.ModuleName $moduleProvider }} {{ $moduleTfRegApiData := dict }} {{- with resources.GetRemote $moduleTfRegApiUrl -}} {{- with .Err -}} {{ errorf "%s" . }} {{- else -}} {{ $moduleTfRegApiData = . | transform.Unmarshal }} {{- end -}} {{- else -}} {{ errorf "Unable to get remote resource %q" $moduleTfRegApiUrl }} {{- end -}} {{ $moduleVersions := slice }} {{- range $moduleTfRegApiData.modules -}} {{- range .versions -}} {{ $moduleVersions = $moduleVersions | append .version }} {{- end -}} {{- end -}} {{- if $moduleVersions -}} {{ $moduleLatestVersion = index $moduleVersions (sub (len $moduleVersions) 1) }} {{- end -}} {{- end -}} {{ $trimmedModuleStatus := replace $item.ModuleStatus "Module " "" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Deprecated" "Deprecated :red_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Available" "Available :green_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Orphaned" "Orphaned :yellow_circle:" }} {{ $trimmedModuleStatus = replace $trimmedModuleStatus "Proposed" "Proposed :white_circle:" }} {{ $trimmedAlternativeNames := replace $item.AlternativeNames " " " " }} {{ $trimmedAlternativeNames = replace $trimmedAlternativeNames ", " "," }} {{ $trimmedAlternativeNames = replace $trimmedAlternativeNames "," ", " }} {{- end -}} {{- end -}}
No. Module Name Source
Code
Display Name Status & Versions Owner(s)
{{/* row index */}} {{- printf "%02d" $i -}} {{- $i = add $i 1 -}} {{/* module name and link to the registry */}} {{- if $useLinks -}} {{- if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") -}} {{ $item.ModuleName }} {{- else -}} {{ $item.ModuleName }} {{- end -}} {{- else -}} {{ $item.ModuleName }} {{- end -}} {{/* link to the repo */}} {{- if $useLinks -}} {{- if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") -}} 📄 {{- else -}} {{ "n/a" }} {{- end -}} {{- else -}} {{ "n/a" }} {{- end -}} {{/* display name and alternative names */}} {{- $ModuleDisplayName := $item.ModuleDisplayName -}} {{- if and (ne $ParentModuleColumnId 0) (ne $item.ParentModule "n/a") -}} {{ $ModuleDisplayName = print $ModuleDisplayName " (Child of " $item.ParentModule ")" }} {{- end -}} {{- with $trimmedAlternativeNames -}} {{ $ModuleDisplayName }}
{{ $trimmedAlternativeNames }} {{- else -}} {{ $ModuleDisplayName }} {{- end -}}
{{/* availability badge and versions */}} {{- if or (eq $item.ModuleStatus "Available") (eq $item.ModuleStatus "Orphaned") -}} {{- else -}} {{- end -}} {{/* module owners */}} {{- if ne $item.PrimaryModuleOwnerGHHandle "" -}} {{ $item.PrimaryModuleOwnerGHHandle }} {{- if and (ne $item.PrimaryModuleOwnerGHHandle "") (ne $item.PrimaryModuleOwnerDisplayName "") -}}
{{ $item.PrimaryModuleOwnerDisplayName }} {{- end -}} {{- end -}}
{{- if ne $item.SecondaryModuleOwnerGHHandle "" -}} {{ $item.SecondaryModuleOwnerGHHandle }} {{- if and (ne $item.SecondaryModuleOwnerGHHandle "") (ne $item.SecondaryModuleOwnerDisplayName "") -}}
{{ $item.SecondaryModuleOwnerDisplayName }} {{- end -}} {{- end -}}

{{ $hasModulesAvailable = true }} {{ end }} {{ else }} {{ errorf "The %q shortcode requires a language parameter to be set either 'Bicep' or 'Terraform'. See %s" .Name .Position }} {{ end }} {{ if not $hasModulesAvailable }} ❌ No modules are available yet. {{ end }}