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

[LocalDeploy] Migrate to extensibility v2 contract #14438

Merged
merged 19 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/Bicep.Cli.IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
},
"Azure.Deployments.Core": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "Zev+8/PldTvNwUEI84e7szmJm7/ClHyr4fe0hlMylZ9lwD4wCOyc3ijWe6LmI8J92WtXX7Mh1K1FtIcHOZC0iw==",
"resolved": "1.54.0",
"contentHash": "dItBSPwB83gv9BXwPEcef4VYufmuP7w59Bg/xpjCSlBEPlj3UukVypUqMmI2hRObhNnz2TQHiMw+Y/S8HtJbyA==",
"dependencies": {
"Microsoft.PowerPlatform.ResourceStack": "7.0.0.2007",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -133,19 +133,19 @@
},
"Azure.Deployments.DiffEngine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "JqDITGajqF4tjR0sqgl8YlwWEC92r7LOHjzP0cH6K0mQIyY3rRr2c1k3fbYRrbG1D69o4IiNXqqShDd8K4lSMg=="
"resolved": "1.54.0",
"contentHash": "Z+1Q/Vpy/LF0xKm3/0szoU/0AhZuNbnQOVMagtfejpRNteqnmeryLjdHG59AeKIpzgbHr3XxusfGz0jg4wjLdA=="
},
"Azure.Deployments.Engine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "xP1lnwgceE74Tmp5N5R1SdcB0iICwH2QiwVWpZnjqzA5EXGr9tesEbV1EO7GTgfCXtTWYbcQlySkAKtDPuMt0A==",
"resolved": "1.54.0",
"contentHash": "8mx0e0JUq43Ax/5I1BEcvUsFmDIUdsRnrKIMG3+QOz11SMbI2nHAPQYFkIkWnxgaxpObaZvx6EcJXQmptEgehg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.DiffEngine": "1.34.0",
"Azure.Deployments.Extensibility": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.DiffEngine": "1.54.0",
"Azure.Deployments.Extensibility": "1.54.0",
"Azure.Deployments.ResourceMetadata": "1.0.1265",
"Azure.Deployments.Templates": "1.34.0",
"Azure.Deployments.Templates": "1.54.0",
"Microsoft.AspNet.WebApi.Client": "5.2.9",
"Microsoft.Extensions.DependencyInjection": "8.0.0",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -155,20 +155,20 @@
},
"Azure.Deployments.Expression": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "4XIed8jUdWsc8IG2o2tdqJl8ioWjwN9MR2y9L9PV/5wlDUyb2I6MXVwU/f5d3ZMCD+svc4rE6HRgxMIBYHZmSQ==",
"resolved": "1.54.0",
"contentHash": "2nhYxVun701mghHxK5h5qZoL9RjaVCo83/VTc2HgPKJkIcRW3oYFbxnMQrP5pr9k0GsCxKmvOkwsoET9gy851A==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"IPNetwork2": "2.6.598",
"Newtonsoft.Json": "13.0.2"
}
},
"Azure.Deployments.Extensibility": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "3n64LvNi90r70Puobb8OImKlivz6/JaCW7zVImwb8VXeXTJJtoPTuY0z81QroGqdQMA/aU8123edFBTM4hiBVg==",
"resolved": "1.54.0",
"contentHash": "CiMXvV8NVW/xQKMQVX7gmKj20GP/h1k+4nuCNyCoS5gek4WI9yk7pH0XHwmx1TVf2Ms1vtwc9bOYohq1kd27tg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Newtonsoft.Json": "13.0.2"
}
},
Expand Down Expand Up @@ -196,12 +196,12 @@
},
"Azure.Deployments.Templates": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "AlstKsqlGEv8XNEjtCZ9KsI//ZKtnKn0m18TSuSQT36w+RjWiCo35uE6U/HTIXmTRS/jJVOuwMSPU4FhTLW/jg==",
"resolved": "1.54.0",
"contentHash": "TNq6JNNcDVuNSS4sqBUETVTm8KDIYvt28vWSPaV+rHyTogo0qJHciSQglEwOk0zoTp1Qf8plT7QqXS0uM/A2AA==",
"dependencies": {
"Azure.Bicep.Types": "0.5.9",
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Expression": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.Expression": "1.54.0",
"Microsoft.Automata.SRM": "1.2.2",
"Newtonsoft.Json": "13.0.2"
}
Expand Down Expand Up @@ -1622,7 +1622,7 @@
"dependencies": {
"Azure.Bicep.Core": "[1.0.0, )",
"Azure.Bicep.Local.Extension": "[1.0.0, )",
"Azure.Deployments.Engine": "[1.34.0, )",
"Azure.Deployments.Engine": "[1.54.0, )",
"Microsoft.AspNet.WebApi.Client": "[6.0.0, )"
}
},
Expand Down
42 changes: 21 additions & 21 deletions src/Bicep.Cli.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
},
"Azure.Deployments.Core": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "Zev+8/PldTvNwUEI84e7szmJm7/ClHyr4fe0hlMylZ9lwD4wCOyc3ijWe6LmI8J92WtXX7Mh1K1FtIcHOZC0iw==",
"resolved": "1.54.0",
"contentHash": "dItBSPwB83gv9BXwPEcef4VYufmuP7w59Bg/xpjCSlBEPlj3UukVypUqMmI2hRObhNnz2TQHiMw+Y/S8HtJbyA==",
"dependencies": {
"Microsoft.PowerPlatform.ResourceStack": "7.0.0.2007",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -133,19 +133,19 @@
},
"Azure.Deployments.DiffEngine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "JqDITGajqF4tjR0sqgl8YlwWEC92r7LOHjzP0cH6K0mQIyY3rRr2c1k3fbYRrbG1D69o4IiNXqqShDd8K4lSMg=="
"resolved": "1.54.0",
"contentHash": "Z+1Q/Vpy/LF0xKm3/0szoU/0AhZuNbnQOVMagtfejpRNteqnmeryLjdHG59AeKIpzgbHr3XxusfGz0jg4wjLdA=="
},
"Azure.Deployments.Engine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "xP1lnwgceE74Tmp5N5R1SdcB0iICwH2QiwVWpZnjqzA5EXGr9tesEbV1EO7GTgfCXtTWYbcQlySkAKtDPuMt0A==",
"resolved": "1.54.0",
"contentHash": "8mx0e0JUq43Ax/5I1BEcvUsFmDIUdsRnrKIMG3+QOz11SMbI2nHAPQYFkIkWnxgaxpObaZvx6EcJXQmptEgehg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.DiffEngine": "1.34.0",
"Azure.Deployments.Extensibility": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.DiffEngine": "1.54.0",
"Azure.Deployments.Extensibility": "1.54.0",
"Azure.Deployments.ResourceMetadata": "1.0.1265",
"Azure.Deployments.Templates": "1.34.0",
"Azure.Deployments.Templates": "1.54.0",
"Microsoft.AspNet.WebApi.Client": "5.2.9",
"Microsoft.Extensions.DependencyInjection": "8.0.0",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -155,20 +155,20 @@
},
"Azure.Deployments.Expression": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "4XIed8jUdWsc8IG2o2tdqJl8ioWjwN9MR2y9L9PV/5wlDUyb2I6MXVwU/f5d3ZMCD+svc4rE6HRgxMIBYHZmSQ==",
"resolved": "1.54.0",
"contentHash": "2nhYxVun701mghHxK5h5qZoL9RjaVCo83/VTc2HgPKJkIcRW3oYFbxnMQrP5pr9k0GsCxKmvOkwsoET9gy851A==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"IPNetwork2": "2.6.598",
"Newtonsoft.Json": "13.0.2"
}
},
"Azure.Deployments.Extensibility": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "3n64LvNi90r70Puobb8OImKlivz6/JaCW7zVImwb8VXeXTJJtoPTuY0z81QroGqdQMA/aU8123edFBTM4hiBVg==",
"resolved": "1.54.0",
"contentHash": "CiMXvV8NVW/xQKMQVX7gmKj20GP/h1k+4nuCNyCoS5gek4WI9yk7pH0XHwmx1TVf2Ms1vtwc9bOYohq1kd27tg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Newtonsoft.Json": "13.0.2"
}
},
Expand Down Expand Up @@ -196,12 +196,12 @@
},
"Azure.Deployments.Templates": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "AlstKsqlGEv8XNEjtCZ9KsI//ZKtnKn0m18TSuSQT36w+RjWiCo35uE6U/HTIXmTRS/jJVOuwMSPU4FhTLW/jg==",
"resolved": "1.54.0",
"contentHash": "TNq6JNNcDVuNSS4sqBUETVTm8KDIYvt28vWSPaV+rHyTogo0qJHciSQglEwOk0zoTp1Qf8plT7QqXS0uM/A2AA==",
"dependencies": {
"Azure.Bicep.Types": "0.5.9",
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Expression": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.Expression": "1.54.0",
"Microsoft.Automata.SRM": "1.2.2",
"Newtonsoft.Json": "13.0.2"
}
Expand Down Expand Up @@ -1454,7 +1454,7 @@
"dependencies": {
"Azure.Bicep.Core": "[1.0.0, )",
"Azure.Bicep.Local.Extension": "[1.0.0, )",
"Azure.Deployments.Engine": "[1.34.0, )",
"Azure.Deployments.Engine": "[1.54.0, )",
"Microsoft.AspNet.WebApi.Client": "[6.0.0, )"
}
},
Expand Down
42 changes: 21 additions & 21 deletions src/Bicep.Cli/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@
},
"Azure.Deployments.Core": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "Zev+8/PldTvNwUEI84e7szmJm7/ClHyr4fe0hlMylZ9lwD4wCOyc3ijWe6LmI8J92WtXX7Mh1K1FtIcHOZC0iw==",
"resolved": "1.54.0",
"contentHash": "dItBSPwB83gv9BXwPEcef4VYufmuP7w59Bg/xpjCSlBEPlj3UukVypUqMmI2hRObhNnz2TQHiMw+Y/S8HtJbyA==",
"dependencies": {
"Microsoft.PowerPlatform.ResourceStack": "7.0.0.2007",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -151,19 +151,19 @@
},
"Azure.Deployments.DiffEngine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "JqDITGajqF4tjR0sqgl8YlwWEC92r7LOHjzP0cH6K0mQIyY3rRr2c1k3fbYRrbG1D69o4IiNXqqShDd8K4lSMg=="
"resolved": "1.54.0",
"contentHash": "Z+1Q/Vpy/LF0xKm3/0szoU/0AhZuNbnQOVMagtfejpRNteqnmeryLjdHG59AeKIpzgbHr3XxusfGz0jg4wjLdA=="
},
"Azure.Deployments.Engine": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "xP1lnwgceE74Tmp5N5R1SdcB0iICwH2QiwVWpZnjqzA5EXGr9tesEbV1EO7GTgfCXtTWYbcQlySkAKtDPuMt0A==",
"resolved": "1.54.0",
"contentHash": "8mx0e0JUq43Ax/5I1BEcvUsFmDIUdsRnrKIMG3+QOz11SMbI2nHAPQYFkIkWnxgaxpObaZvx6EcJXQmptEgehg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.DiffEngine": "1.34.0",
"Azure.Deployments.Extensibility": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.DiffEngine": "1.54.0",
"Azure.Deployments.Extensibility": "1.54.0",
"Azure.Deployments.ResourceMetadata": "1.0.1265",
"Azure.Deployments.Templates": "1.34.0",
"Azure.Deployments.Templates": "1.54.0",
"Microsoft.AspNet.WebApi.Client": "5.2.9",
"Microsoft.Extensions.DependencyInjection": "8.0.0",
"Newtonsoft.Json": "13.0.2",
Expand All @@ -173,20 +173,20 @@
},
"Azure.Deployments.Expression": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "4XIed8jUdWsc8IG2o2tdqJl8ioWjwN9MR2y9L9PV/5wlDUyb2I6MXVwU/f5d3ZMCD+svc4rE6HRgxMIBYHZmSQ==",
"resolved": "1.54.0",
"contentHash": "2nhYxVun701mghHxK5h5qZoL9RjaVCo83/VTc2HgPKJkIcRW3oYFbxnMQrP5pr9k0GsCxKmvOkwsoET9gy851A==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"IPNetwork2": "2.6.598",
"Newtonsoft.Json": "13.0.2"
}
},
"Azure.Deployments.Extensibility": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "3n64LvNi90r70Puobb8OImKlivz6/JaCW7zVImwb8VXeXTJJtoPTuY0z81QroGqdQMA/aU8123edFBTM4hiBVg==",
"resolved": "1.54.0",
"contentHash": "CiMXvV8NVW/xQKMQVX7gmKj20GP/h1k+4nuCNyCoS5gek4WI9yk7pH0XHwmx1TVf2Ms1vtwc9bOYohq1kd27tg==",
"dependencies": {
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Newtonsoft.Json": "13.0.2"
}
},
Expand Down Expand Up @@ -214,12 +214,12 @@
},
"Azure.Deployments.Templates": {
"type": "Transitive",
"resolved": "1.34.0",
"contentHash": "AlstKsqlGEv8XNEjtCZ9KsI//ZKtnKn0m18TSuSQT36w+RjWiCo35uE6U/HTIXmTRS/jJVOuwMSPU4FhTLW/jg==",
"resolved": "1.54.0",
"contentHash": "TNq6JNNcDVuNSS4sqBUETVTm8KDIYvt28vWSPaV+rHyTogo0qJHciSQglEwOk0zoTp1Qf8plT7QqXS0uM/A2AA==",
"dependencies": {
"Azure.Bicep.Types": "0.5.9",
"Azure.Deployments.Core": "1.34.0",
"Azure.Deployments.Expression": "1.34.0",
"Azure.Deployments.Core": "1.54.0",
"Azure.Deployments.Expression": "1.54.0",
"Microsoft.Automata.SRM": "1.2.2",
"Newtonsoft.Json": "13.0.2"
}
Expand Down Expand Up @@ -1352,7 +1352,7 @@
"dependencies": {
"Azure.Bicep.Core": "[1.0.0, )",
"Azure.Bicep.Local.Extension": "[1.0.0, )",
"Azure.Deployments.Engine": "[1.34.0, )",
"Azure.Deployments.Engine": "[1.54.0, )",
"Microsoft.AspNet.WebApi.Client": "[6.0.0, )"
}
},
Expand Down
84 changes: 84 additions & 0 deletions src/Bicep.Core.IntegrationTests/RegistryProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Bicep.Core.IntegrationTests;
public class RegistryProviderTests : TestBase
{
private static readonly FeatureProviderOverrides AllFeaturesEnabled = new(ExtensibilityEnabled: true, ProviderRegistry: true, DynamicTypeLoadingEnabled: true);
private static readonly FeatureProviderOverrides AllFeaturesEnabledForLocalDeploy = new(LocalDeployEnabled: true, ExtensibilityEnabled: true, ProviderRegistry: true, DynamicTypeLoadingEnabled: true);

[TestMethod]
[TestCategory(BaselineHelper.BaselineTestCategory)]
Expand Down Expand Up @@ -349,6 +350,89 @@ public async Task Missing_required_provider_configuration_blocks_compilation()
});
}

