[
https://issues.apache.org/jira/browse/CAMEL-12891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16658613#comment-16658613
]
ASF GitHub Bot commented on CAMEL-12891:
----------------------------------------
oscerd closed pull request #2573: CAMEL-12891 - Allow getConfigMap operation to
specify namespace.
URL: https://github.com/apache/camel/pull/2573
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
index 7513a8e43af..6878a337cf9 100644
---
a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
+++
b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/config_maps/KubernetesConfigMapsProducer.java
@@ -109,11 +109,16 @@ protected void doListConfigMapsByLabels(Exchange
exchange, String operation) thr
protected void doGetConfigMap(Exchange exchange, String operation) throws
Exception {
ConfigMap configMap = null;
String cfMapName =
exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME,
String.class);
+ String namespaceName =
exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
String.class);
if (ObjectHelper.isEmpty(cfMapName)) {
LOG.error("Get a specific ConfigMap require specify a ConfigMap
name");
throw new IllegalArgumentException("Get a specific ConfigMap
require specify a ConfigMap name");
}
- configMap =
getEndpoint().getKubernetesClient().configMaps().withName(cfMapName).get();
+ if(namespaceName != null) {
+ configMap =
getEndpoint().getKubernetesClient().configMaps().inNamespace(namespaceName).withName(cfMapName).get();
+ } else {
+ configMap =
getEndpoint().getKubernetesClient().configMaps().withName(cfMapName).get();
+ }
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(configMap);
diff --git
a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
index ef63de6bf04..f4497698a82 100644
---
a/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
+++
b/components/camel-kubernetes/src/test/java/org/apache/camel/component/kubernetes/producer/KubernetesConfigMapsProducerTest.java
@@ -73,9 +73,9 @@ public void process(Exchange exchange) throws Exception {
assertEquals(3, result.size());
}
-
+
@Test
- public void getConfigMapTest() throws Exception {
+ public void getConfigMapTestDefaultNamespace() throws Exception {
ObjectMeta meta = new ObjectMeta();
meta.setName("cm1");
server.expect().withPath("/api/v1/namespaces/test/configmaps/cm1").andReturn(200,
new ConfigMapBuilder().withMetadata(meta).build()).once();
@@ -84,7 +84,26 @@ public void getConfigMapTest() throws Exception {
@Override
public void process(Exchange exchange) throws Exception {
-
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
"test");
+
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME,
"cm1");
+ }
+ });
+
+ ConfigMap result = ex.getOut().getBody(ConfigMap.class);
+
+ assertEquals("cm1", result.getMetadata().getName());
+ }
+
+ @Test
+ public void getConfigMapTestCustomNamespace() throws Exception {
+ ObjectMeta meta = new ObjectMeta();
+ meta.setName("cm1");
+
server.expect().withPath("/api/v1/namespaces/custom/configmaps/cm1").andReturn(200,
new ConfigMapBuilder().withMetadata(meta).build()).once();
+
server.expect().withPath("/api/v1/namespaces/custom/configmaps/cm2").andReturn(200,
new ConfigMapBuilder().build()).once();
+ Exchange ex = template.request("direct:getConfigMap", new Processor() {
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME,
"custom");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME,
"cm1");
}
});
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> camel-kubernetes getConfigMap does not use Namespace Header
> -----------------------------------------------------------
>
> Key: CAMEL-12891
> URL: https://issues.apache.org/jira/browse/CAMEL-12891
> Project: Camel
> Issue Type: Bug
> Components: camel-kubernetes
> Affects Versions: 2.21.2, 2.22.0
> Environment: Kubernetes 1.9.11
> Reporter: Bob Paulin
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 2.22.2, 2.23.0, 2.21.4
>
>
> The getConfigMap operation does not return a map in a namespace when the
> CamelKubernetesNamespaceName being specified. This header should be used by
> getConfigMap when it is present.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)