From 0a08d9dd6f11205f3e76cb564a12c7269dba7d08 Mon Sep 17 00:00:00 2001 From: Sergey Beryozkin Date: Thu, 8 Feb 2024 13:08:48 +0000 Subject: [PATCH] Log how Keycloak devservice maps resources --- .../KeycloakDevServicesProcessor.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index 4cc2ff2a17d2f..c2ef04ff3d074 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -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, @@ -401,12 +401,17 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild .orElseGet(defaultKeycloakContainerSupplier); } - private Map resourcesMap() { + private Map resourcesMap(List errors) { Map resources = new HashMap<>(); for (Map.Entry 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; @@ -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); } }