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

Fix dynamic loading feature to load providers from custom bicepconfig.json aliases #12267

Merged
merged 61 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
fea7164
initial commit
Oct 12, 2023
0e2742d
refactor for simplicity
Oct 12, 2023
d587067
Fix Bicep.Cli.IntegrationTests
Oct 12, 2023
490b331
fix tests
Oct 12, 2023
755cd6d
simplify code
Oct 13, 2023
db01b75
fix conditional
Oct 13, 2023
e0f3582
adressed pr comments
Oct 13, 2023
d65557a
adress pr comments
Oct 13, 2023
49f9c83
adress pr comments
Oct 13, 2023
5374f96
fix tests
Oct 15, 2023
ce64dc7
rename moduleReference to reference
Oct 16, 2023
7b6c1ff
move ArtifactType to its own file
Oct 16, 2023
115b453
fix diagnostic to not use the class name
Oct 16, 2023
ee2dd62
Various renames to address pr comments
Oct 16, 2023
7a03b80
add GetArtifactType() fn
Oct 16, 2023
e190cb2
refactor functions to get type as first argument
Oct 16, 2023
89c2997
refactor functions to get type as first argument
Oct 16, 2023
27fd979
rename matcher
Oct 16, 2023
fa45b1a
rename
Oct 16, 2023
3011cd3
address pr comments
Oct 20, 2023
fd93bda
addressing pr comments
Oct 22, 2023
9ca749e
refactor TryGetNamespace signature
Oct 23, 2023
26e1148
more test cases
Oct 23, 2023
3b680cf
Merge remote-tracking branch 'origin/main' into asilverman/refactor/T…
Oct 23, 2023
f2470a0
refaactor T
Oct 23, 2023
4351706
various changes
Oct 30, 2023
a3f4135
various changes
Oct 30, 2023
0dcc38b
merge main
Oct 30, 2023
d8f2288
fix test setup
Oct 30, 2023
4004fea
fix tests
Oct 30, 2023
5b41e8e
fix tests
Nov 1, 2023
751aa77
fix tests
Nov 1, 2023
1aa2838
fix tests
Nov 1, 2023
ffd7fd9
fix tests
Nov 1, 2023
1a11767
revert unintentional rename
Nov 1, 2023
21ab650
fix refactors
Nov 1, 2023
fa2b074
dotnet format
Nov 1, 2023
c053734
revert unintentional rename
Nov 1, 2023
cafd535
fix compilation error
Nov 1, 2023
a04e43a
revert unintended changes
Nov 1, 2023
8f94298
various trims
Nov 1, 2023
52ec607
final touches
Nov 2, 2023
85b3b12
more finishing touches
Nov 2, 2023
f84d465
merge main
Nov 2, 2023
4712de5
fix diagnostic id
Nov 2, 2023
595bff7
make test os agnostic
Nov 2, 2023
eae634c
fix path resolution
Nov 2, 2023
e7d24ce
adress pr comments
Nov 3, 2023
7fa9ffa
fix test
Nov 3, 2023
769dfe6
use a test path
asilverman Nov 6, 2023
d63ed24
move file location to correct ns
Nov 6, 2023
e56322f
remove comment
Nov 6, 2023
524e774
move prodiver descriptor namespace
Nov 7, 2023
e5803cb
move files to correct namespace
Nov 7, 2023
0d0d2f1
rename to address pr comment
Nov 7, 2023
0e22a6e
address pr comments
Nov 7, 2023
18e4ea2
address PR comments
Nov 8, 2023
6a09d29
fixes
Nov 9, 2023
14e083e
adress pr comment
Nov 9, 2023
e1531cf
address pr comments
Nov 9, 2023
24f610b
address PR comments
Nov 14, 2023
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
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
asilverman committed Oct 30, 2023
commit 4004fea9529590fbc25fd73710b7d7664783a6bd
1 change: 0 additions & 1 deletion src/Bicep.Cli/Helpers/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static IServiceCollection AddCommands(this IServiceCollection services) =

