Repository: quarkusio/quarkus
Issue: java.lang.ClassCastException when upgrading from 2.16.0.Final to 2.16.1.Final

### Describe the bug

After upgrading to Quarkus 2.16.1 this issue started to happen:

```

 Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
 	[error]: Build step io.quarkus.kubernetes.deployment.KubernetesProcessor#build threw an exception: java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')
 	at io.dekorate.docker.adapter.DockerBuildConfigAdapter.newBuilder(DockerBuildConfigAdapter.java:58)
 	at io.dekorate.docker.config.DockerBuildConfigGenerator.addPropertyConfiguration(DockerBuildConfigGenerator.java:48)
 	at io.dekorate.Session.lambda$addPropertyConfiguration$1(Session.java:167)
 	at io.dekorate.Session.addConfiguration(Session.java:183)
 	at io.dekorate.Session.addPropertyConfiguration(Session.java:167)
 	at io.quarkus.kubernetes.deployment.KubernetesProcessor.lambda$build$2(KubernetesProcessor.java:164)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at io.quarkus.kubernetes.deployment.KubernetesProcessor.build(KubernetesProcessor.java:141)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
 	at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
 	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
 	at java.base/java.lang.Thread.run(Thread.java:829)
 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
```

### Expected behavior

No issues when upgrading from 2.16.0.Final to 2.16.1.Final

### Actual behavior

This seems to be a breaking change that we would not expect to see in a minor release.

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfigUtil.java
extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java

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 085ac6b982b..e7eb1862def 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
@@ -29,6 +29,8 @@
 import org.jboss.logging.Logger;
 
 import io.dekorate.utils.Strings;
+import io.quarkus.deployment.Capabilities;
+import io.quarkus.deployment.Capability;
 
 public class KubernetesConfigUtil {
 
@@ -36,8 +38,10 @@ public class KubernetesConfigUtil {
     private static final String QUARKUS_PREFIX = "quarkus.";
     private static final Pattern QUARKUS_DEPLOY_PATTERN = Pattern.compile("quarkus\\\\.([^\\\\.]+)\\\\.deploy");
 
-    private static final Set<String> ALLOWED_GENERATORS = new HashSet<>(
-            Arrays.asList(KUBERNETES, OPENSHIFT, KNATIVE, DOCKER, S2I));
+    private static final Set<String> ALLOWED_GENERATORS = Set.of(KUBERNETES, KNATIVE, OPENSHIFT);
+    private static final Map<String, String> ALLOWED_GENERATORS_BY_CAPABILITY = Map.of(
+            DOCKER, Capability.CONTAINER_IMAGE_DOCKER,
+            S2I, Capability.CONTAINER_IMAGE_S2I);
 
     private static final String EXPOSE_PROPERTY_NAME = "expose";
     private static final String[] EXPOSABLE_GENERATORS = { OPENSHIFT, KUBERNETES };
@@ -133,7 +137,7 @@ public static boolean isDeploymentEnabled() {
      *
      * @return A map containing the properties.
      */
-    public static Map<String, Object> toMap(PlatformConfiguration... platformConfigurations) {
+    public static Map<String, Object> toMap(Capabilities capabilities, PlatformConfiguration... platformConfigurations) {
         Config config = ConfigProvider.getConfig();
         Map<String, Object> result = new HashMap<>();
 
@@ -149,12 +153,13 @@ public static Map<String, Object> toMap(PlatformConfiguration... platformConfigu
                     .ifPresent(v -> quarkusPrefixed.put(DEKORATE_PREFIX + p.getConfigName() + ".version", v));
         });
 
+        Set<String> allowedGenerators = allowedGenerators(capabilities);
         Map<String, Object> unPrefixed = StreamSupport.stream(config.getPropertyNames().spliterator(), false)
-                .filter(k -> ALLOWED_GENERATORS.contains(generatorName(k)))
+                .filter(k -> allowedGenerators.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) {
+        for (String generator : allowedGenerators) {
             String oldKey = DEKORATE_PREFIX + generator + ".group";
             String newKey = DEKORATE_PREFIX + generator + ".part-of";
             if (unPrefixed.containsKey(oldKey)) {
@@ -206,6 +211,17 @@ private static void handleExpose(Config config, Map<String, Object> unPrefixed,
         }
     }
 
+    private static Set<String> allowedGenerators(Capabilities capabilities) {
+        Set<String> generators = new HashSet<>(ALLOWED_GENERATORS);
+        for (Map.Entry<String, String> generatorByCapability : ALLOWED_GENERATORS_BY_CAPABILITY.entrySet()) {
+            if (capabilities.isPresent(generatorByCapability.getValue())) {
+                generators.add(generatorByCapability.getKey());
+            }
+        }
+
+        return generators;
+    }
+
     /**
      * Returns the name of the generators that can handle the specified key.
      *
diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java
index ec65140a974..cf174966c66 100644
--- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java
+++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java
@@ -127,7 +127,7 @@ public void build(ApplicationInfoBuildItem applicationInfo,
             throw new RuntimeException("Unable to setup environment for generating Kubernetes resources", e);
         }
 
-        Map<String, Object> config = KubernetesConfigUtil.toMap(kubernetesConfig, openshiftConfig, knativeConfig);
+        Map<String, Object> config = KubernetesConfigUtil.toMap(capabilities, kubernetesConfig, openshiftConfig, knativeConfig);
         Set<String> deploymentTargets = kubernetesDeploymentTargets.getEntriesSortedByPriority().stream()
                 .map(DeploymentTargetEntry::getName)
                 .collect(Collectors.toSet());