Skip to content

Commit 972f9a9

Browse files
committed
Hosting.KeyCloak: Remove incorrect param check on WithRealmImport
The import path is expected to be relative to the AppHost path, but here it was being used as-is - relative to the current working directory. Instead, remove the check and let the downstream `WithBindMount` method use the path correctly. This manifested as a failure to import the file when running the app with `Aspire.Hosting.Testing` which would start the apphost with cwd!=apphost .
1 parent 583014c commit 972f9a9

File tree

4 files changed

+1939
-7
lines changed

4 files changed

+1939
-7
lines changed

src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,7 @@ public static IResourceBuilder<KeycloakResource> WithRealmImport(
138138
{
139139
ArgumentNullException.ThrowIfNull(importDirectory);
140140

141-
if (!Directory.Exists(importDirectory))
142-
{
143-
throw new DirectoryNotFoundException($"The realm import directory {importDirectory} does not exist.");
144-
}
145-
146141
builder.WithBindMount(importDirectory, RealmImportDirectory, isReadOnly);
147-
148142
return builder;
149143
}
150144
}

tests/TestingAppHost1/TestingAppHost1.AppHost/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
var builder = DistributedApplication.CreateBuilder(args);
77

88
builder.AddRedis("redis1");
9+
var keycloak = builder.AddKeycloak("keycloak", 8080)
10+
.WithDataVolume()
11+
.WithRealmImport("../realms");
912
builder.AddProject<Projects.TestingAppHost1_MyWebApp>("mywebapp1")
1013
.WithEndpoint("http", ea => ea.IsProxied = false)
1114
.WithEndpoint("https", ea => ea.IsProxied = false)
12-
.WithExternalHttpEndpoints();
15+
.WithExternalHttpEndpoints()
16+
.WithReference(keycloak);
1317
builder.AddProject<Projects.TestingAppHost1_MyWorker>("myworker1")
1418
.WithEndpoint(name: "myendpoint1");
1519
builder.AddPostgres("postgres1");

tests/TestingAppHost1/TestingAppHost1.AppHost/TestingAppHost1.AppHost.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ProjectReference Include="..\..\..\src\Aspire.Hosting.AppHost\Aspire.Hosting.AppHost.csproj" IsAspireProjectResource="false" />
1313
<ProjectReference Include="..\..\..\src\Aspire.Hosting.PostgreSQL\Aspire.Hosting.PostgreSQL.csproj" IsAspireProjectResource="false" />
1414
<ProjectReference Include="..\..\..\src\Aspire.Hosting.Redis\Aspire.Hosting.Redis.csproj" IsAspireProjectResource="false" />
15+
<ProjectReference Include="..\..\..\src\Aspire.Hosting.Keycloak\Aspire.Hosting.Keycloak.csproj" IsAspireProjectResource="false" />
1516
<ProjectReference Include="..\TestingAppHost1.MyWebApp\TestingAppHost1.MyWebApp.csproj" />
1617
<ProjectReference Include="..\TestingAppHost1.MyWorker\TestingAppHost1.MyWorker.csproj" />
1718
</ItemGroup>

0 commit comments

Comments
 (0)