-
Notifications
You must be signed in to change notification settings - Fork 757
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
[Local extensibility] Expose new classes #14697
base: main
Are you sure you want to change the base?
Conversation
var localDeployResult = await LocalDeployment.Deploy(extensibilityHandler, templateFile, parametersFile, TestContext.CancellationTokenSource.Token); | ||
var moduleDispatcher = BicepTestConstants.CreateModuleDispatcher(services.Build().Construct<IServiceProvider>()); | ||
|
||
var extensionFactoryManager = new LocalExtensionFactoryManager(localExtensionFactory.Object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the code remained the same, one of the biggest differences is the fact that there is an interface to create extension instances - ILocalExtensionFactory
which is meant for clients to implement it - see LocalDeployCommand.cs
and the other difference if LocalExtensionFactoryManager
this class is in charge of initializing local extensions and load them on-demand and only once.
|
||
namespace Bicep.Local.Deploy.Extensibility | ||
{ | ||
public class GrpcProxyLocalExtension : ILocalExtension, IAsyncDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the existing implementation, difference is that implements ILocalExtension
and also that uses extensibility v2 data types.
@@ -70,3 +74,8 @@ public interface IResourceHandler : IGenericResourceHandler | |||
{ | |||
string ResourceType { get; } | |||
} | |||
|
|||
public interface ILocalExtensionHandler : ILocalExtension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Existing Mock project needs to reference this type.
|
||
namespace Bicep.Local.Extension.Rpc | ||
{ | ||
public class BicepGrpcService : BicepExtension.BicepExtensionBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same implementation as BicepExtensionImpl
difference is the type reference.
public class LocalExtensionFactoryManager(ILocalExtensionFactory extensionFactory) : ILocalExtensionFactoryManager | ||
{ | ||
private readonly Dictionary<LocalExtensionKey, Func<Task<ILocalExtension>>> RegisteredLocalExtensions = []; | ||
private readonly Dictionary<LocalExtensionKey, ILocalExtension> InitializedLocalExtensions = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worst case, space complexity will be O(2n), which equates to O(n), with this new struct I'll be able to load extensions lazily - without using Lazy
or AsyncLazy
- using AsyncLazy might be a better approach, I just wasn't able to get it to work.
|
||
public async Task<HttpResponseMessage> CallExtensibilityHost(LocalDeploymentEngineHost.ExtensionInfo extensionInfo, HttpContent content, CancellationToken cancellationToken) | ||
{ | ||
var extension = await extensionFactoryManager.GetLocalExtensionAsync(extensionInfo.ExtensionName, extensionInfo.ExtensionVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling extensionFactoryManager
ensures that we load the extension on-demand and only once.
Contributing a Pull Request
If you haven't already, read the full contribution guide. The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, run through the relevant checklist below.
Contributing to documentation
Contributing an example
We are integrating the Bicep examples into the Azure QuickStart Templates. If you'd like to contribute new example
.bicep
files that showcase abilities of the language, please follow these instructions to add them directly there. We can still take bug reports and fixes for the existing examples for the time being.dotnet test
Contributing a feature
Contributing a snippet
I have a snippet that is either a single, generic resource or multi resource that uses parent-child syntax
I have checked that there is not an equivalent snippet already submitted
I have used camelCasing unless I have a justification to use another casing style
I have placeholders values that correspond to their property names (e.g.
dnsPrefix: 'dnsPrefix'
), unless it's a property that MUST be changed or parameterized in order to deploy. In that case, I use 'REQUIRED' e.g. keyDataI have my symbolic name as the first tab stop ($1) in the snippet. e.g. res-aks-cluster.bicep
I have a resource name property equal to "name"
If applicable, I have set the
location
property tolocation: /*${<id>:location}*/'location'
(notresourceGroup().location
) where<id>
is a placeholder id, and addedparam location string
to the test's main.bicep file so that the resulting main.combined.bicep file used in the tests compiles without errorsI have verified that the snippet deploys correctly when used in the context of an actual bicep file
e.g.
Microsoft Reviewers: Open in CodeFlow