Skip to content
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

Prototype: Support for dynamic loading of provider definitions #10624

Merged
merged 22 commits into from
May 25, 2023

Conversation

asilverman
Copy link
Contributor

@asilverman asilverman commented May 5, 2023

Overview

Adds support for loading the 'az' provider dynamically sourced from an OCI artifact registry. The artifact must be restored (downloaded to the appropriate location) manually under $BicepCacheRootDir/br/mcr.microsoft.com/bicep$providers$az/${providerVersion} which is the target location in the Bicep cache for the az provider.

The work to restore the provider data to the cache will be handled in a separate PR for convenience so that reviewing PRs is easier.

To enable the feature DynamicTypeLoadingEnabled and must be set to true in bicepconfig.json:

{
    "experimentalFeaturesEnabled": {
        "extensibility": true,
        "dynamicTypeLoadingEnabled": true,
    },
    "cacheRootDirectory": "~/.bicep",
}

Changes

  • Adds a new experimental feature flag DynamicTypeLoadingEnabled
  • Adds a new factory AzResourceTypeLoader that is handling the concern of deciding the provider loader to use based on the feature flag and presence of an import declaration syntax in the Bicep file being processed.
  • Serializes the provider version by inspecting the ImportDeclarationSyntax vs using a hardcoded value

Fixes #10662

Contributing a feature

  • I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented
  • I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged
  • I have appropriate test coverage of my new feature
Microsoft Reviewers: Open in CodeFlow

@asilverman asilverman force-pushed the asilverman/prototype/dynamic-loading branch 2 times, most recently from 67e79bd to 34c5c8e Compare May 9, 2023 04:24
@asilverman asilverman force-pushed the asilverman/prototype/dynamic-loading branch from 7a9165d to bf3a38f Compare May 10, 2023 17:48
@asilverman asilverman marked this pull request as ready for review May 15, 2023 17:25

public ApiVersionProvider(IFeatureProvider features, IAzResourceTypeLoader resourceTypeLoader)
private readonly IEnumerable<ResourceTypeReference> resourceTypeReferences;
public ApiVersionProvider(IFeatureProvider features, IEnumerable<ResourceTypeReference> resourceTypeReferences)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is laudable here but at the same time unsustainable @majastrz, @anthony-c-martin should we add a ticket to have a framework to test performance so we can apply consistently the necessary checks and also prevent unintended regressions?

Copy link
Contributor

@StephenWeatherford StephenWeatherford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to get a second opinion on the syntax tree in type provider code issue.

@asilverman asilverman dismissed StephenWeatherford’s stale review May 25, 2023 06:45

Stephens concerns were assuaged by manually testing performance

@asilverman asilverman merged commit 625341f into main May 25, 2023
@asilverman asilverman deleted the asilverman/prototype/dynamic-loading branch May 25, 2023 18:23
StephenWeatherford pushed a commit that referenced this pull request May 30, 2023
StephenWeatherford pushed a commit that referenced this pull request May 31, 2023
StephenWeatherford added a commit that referenced this pull request May 31, 2023
…rt for dynamic loading of provider definitions (#10863)

Revert "MAINT: Publish test output so that it can be consumed from wi…
Revert "MAINT: Increase default timeout to add stability to ci on MST… 
Revert "MAINT: Remove config on MSTest (#10831)" 
Revert "Create Bicep function (LoadEnvironmentVariable) to enableusin… 
Revert "Formatter v2 part 5: Add test baselines for all data sets (#1… 
Revert "Support for dynamic loading of provider definitions (#10624[)"]

###### Microsoft Reviewers: [Open in
CodeFlow](https://portal.fabricbot.ms/api/codeflow?pullrequest=https://github.com/Azure/bicep/pull/10863)

---------

Co-authored-by: Stephen Weatherford <Stephen.Weatherford.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Proposal: Distribute Bicep providers using OCI registry
6 participants