gnodet opened a new pull request, #27216:
URL: https://github.com/apache/camel/pull/27216

   ## Problem
   
   When the user explicitly passes `--cluster-type <type>` to `camel kubernetes 
run`, the value is silently discarded and replaced by the auto-detected cluster 
type.
   
   Root cause: `KubernetesRun.clusterType` was initialized to `"Kubernetes"`, 
so picocli cannot distinguish between the user passing `--cluster-type 
kubernetes` and the user omitting the option entirely. `detectCluster()` then 
unconditionally overwrites the field with the auto-detected value, ignoring 
whatever the user passed.
   
   This means that passing `--cluster-type openshift` with a non-OpenShift kube 
context active silently results in using `jib` as the image builder and 
`k8s:deploy` instead of `docker` + `oc:deploy`, with no warning.
   
   The workaround (`--disable-auto --cluster-type openshift`) is non-obvious 
and undiscoverable.
   
   ## Fix
   
   - Change `clusterType` field default from `"Kubernetes"` to `null`, 
consistent with `KubernetesExport.clusterType`
   - Guard `detectCluster()` to only run auto-detection when `clusterType == 
null` (i.e., the user did not provide `--cluster-type`)
   - After the guard, fall back to `KUBERNETES` if the field is still null 
(covers the `--disable-auto` + no explicit cluster type case)
   
   ## Test
   
   Added `explicitClusterTypeShouldNotBeOverriddenByAutoDetection` in 
`KubernetesRunCustomTest`:
   - Minikube environment variables are set, mock server responds as Minikube
   - User passes `--cluster-type=openshift`
   - Assert that `command.clusterType` is `openshift` after the run (not 
`minikube`)
   
   All existing tests (`disableAutomaticClusterDetection`, 
`detectOpenshiftCluster`, `detectMinikubeCluster`) continue to pass.
   
   Fixes CAMEL-24662.
   
   _This PR was produced by Hermes Agent on behalf of gnodet._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to