diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java index 085ac6b982be3..bf7c120e29e92 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java @@ -4,20 +4,15 @@ import static io.quarkus.deployment.builditem.ApplicationInfoBuildItem.UNSET_VALUE; import static io.quarkus.kubernetes.deployment.Constants.DEPLOY; import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT_TARGET; -import static io.quarkus.kubernetes.deployment.Constants.DOCKER; -import static io.quarkus.kubernetes.deployment.Constants.KNATIVE; -import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES; import static io.quarkus.kubernetes.deployment.Constants.OPENSHIFT; import static io.quarkus.kubernetes.deployment.Constants.S2I; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -26,24 +21,12 @@ import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; -import org.jboss.logging.Logger; - -import io.dekorate.utils.Strings; public class KubernetesConfigUtil { private static final String DEKORATE_PREFIX = "dekorate."; - private static final String QUARKUS_PREFIX = "quarkus."; private static final Pattern QUARKUS_DEPLOY_PATTERN = Pattern.compile("quarkus\\.([^\\.]+)\\.deploy"); - private static final Set ALLOWED_GENERATORS = new HashSet<>( - Arrays.asList(KUBERNETES, OPENSHIFT, KNATIVE, DOCKER, S2I)); - - private static final String EXPOSE_PROPERTY_NAME = "expose"; - private static final String[] EXPOSABLE_GENERATORS = { OPENSHIFT, KUBERNETES }; - - private static final Logger log = Logger.getLogger(KubernetesConfigUtil.class); - /** * Get the explicit configured deployment target, if any. * The explicit deployment target is determined using: `quarkus.kubernetes.deployment-target=` @@ -63,7 +46,7 @@ public static List getExplictilyDeploymentTargets() { return Collections.emptyList(); } return Arrays.stream(deploymentTargets - .split(",")) + .split(Pattern.quote(","))) .map(String::trim) .map(String::toLowerCase) .collect(Collectors.toList()); @@ -134,7 +117,6 @@ public static boolean isDeploymentEnabled() { * @return A map containing the properties. */ public static Map toMap(PlatformConfiguration... platformConfigurations) { - Config config = ConfigProvider.getConfig(); Map result = new HashMap<>(); // Most of quarkus prefixed properties are handled directly by the config items (KubernetesConfig, OpenshiftConfig, KnativeConfig) @@ -149,76 +131,11 @@ public static Map toMap(PlatformConfiguration... platformConfigu .ifPresent(v -> quarkusPrefixed.put(DEKORATE_PREFIX + p.getConfigName() + ".version", v)); }); - Map unPrefixed = StreamSupport.stream(config.getPropertyNames().spliterator(), false) - .filter(k -> ALLOWED_GENERATORS.contains(generatorName(k))) - .filter(k -> config.getOptionalValue(k, String.class).isPresent()) - .collect(Collectors.toMap(k -> DEKORATE_PREFIX + k, k -> config.getValue(k, String.class))); - - for (String generator : ALLOWED_GENERATORS) { - String oldKey = DEKORATE_PREFIX + generator + ".group"; - String newKey = DEKORATE_PREFIX + generator + ".part-of"; - if (unPrefixed.containsKey(oldKey)) { - unPrefixed.put(newKey, unPrefixed.get(oldKey)); - } - } - - handleExpose(config, unPrefixed, platformConfigurations); - - result.putAll(unPrefixed); result.putAll(quarkusPrefixed); result.putAll(toS2iProperties(quarkusPrefixed)); return result; } - @Deprecated - private static void handleExpose(Config config, Map unPrefixed, - PlatformConfiguration... platformConfigurations) { - for (String generator : EXPOSABLE_GENERATORS) { - boolean unprefixedExpose = config.getOptionalValue(generator + "." + EXPOSE_PROPERTY_NAME, Boolean.class) - .orElse(false); - boolean prefixedExpose = config - .getOptionalValue(QUARKUS_PREFIX + generator + "." + EXPOSE_PROPERTY_NAME, Boolean.class) - .orElse(false); - if (unprefixedExpose || prefixedExpose) { - if (generator == KUBERNETES) { - log.warn("Usage of quarkus.kubernetes.expose is deprecated in favor of quarkus.kubernetes.ingress.expose"); - } else { - log.warn("Usage of quarkus.openshift.expose is deprecated in favor of quarkus.openshift.route.expose"); - } - unPrefixed.put(DEKORATE_PREFIX + generator + "." + EXPOSE_PROPERTY_NAME, true); - for (PlatformConfiguration platformConfiguration : platformConfigurations) { - if (platformConfiguration.getConfigName().equals(generator)) { - platformConfiguration.getHost() - .ifPresent(h -> { - unPrefixed.put(DEKORATE_PREFIX + generator + ".host", h); - if (generator == KUBERNETES) { - log.warn( - "Usage of quarkus.kubernetes.host is deprecated in favor of quarkus.kubernetes.ingress.host"); - } else { - log.warn( - "Usage of quarkus.openshift.host is deprecated in favor of quarkus.openshift.route.host"); - } - }); - break; - } - } - } - } - } - - /** - * Returns the name of the generators that can handle the specified key. - * - * @param key The key. - * @return The generator name or null if the key format is unexpected. - */ - private static String generatorName(String key) { - if (Strings.isNullOrEmpty(key) || !key.contains(".")) { - return null; - } - return key.substring(0, key.indexOf(".")); - } - private static Map toS2iProperties(Map map) { Map result = new HashMap<>(); map.forEach((k, v) -> { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithDeprecatedPropertiesTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithDeprecatedPropertiesTest.java deleted file mode 100644 index c06d3ada91c48..0000000000000 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithDeprecatedPropertiesTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package io.quarkus.it.kubernetes; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.entry; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.api.model.apps.Deployment; -import io.quarkus.test.ProdBuildResults; -import io.quarkus.test.ProdModeTestResults; -import io.quarkus.test.QuarkusProdModeTest; - -public class KubernetesWithDeprecatedPropertiesTest { - - @RegisterExtension - static final QuarkusProdModeTest config = new QuarkusProdModeTest() - .withApplicationRoot((jar) -> jar.addClasses(GreetingResource.class)) - .setApplicationName("kubernetes-with-deprecated-properties") - .setApplicationVersion("0.1-SNAPSHOT") - .withConfigurationResource("kubernetes-with-deprecated.properties"); - - @ProdBuildResults - private ProdModeTestResults prodModeTestResults; - - @Test - public void assertGeneratedResources() throws IOException { - Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes"); - assertThat(kubernetesDir) - .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json")) - .isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml")); - List kubernetesList = DeserializationUtil - .deserializeAsList(kubernetesDir.resolve("kubernetes.yml")); - - assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> { - assertThat(d.getMetadata()).satisfies(m -> { - assertThat(m.getLabels()).contains(entry("app.kubernetes.io/part-of", "grp")); - }); - }); - } -} diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-deprecated.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-deprecated.properties deleted file mode 100644 index 6df38eece81a5..0000000000000 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/kubernetes-with-deprecated.properties +++ /dev/null @@ -1 +0,0 @@ -kubernetes.group=grp diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-legacy-sidecar-and-s2i.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-legacy-sidecar-and-s2i.properties index 1af97a9376baa..f293fcce1ccff 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-legacy-sidecar-and-s2i.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-legacy-sidecar-and-s2i.properties @@ -1,4 +1,4 @@ -quarkus.openshift.expose=true +quarkus.openshift.route.expose=true quarkus.s2i.base-jvm-image=my.registry.example/openjdk/openjdk-11-rhel7 quarkus.openshift.containers.sc.image=quay.io/sidecar/image:2.1 quarkus.openshift.containers.sc.image-pull-policy=IfNotPresent diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-s2i.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-s2i.properties index b8f6c32c14a51..dc7c1d322dd43 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-s2i.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-s2i.properties @@ -1,3 +1,3 @@ -quarkus.openshift.expose=true +quarkus.openshift.route.expose=true quarkus.s2i.base-jvm-image=my.registry.example/openjdk/openjdk-11-rhel7 quarkus.s2i.jvm-arguments=-Djava.util.logging.manager=org.jboss.logmanager.LogManager \ No newline at end of file diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-sidecar-and-s2i.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-sidecar-and-s2i.properties index c94814b323956..f60a7825fec4f 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-sidecar-and-s2i.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/openshift-with-sidecar-and-s2i.properties @@ -1,4 +1,4 @@ -quarkus.openshift.expose=true +quarkus.openshift.route.expose=true quarkus.s2i.base-jvm-image=my.registry.example/openjdk/openjdk-11-rhel7 quarkus.openshift.sidecars.sc.image=quay.io/sidecar/image:2.1 quarkus.openshift.sidecars.sc.image-pull-policy=IfNotPresent