Skip to content

Commit

Permalink
fix: Avm finops hub - Update readme for static tests (#2018)
Browse files Browse the repository at this point in the history
## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes #123
Fixes #456
Closes #123
Closes #456
-->

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.ptn.finops-toolkit.finops-hub](https://github.com/sebassem/bicep-registry-modules/actions/workflows/avm.ptn.finops-toolkit.finops-hub.yml/badge.svg?branch=avm-finops-hub)](https://github.com/sebassem/bicep-registry-modules/actions/workflows/avm.ptn.finops-toolkit.finops-hub.yml)
|

## Type of Change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utlities (Non-module effecting
changes)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [ ] I'm sure there are no other open Pull Requests for the same
update/change
- [ ] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [ ] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to day with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
sebassem authored May 23, 2024
1 parent fe5727c commit d3a3126
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion avm/ptn/finops-toolkit/finops-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This module deploys a Finops hub from the Finops toolkit.
| `Microsoft.ManagedIdentity/userAssignedIdentities` | [2023-01-31](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ManagedIdentity/2023-01-31/userAssignedIdentities) |
| `Microsoft.Network/privateEndpoints` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/privateEndpoints) |
| `Microsoft.Network/privateEndpoints/privateDnsZoneGroups` | [2023-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Network/2023-04-01/privateEndpoints/privateDnsZoneGroups) |
| `Microsoft.Resources/deploymentScripts` | [2023-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Resources/deploymentScripts) |
| `Microsoft.Resources/deploymentScripts` | [2023-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Resources/2023-08-01/deploymentScripts) |
| `Microsoft.Storage/storageAccounts` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts) |
| `Microsoft.Storage/storageAccounts/blobServices` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts/blobServices) |
| `Microsoft.Storage/storageAccounts/blobServices/containers` | [2022-09-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Storage/2022-09-01/storageAccounts/blobServices/containers) |
Expand Down
18 changes: 9 additions & 9 deletions avm/ptn/finops-toolkit/finops-hub/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "13888331902588628493"
"version": "0.27.1.19265",
"templateHash": "8363675209548092624"
},
"name": "Finops-hub",
"description": "This module deploys a Finops hub from the Finops toolkit.",
Expand Down Expand Up @@ -210,8 +210,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "4383879433834970993"
"version": "0.27.1.19265",
"templateHash": "4122497544653764025"
}
},
"parameters": {
Expand Down Expand Up @@ -291,7 +291,7 @@
}
},
"variables": {
"$fxv#0": "Write-Output 'Updating settings.json file...'\nWrite-Output \" Storage account: $env:storageAccountName\"\nWrite-Output \" Container: $env:containerName\"\n\n$validateScopes = { $_.Length -gt 45 }\n\n# Initialize variables\n$fileName = 'settings.json'\n$filePath = Join-Path -Path . -ChildPath $fileName\n$newScopes = $env:exportScopes.Split('|') | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\n\n# Get storage context\n$storageContext = @{\n Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount\n Container = $env:containerName\n}\n\n# Download existing settings, if they exist\n$blob = Get-AzStorageBlobContent @storageContext -Blob $fileName -Destination $filePath -Force\nif ($blob) {\n Write-Output 'Existing settings.json file found. Updating...'\n $text = Get-Content $filePath -Raw\n Write-Output '---------'\n Write-Output $text\n Write-Output '---------'\n $json = $text | ConvertFrom-Json\n\n # Rename exportScopes to scopes + convert to object array\n if ($json.exportScopes) {\n Write-Output ' Updating exportScopes...'\n if ($json.exportScopes[0] -is [string]) {\n Write-Output ' Converting string array to object array...'\n $json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\n if (-not ($json.exportScopes -is [array])) {\n Write-Output ' Converting single object to object array...'\n $json.exportScopes = @($json.exportScopes)\n }\n }\n\n Write-Output \" Renaming to 'scopes'...\"\n $json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes\n $json.PSObject.Properties.Remove('exportScopes')\n }\n}\n\n# Set default if not found\nif (!$json) {\n Write-Output 'No existing settings.json file found. Creating new file...'\n $json = [ordered]@{\n '$schema' = 'https://aka.ms/finops/hubs/settings-schema'\n type = 'HubInstance'\n version = ''\n learnMore = 'https://aka.ms/finops/hubs'\n scopes = @()\n }\n}\n\n# Updating settings\nWrite-Output \"Updating version to $env:ftkVersion...\"\n$json.version = $env:ftkVersion\nif ($newScopes) {\n Write-Output \"Merging $($newScopes.Count) scopes...\"\n $json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual\n\n # Remove the SideIndicator property from the Compare-Object output\n $json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json\n\n if (-not ($json.scopes -is [array])) {\n $json.scopes = @($json.scopes)\n }\n Write-Output \"$($json.scopes.Count) scopes found.\"\n}\n$text = $json | ConvertTo-Json\nWrite-Output '---------'\nWrite-Output $text\nWrite-Output '---------'\n$text | Out-File $filePath\n\n# Upload new/updated settings\nWrite-Output 'Uploading settings.json file...'\nSet-AzStorageBlobContent @storageContext -File $filePath -Force\n"
"$fxv#0": "Write-Output 'Updating settings.json file...'\nWrite-Output \"Storage account: $env:storageAccountName\"\nWrite-Output \"Container: $env:containerName\"\n\n$validateScopes = { $_.Length -gt 45 }\n\n# Initialize variables\n$fileName = 'settings.json'\n$filePath = Join-Path -Path . -ChildPath $fileName\n$newScopes = $env:exportScopes.Split('|') | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\n\n# Get storage context\n$storageContext = @{\n Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount\n Container = $env:containerName\n}\n\n# Download existing settings, if they exist\n$blob = Get-AzStorageBlobContent @storageContext -Blob $fileName -Destination $filePath -Force\nif ($blob) {\n Write-Output 'Existing settings.json file found. Updating...'\n $text = Get-Content $filePath -Raw\n Write-Output '---------'\n Write-Output $text\n Write-Output '---------'\n $json = $text | ConvertFrom-Json\n\n # Rename exportScopes to scopes + convert to object array\n if ($json.exportScopes) {\n Write-Output ' Updating exportScopes...'\n if ($json.exportScopes[0] -is [string]) {\n Write-Output ' Converting string array to object array...'\n $json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }\n if (-not ($json.exportScopes -is [array])) {\n Write-Output ' Converting single object to object array...'\n $json.exportScopes = @($json.exportScopes)\n }\n }\n\n Write-Output \" Renaming to 'scopes'...\"\n $json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes\n $json.PSObject.Properties.Remove('exportScopes')\n }\n}\n\n# Set default if not found\nif (!$json) {\n Write-Output 'No existing settings.json file found. Creating new file...'\n $json = [ordered]@{\n '$schema' = 'https://aka.ms/finops/hubs/settings-schema'\n type = 'HubInstance'\n version = ''\n learnMore = 'https://aka.ms/finops/hubs'\n scopes = @()\n }\n}\n\n# Updating settings\nWrite-Output \"Updating version to $env:ftkVersion...\"\n$json.version = $env:ftkVersion\nif ($newScopes) {\n Write-Output \"Merging $($newScopes.Count) scopes...\"\n $json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual\n\n # Remove the SideIndicator property from the Compare-Object output\n $json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json\n\n if (-not ($json.scopes -is [array])) {\n $json.scopes = @($json.scopes)\n }\n Write-Output \"$($json.scopes.Count) scopes found.\"\n}\n$text = $json | ConvertTo-Json\nWrite-Output '---------'\nWrite-Output $text\nWrite-Output '---------'\n$text | Out-File $filePath\n\n# Upload new/updated settings\nWrite-Output 'Uploading settings.json file...'\nSet-AzStorageBlobContent @storageContext -File $filePath -Force\n"
},
"resources": {
"identity": {
Expand Down Expand Up @@ -5614,8 +5614,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "13617090394106970682"
"version": "0.27.1.19265",
"templateHash": "3536466427550878903"
}
},
"parameters": {
Expand Down Expand Up @@ -8386,8 +8386,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.26.170.59819",
"templateHash": "18290965054356591240"
"version": "0.27.1.19265",
"templateHash": "805240367391579055"
}
},
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Write-Output 'Updating settings.json file...'
Write-Output " Storage account: $env:storageAccountName"
Write-Output " Container: $env:containerName"
Write-Output "Storage account: $env:storageAccountName"
Write-Output "Container: $env:containerName"

$validateScopes = { $_.Length -gt 45 }

Expand Down

0 comments on commit d3a3126

Please sign in to comment.