[TestMethod]
public async Task Correct_local_deploy_provider_configuration_result_in_successful_compilation()
{
// tgzData provideds configType with the properties namespace, config, and context
var services = await ProviderTestHelper.GetServiceBuilderWithPublishedProvider(ThirdPartyTypeHelper.GetTestTypesTgzWithFallbackAndConfiguration(), AllFeaturesEnabledForLocalDeploy);

var result = await CompilationHelper.RestoreAndCompile(services, """
provider 'br:example.azurecr.io/providers/foo:1.2.3' with {
namespace: 'ThirdPartyNamespace'
config: 'Some path to config file'
context: 'Some ThirdParty context'
}

resource dadJoke 'fooType@v1' = {
identifier: 'foo'
joke: 'dad joke'
}

output joke string = dadJoke.joke
""");

result.Template.Should().NotBeNull();

result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['name']", "ThirdPartyProvider");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['version']", "1.0.0");

result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['namespace']['type']", "string");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['namespace']['defaultValue']", "ThirdPartyNamespace");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['config']['type']", "string");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['config']['defaultValue']", "Some path to config file");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['context']['type']", "string");
result.Template.Should().HaveValueAtPath("$.extensions['ThirdPartyProvider']['config']['context']['defaultValue']", "Some ThirdParty context");

