From 8797fe6995b76e3064f646853948c934d851049f Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 7 Sep 2021 12:43:47 +0300 Subject: [PATCH] Trim container-image configuration values Fixes: #19956 (cherry picked from commit ab8fa5ea7c6a832556bfa7a2de2bd3ab25ca65d4) --- .../container/image/deployment/ContainerImageConfig.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageConfig.java b/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageConfig.java index 87547b9f92a7b..ba801165fc494 100644 --- a/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageConfig.java +++ b/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageConfig.java @@ -5,6 +5,8 @@ import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; +import io.quarkus.runtime.annotations.ConvertWith; +import io.quarkus.runtime.configuration.TrimmedStringConverter; @ConfigRoot public class ContainerImageConfig { @@ -13,12 +15,14 @@ public class ContainerImageConfig { * The group the container image will be part of */ @ConfigItem(defaultValue = "${user.name}") + @ConvertWith(TrimmedStringConverter.class) public Optional group; /** * The name of the container image. If not set defaults to the application name */ @ConfigItem(defaultValue = "${quarkus.application.name:unset}") + @ConvertWith(TrimmedStringConverter.class) public Optional name; /** @@ -95,6 +99,9 @@ public Optional getEffectiveGroup() { if (group.isPresent()) { String originalGroup = group.get(); if (originalGroup.equals(System.getProperty("user.name"))) { + if (originalGroup.isEmpty()) { + return Optional.empty(); + } return Optional.of(originalGroup.toLowerCase().replace(' ', '-')); } }