public static IServiceCollection AddBicepCore(this IServiceCollection services) => services
.AddSingleton<INamespaceProvider, DefaultNamespaceProvider>()
.AddSingleton<IProviderTypeLoader, AzResourceTypeLoader>()
.AddSingleton<IResourceTypeProviderFactory, ResourceTypeProviderFactory>()
.AddSingleton<IContainerRegistryClientFactory, ContainerRegistryClientFactory>()
.AddSingleton<ITemplateSpecRepositoryFactory, TemplateSpecRepositoryFactory>()
Expand Down
1 change: 0 additions & 1 deletion src/Bicep.Core.UnitTests/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static class IServiceCollectionExtensions
{
public static IServiceCollection AddBicepCore(this IServiceCollection services) => services
.AddSingleton<INamespaceProvider, DefaultNamespaceProvider>()
.AddSingleton<IProviderTypeLoader, AzResourceTypeLoader>()
.AddSingleton<IResourceTypeProviderFactory, ResourceTypeProviderFactory>()
.AddSingleton<IContainerRegistryClientFactory, ContainerRegistryClientFactory>()
.AddSingleton<ITemplateSpecRepositoryFactory, TemplateSpecRepositoryFactory>()
Expand Down
13 changes: 10 additions & 3 deletions src/Bicep.Core/Semantics/DeclarationVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Bicep.Core.TypeSystem;
using Bicep.Core.Utils;
using Bicep.Core.Workspaces;
using System.IO;

namespace Bicep.Core.Semantics
{
Expand Down Expand Up @@ -191,18 +192,24 @@ TypeSymbol resolveProviderSymbol()
}

// Try to resolve the provider folder in the local cache from the specification (only works for az provider
string? providerPathInLocalCache = null;
string? providerPackageCacheDir = null;
if (syntax.Specification.Name.Equals(AzNamespaceType.BuiltInName) &&
!syntax.TryGetProviderDirectoryInCache(factory, features, context.SourceFileUri).IsSuccess(out providerPathInLocalCache, out var errorBuilder))
!syntax.TryGetProviderDirectoryInCache(factory, features, context.SourceFileUri).IsSuccess(out providerPackageCacheDir, out var errorBuilder))
{

return ErrorType.Create(errorBuilder(DiagnosticBuilder.ForPosition(syntax)));
}

// Check if the provider folder exists, if it doesn't then the provider could not be restored
if (providerPackageCacheDir is not null && !Directory.Exists(providerPackageCacheDir))
{
return ErrorType.Create(DiagnosticBuilder.ForPosition(syntax).UnrecognizedProvider(syntax.Specification.Name));
}

if (namespaceProvider.TryGetNamespace(
new(
syntax.Specification.Name,
providerPathInLocalCache,
providerPackageCacheDir,
syntax.Alias?.IdentifierName,
syntax.Specification.Version),
targetScope,
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/Semantics/Namespaces/INamespaceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public record TypesProviderDescriptor
{
public TypesProviderDescriptor(
string name,
string? path = null,
string? alias = null,
string? path = null,
string version = IResourceTypeProvider.BuiltInVersion)
{
Name = name;
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.Core/TypeSystem/K8s/K8sResourceTypeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Bicep.Core.TypeSystem.K8s
{
public class K8sResourceTypeLoader
public class K8sResourceTypeLoader : IProviderTypeLoader
{
private readonly ITypeLoader typeLoader;
private readonly K8sResourceTypeFactory resourceTypeFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Bicep.Core.TypeSystem.MicrosoftGraph
{
public class MicrosoftGraphResourceTypeLoader
public class MicrosoftGraphResourceTypeLoader : IProviderTypeLoader
{
private readonly ITypeLoader typeLoader;
private readonly MicrosoftGraphResourceTypeFactory resourceTypeFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static class IServiceCollectionExtensions
public static IServiceCollection AddBicepCompiler(this IServiceCollection services) => services
.AddSingleton<IFileSystem, FileSystem>()
.AddSingleton<INamespaceProvider, DefaultNamespaceProvider>()
.AddSingleton<IProviderTypeLoader, AzResourceTypeLoader>()
.AddSingleton<IResourceTypeProviderFactory, ResourceTypeProviderFactory>()
.AddSingleton<IContainerRegistryClientFactory, ContainerRegistryClientFactory>()
.AddSingleton<ITemplateSpecRepositoryFactory, TemplateSpecRepositoryFactory>()
Expand Down
1 change: 0 additions & 1 deletion src/Bicep.Wasm/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Bicep.Wasm;
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddBicepCore(this IServiceCollection services) => services
.AddSingleton<IProviderTypeLoader, AzResourceTypeLoader>()
.AddSingleton<IResourceTypeProviderFactory, ResourceTypeProviderFactory>()
.AddSingleton<INamespaceProvider, DefaultNamespaceProvider>()
.AddSingleton<IModuleDispatcher, ModuleDispatcher>()
Expand Down
Loading