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

Log how Keycloak devservice maps resources #38680

Merged
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild
capturedDevServicesConfiguration.port,
useSharedNetwork,
capturedDevServicesConfiguration.realmPath.orElse(List.of()),
resourcesMap(),
resourcesMap(errors),
capturedDevServicesConfiguration.serviceName,
capturedDevServicesConfiguration.shared,
capturedDevServicesConfiguration.javaOpts,
Expand Down Expand Up @@ -401,12 +401,17 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild
.orElseGet(defaultKeycloakContainerSupplier);
}

private Map<String, String> resourcesMap() {
private Map<String, String> resourcesMap(List<String> errors) {
Map<String, String> resources = new HashMap<>();
for (Map.Entry<String, String> aliasEntry : capturedDevServicesConfiguration.resourceAliases.entrySet()) {
if (capturedDevServicesConfiguration.resourceMappings.containsKey(aliasEntry.getKey())) {
resources.put(aliasEntry.getValue(),
capturedDevServicesConfiguration.resourceMappings.get(aliasEntry.getKey()));
} else {
errors.add(String.format("%s alias for the %s resource does not have a mapping", aliasEntry.getKey(),
aliasEntry.getValue()));
LOG.errorf("%s alias for the %s resource does not have a mapping", aliasEntry.getKey(),
aliasEntry.getValue());
}
}
return resources;
Expand Down Expand Up @@ -540,12 +545,18 @@ protected void configure() {

private void mapResource(String resourcePath, String mappedResource) {
if (Thread.currentThread().getContextClassLoader().getResource(resourcePath) != null) {
LOG.debugf("Mapping the classpath %s resource to %s", resourcePath, mappedResource);
withClasspathResourceMapping(resourcePath, mappedResource, BindMode.READ_ONLY);
} else if (Files.exists(Paths.get(resourcePath))) {
LOG.debugf("Mapping the file system %s resource to %s", resourcePath, mappedResource);
withFileSystemBind(resourcePath, mappedResource, BindMode.READ_ONLY);
} else {
errors.add(String.format("%s resource is not available", resourcePath));
LOG.errorf("Realm %s resource is not available", resourcePath);
errors.add(
String.format(
"%s resource can not be mapped to %s because it is not available on the classpath and file system",
resourcePath, mappedResource));
LOG.errorf("%s resource can not be mapped to %s because it is not available on the classpath and file system",
resourcePath, mappedResource);
}
}

Expand Down
Loading