-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Write bicep into modules based on scope hierarchy rather than user constructs #42029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoshLove-msft
merged 35 commits into
Azure:feature/cdk
from
JoshLove-msft:module-reorganization
Feb 20, 2024
Merged
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
635c7ec
Write bicep into modules based on scope hierarchy rather than user co…
JoshLove-msft 54ad6d3
Clean up
JoshLove-msft b6a49f0
Merge branch 'feature/cdk' of https://github.com/Azure/azure-sdk-for-…
JoshLove-msft 410f372
remove dead code
JoshLove-msft 5c41e5a
Add override logic for ManagedService
JoshLove-msft c9add63
PR fb
JoshLove-msft fdd2d5e
deleted files
JoshLove-msft ee33dee
API
JoshLove-msft f5a7d2b
Fix getResources
JoshLove-msft 16e0e5d
tests
JoshLove-msft 78251ad
Fix outputs
JoshLove-msft 778d52c
remove commented code
JoshLove-msft bd35f78
remove blank refdocs
JoshLove-msft 725e73a
using
JoshLove-msft b934c99
Pass recursive as true
JoshLove-msft 0bee48f
revert recursive change
JoshLove-msft 8ec68ad
PR fb
JoshLove-msft 613d506
pass true as recursive arg
JoshLove-msft 925b313
Fix recursive call and don't mutate Parameter
JoshLove-msft ceceb89
API
JoshLove-msft beb046b
fix comments
JoshLove-msft 9b82c38
readonly
JoshLove-msft 2d4b7b0
add construct tests
JoshLove-msft dc25978
Fix enumeration
JoshLove-msft 1521c9b
Add parameter and outputs tests
JoshLove-msft 975fe8f
save
JoshLove-msft 92dc0f5
update get parameters
m-nash 7d6dc2e
update api
m-nash 80cc65c
merge upstream feature/cdk
m-nash ec6c624
update after merge
m-nash 84a4494
Fix outputs/parameters
JoshLove-msft 499bf89
Merge branch 'module-reorganization' of https://github.com/JoshLove-m…
JoshLove-msft e6e32b7
avoid dupes
JoshLove-msft c7ffffe
fix test
JoshLove-msft 1cd0b5a
api
JoshLove-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
sdk/provisioning/Azure.Provisioning/src/ModuleConstruct.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Provisioning.ResourceManager; | ||
|
|
||
| namespace Azure.Provisioning | ||
| { | ||
| internal class ModuleConstruct : Construct | ||
| { | ||
| public ModuleConstruct(ModuleResource resource) | ||
| : base( | ||
| resource.Scope, | ||
| resource.Resource is Subscription ? resource.Resource.Name : resource.Resource.Id.Name.Replace('-', '_'), | ||
| ResourceToConstructScope(resource.Resource), | ||
| tenant: GetTenant(resource.Resource), | ||
| subscription: GetSubscription(resource.Resource), | ||
| resourceGroup: resource.Resource as ResourceGroup) | ||
| { | ||
| } | ||
|
|
||
| public bool IsRoot { get; set; } | ||
|
|
||
| private static Tenant? GetTenant(Resource resource) | ||
| { | ||
| return resource switch | ||
| { | ||
| Tenant tenant => tenant, | ||
| Subscription sub => (Tenant) sub.Parent!, | ||
| ResourceGroup rg => (Tenant) rg.Parent!.Parent!, | ||
| _ => null, | ||
| }; | ||
| } | ||
|
|
||
| private static Subscription? GetSubscription(Resource resource) | ||
| { | ||
| return resource switch | ||
| { | ||
| Subscription subscription => subscription, | ||
| ResourceGroup rg => (Subscription) rg.Parent!, | ||
| _ => null, | ||
| }; | ||
| } | ||
|
|
||
| private static ConstructScope ResourceToConstructScope(Resource resource) | ||
| { | ||
| return resource switch | ||
| { | ||
| Tenant => ConstructScope.Tenant, | ||
| ResourceManager.Subscription => ConstructScope.Subscription, | ||
| //TODO managementgroup support | ||
| ResourceManager.ResourceGroup => ConstructScope.ResourceGroup, | ||
| _ => throw new InvalidOperationException(), | ||
| }; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.