result.Should().NotHaveAnyDiagnostics();
}

[TestMethod]
public async Task Local_deploy_provider_with_configuration_defined_and_empty_configuration_provided_result_in_failure_compilation()
{
// tgzData provideds configType with the properties namespace, config, and context
var services = await ProviderTestHelper.GetServiceBuilderWithPublishedProvider(ThirdPartyTypeHelper.GetTestTypesTgzWithFallbackAndConfiguration(), AllFeaturesEnabledForLocalDeploy);

var result = await CompilationHelper.RestoreAndCompile(services, """
provider 'br:example.azurecr.io/providers/foo:1.2.3' with { }

resource dadJoke 'fooType@v1' = {
identifier: 'foo'
joke: 'dad joke'
}

output joke string = dadJoke.joke
""");

result.Template.Should().BeNull();

result.Should().HaveDiagnostics([("BCP035", DiagnosticLevel.Error, "The specified \"object\" declaration is missing the following required properties: \"config\", \"namespace\".")], because: "Type checking should block the template compilation because required provider config properties hasn't been supplied.");
}

[TestMethod]
public async Task Local_deploy_provider_without_configuration_defined_and_configuration_provided_result_in_failure_compilation()
{
var services = await ProviderTestHelper.GetServiceBuilderWithPublishedProvider(ThirdPartyTypeHelper.GetTestTypesTgz(), AllFeaturesEnabledForLocalDeploy);

var result = await CompilationHelper.RestoreAndCompile(services, """
provider 'br:example.azurecr.io/providers/foo:1.2.3' with {
namespace: 'ThirdPartyNamespace'
config: 'Some path to config file'
context: 'Some ThirdParty context'
}

resource fooRes 'fooType@v1' existing = {
identifier: 'foo'
}

output baz string = fooRes.convertBarToBaz('bar')

""");

result.Template.Should().BeNull();

result.Should().HaveDiagnostics([("BCP205", DiagnosticLevel.Error, "Provider namespace \"ThirdPartyProvider\" does not support configuration.")], because: "Type checking should block the template compilation because provider does not support configuration but one has been provided.");
}

[TestMethod]
public async Task Correct_provider_configuration_result_in_successful_compilation()
{
Expand Down
Loading
Loading