You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2023/12/05 11:05:46 UTC

[PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

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

   # Description
   
   <!--
   - Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   -->
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [x] I have run `mvn clean install -DskipTests` locally and I have committed all auto-generated changes
   
   <!--
   You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #12317:
URL: https://github.com/apache/camel/pull/12317#issuecomment-1840600928

   It should be ok now.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415401244


##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobEndpoint.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConfiguration;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.spi.UriEndpoint;
+
+import static org.apache.camel.component.kubernetes.KubernetesConstants.SCHEME_CRON_JOB;
+
+/**
+ * Perform operations on Kubernetes CronJob.
+ */
+@UriEndpoint(firstVersion = "4.3.0", scheme = SCHEME_CRON_JOB, title = "Kubernetes Cronjob",

Review Comment:
   so it's false.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415399705


##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobEndpoint.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConfiguration;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.spi.UriEndpoint;
+
+import static org.apache.camel.component.kubernetes.KubernetesConstants.SCHEME_CRON_JOB;
+
+/**
+ * Perform operations on Kubernetes CronJob.
+ */
+@UriEndpoint(firstVersion = "4.3.0", scheme = SCHEME_CRON_JOB, title = "Kubernetes Cronjob",

Review Comment:
   there is no consumer



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12317:
URL: https://github.com/apache/camel/pull/12317#issuecomment-1840527975

   :robot: The Apache Camel test robot will run the tests for you :+1:


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415397842


##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobProducer.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import java.util.Map;
+import java.util.function.Function;
+
+import io.fabric8.kubernetes.api.model.batch.v1.*;
+import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.Resource;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.component.kubernetes.KubernetesOperations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.support.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.kubernetes.KubernetesHelper.prepareOutboundMessage;
+
+public class KubernetesCronJobProducer extends DefaultProducer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(KubernetesCronJobProducer.class);
+
+    public KubernetesCronJobProducer(AbstractKubernetesEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public AbstractKubernetesEndpoint getEndpoint() {
+        return (AbstractKubernetesEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String operation;
+
+        if (ObjectHelper.isEmpty(getEndpoint().getKubernetesConfiguration().getOperation())) {
+            operation = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_OPERATION, String.class);
+        } else {
+            operation = getEndpoint().getKubernetesConfiguration().getOperation();
+        }
+
+        switch (operation) {
+
+            case KubernetesOperations.LIST_CRON_JOB_OPERATION:
+                doList(exchange);
+                break;
+
+            case KubernetesOperations.LIST_CRON_JOB_BY_LABELS_OPERATION:
+                doListCronJobByLabel(exchange);
+                break;
+
+            case KubernetesOperations.GET_CRON_JOB_OPERATION:
+                doGetCronJob(exchange);
+                break;
+
+            case KubernetesOperations.CREATE_CRON_JOB_OPERATION:
+                doCreateCronJob(exchange);
+                break;
+
+            case KubernetesOperations.UPDATE_CRON_JOB_OPERATION:
+                doUpdateCronJob(exchange);
+                break;
+
+            case KubernetesOperations.DELETE_CRON_JOB_OPERATION:
+                doDeleteCronJob(exchange);
+                break;
+
+            default:
+                throw new IllegalArgumentException("Unsupported operation " + operation);
+        }
+    }
+
+    protected void doList(Exchange exchange) {
+        CronJobList cronJobList = getEndpoint().getKubernetesClient().batch().v1().cronjobs().list();
+
+        prepareOutboundMessage(exchange, cronJobList.getItems());
+    }
+
+    protected void doListCronJobByLabel(Exchange exchange) {
+        Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_LABELS, Map.class);
+        if (ObjectHelper.isEmpty(labels)) {
+            LOG.error("List CronJob by labels require specify a labels set");
+            throw new IllegalArgumentException("Cron Job by labels require specify a labels set");
+        }
+
+        MixedOperation<CronJob, CronJobList, Resource<CronJob>> cronJobs
+                = getEndpoint().getKubernetesClient().batch().v1().cronjobs();
+
+        CronJobList jobList = cronJobs.withLabels(labels).list();
+
+        prepareOutboundMessage(exchange, jobList.getItems());
+    }
+
+    protected void doGetCronJob(Exchange exchange) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("Get a specific cronjob require specify a cronjob name");
+            throw new IllegalArgumentException("Get a specific cronjob require specify a cronnjob name");
+        }
+        if (ObjectHelper.isEmpty(namespaceName)) {
+            LOG.error("Get a specific cronjob require specify a namespace name");
+            throw new IllegalArgumentException("Get a specific cronjob require specify a namespace name");
+        }
+        CronJob cronJob = getEndpoint().getKubernetesClient().batch().v1().cronjobs().inNamespace(namespaceName)
+                .withName(cronjobName).get();
+
+        prepareOutboundMessage(exchange, cronJob);
+    }
+
+    protected void doUpdateCronJob(Exchange exchange) {
+        doCreateOrUpdateCronJob(exchange, "Update", Resource::update);
+    }
+
+    protected void doCreateCronJob(Exchange exchange) {
+        doCreateOrUpdateCronJob(exchange, "Create", Resource::create);
+    }
+
+    private void doCreateOrUpdateCronJob(
+            Exchange exchange, String operationName, Function<Resource<CronJob>, Object> operation) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        CronJobSpec cronjobSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_SPEC, CronJobSpec.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("{} a specific cronjob require specify a cronjob name", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a cronjob name", operationName));
+        }
+        if (ObjectHelper.isEmpty(namespaceName)) {
+            LOG.error("{} a specific cronjob require specify a namespace name", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a namespace name", operationName));
+        }
+        if (ObjectHelper.isEmpty(cronjobSpec)) {
+            LOG.error("{} a specific cronjob require specify a cronjob spec bean", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a cronjob spec bean", operationName));
+        }
+        Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_LABELS, Map.class);
+        CronJob cronjobCreating = new CronJobBuilder().withNewMetadata().withName(cronjobName).withLabels(labels).endMetadata()
+                .withSpec(cronjobSpec).build();
+        Object cronJob = operation.apply(
+                getEndpoint().getKubernetesClient().batch().v1().cronjobs().inNamespace(namespaceName)
+                        .resource(cronjobCreating));
+
+        prepareOutboundMessage(exchange, cronJob);
+    }
+
+    protected void doDeleteCronJob(Exchange exchange) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("Delete a specific cronjob require specify a cronjob name");

Review Comment:
   Same, it needs to be reviewed everywhere.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415419437


##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobEndpoint.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConfiguration;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.spi.UriEndpoint;
+
+import static org.apache.camel.component.kubernetes.KubernetesConstants.SCHEME_CRON_JOB;
+
+/**
+ * Perform operations on Kubernetes CronJob.
+ */
+@UriEndpoint(firstVersion = "4.3.0", scheme = SCHEME_CRON_JOB, title = "Kubernetes Cronjob",

Review Comment:
   Ah yeah my bad, should be producerOnly = true



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12317:
URL: https://github.com/apache/camel/pull/12317#issuecomment-1840527261

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :robot: CI automation will test this PR automatically.
   
   :camel: Apache Camel Committers, please review the following items:
   
   * First-time contributors **require MANUAL approval** for the GitHub Actions to run
   
   * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
   
   * You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
   
   * Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary. 
   
   * :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #12317:
URL: https://github.com/apache/camel/pull/12317#issuecomment-1840527255

   /component-test kubernetes


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415388870


##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobProducer.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import java.util.Map;
+import java.util.function.Function;
+
+import io.fabric8.kubernetes.api.model.batch.v1.*;
+import io.fabric8.kubernetes.client.dsl.MixedOperation;
+import io.fabric8.kubernetes.client.dsl.Resource;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.component.kubernetes.KubernetesOperations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.support.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.kubernetes.KubernetesHelper.prepareOutboundMessage;
+
+public class KubernetesCronJobProducer extends DefaultProducer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(KubernetesCronJobProducer.class);
+
+    public KubernetesCronJobProducer(AbstractKubernetesEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public AbstractKubernetesEndpoint getEndpoint() {
+        return (AbstractKubernetesEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String operation;
+
+        if (ObjectHelper.isEmpty(getEndpoint().getKubernetesConfiguration().getOperation())) {
+            operation = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_OPERATION, String.class);
+        } else {
+            operation = getEndpoint().getKubernetesConfiguration().getOperation();
+        }
+
+        switch (operation) {
+
+            case KubernetesOperations.LIST_CRON_JOB_OPERATION:
+                doList(exchange);
+                break;
+
+            case KubernetesOperations.LIST_CRON_JOB_BY_LABELS_OPERATION:
+                doListCronJobByLabel(exchange);
+                break;
+
+            case KubernetesOperations.GET_CRON_JOB_OPERATION:
+                doGetCronJob(exchange);
+                break;
+
+            case KubernetesOperations.CREATE_CRON_JOB_OPERATION:
+                doCreateCronJob(exchange);
+                break;
+
+            case KubernetesOperations.UPDATE_CRON_JOB_OPERATION:
+                doUpdateCronJob(exchange);
+                break;
+
+            case KubernetesOperations.DELETE_CRON_JOB_OPERATION:
+                doDeleteCronJob(exchange);
+                break;
+
+            default:
+                throw new IllegalArgumentException("Unsupported operation " + operation);
+        }
+    }
+
+    protected void doList(Exchange exchange) {
+        CronJobList cronJobList = getEndpoint().getKubernetesClient().batch().v1().cronjobs().list();
+
+        prepareOutboundMessage(exchange, cronJobList.getItems());
+    }
+
+    protected void doListCronJobByLabel(Exchange exchange) {
+        Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_LABELS, Map.class);
+        if (ObjectHelper.isEmpty(labels)) {
+            LOG.error("List CronJob by labels require specify a labels set");
+            throw new IllegalArgumentException("Cron Job by labels require specify a labels set");
+        }
+
+        MixedOperation<CronJob, CronJobList, Resource<CronJob>> cronJobs
+                = getEndpoint().getKubernetesClient().batch().v1().cronjobs();
+
+        CronJobList jobList = cronJobs.withLabels(labels).list();
+
+        prepareOutboundMessage(exchange, jobList.getItems());
+    }
+
+    protected void doGetCronJob(Exchange exchange) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("Get a specific cronjob require specify a cronjob name");
+            throw new IllegalArgumentException("Get a specific cronjob require specify a cronnjob name");
+        }
+        if (ObjectHelper.isEmpty(namespaceName)) {
+            LOG.error("Get a specific cronjob require specify a namespace name");
+            throw new IllegalArgumentException("Get a specific cronjob require specify a namespace name");
+        }
+        CronJob cronJob = getEndpoint().getKubernetesClient().batch().v1().cronjobs().inNamespace(namespaceName)
+                .withName(cronjobName).get();
+
+        prepareOutboundMessage(exchange, cronJob);
+    }
+
+    protected void doUpdateCronJob(Exchange exchange) {
+        doCreateOrUpdateCronJob(exchange, "Update", Resource::update);
+    }
+
+    protected void doCreateCronJob(Exchange exchange) {
+        doCreateOrUpdateCronJob(exchange, "Create", Resource::create);
+    }
+
+    private void doCreateOrUpdateCronJob(
+            Exchange exchange, String operationName, Function<Resource<CronJob>, Object> operation) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        CronJobSpec cronjobSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_SPEC, CronJobSpec.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("{} a specific cronjob require specify a cronjob name", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a cronjob name", operationName));
+        }
+        if (ObjectHelper.isEmpty(namespaceName)) {
+            LOG.error("{} a specific cronjob require specify a namespace name", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a namespace name", operationName));
+        }
+        if (ObjectHelper.isEmpty(cronjobSpec)) {
+            LOG.error("{} a specific cronjob require specify a cronjob spec bean", operationName);
+            throw new IllegalArgumentException(
+                    String.format("%s a specific cronjob require specify a cronjob spec bean", operationName));
+        }
+        Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_LABELS, Map.class);
+        CronJob cronjobCreating = new CronJobBuilder().withNewMetadata().withName(cronjobName).withLabels(labels).endMetadata()
+                .withSpec(cronjobSpec).build();
+        Object cronJob = operation.apply(
+                getEndpoint().getKubernetesClient().batch().v1().cronjobs().inNamespace(namespaceName)
+                        .resource(cronjobCreating));
+
+        prepareOutboundMessage(exchange, cronJob);
+    }
+
+    protected void doDeleteCronJob(Exchange exchange) {
+        String cronjobName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CRON_JOB_NAME, String.class);
+        String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
+        if (ObjectHelper.isEmpty(cronjobName)) {
+            LOG.error("Delete a specific cronjob require specify a cronjob name");

Review Comment:
   Do not log and throw exception - only throw exception



##########
components/camel-kubernetes/src/main/docs/kubernetes-cronjob-component.adoc:
##########
@@ -0,0 +1,46 @@
+= Kubernetes Cronjob Component
+:doctitle: Kubernetes Cronjob
+:shortname: kubernetes-cronjob
+:artifactid: camel-kubernetes
+:description: Perform operations on Kubernetes CronJob.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Both producer and consumer are supported
+//Manually maintained attributes
+:group: Kubernetes
+:camel-spring-boot-name: kubernetes
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Kubernetes CronJob component is one of xref:kubernetes-summary.adoc[Kubernetes Components] which

Review Comment:
   There is no consumer



##########
components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/cronjob/KubernetesCronJobEndpoint.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kubernetes.cronjob;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.kubernetes.AbstractKubernetesEndpoint;
+import org.apache.camel.component.kubernetes.KubernetesConfiguration;
+import org.apache.camel.component.kubernetes.KubernetesConstants;
+import org.apache.camel.spi.UriEndpoint;
+
+import static org.apache.camel.component.kubernetes.KubernetesConstants.SCHEME_CRON_JOB;
+
+/**
+ * Perform operations on Kubernetes CronJob.
+ */
+@UriEndpoint(firstVersion = "4.3.0", scheme = SCHEME_CRON_JOB, title = "Kubernetes Cronjob",

Review Comment:
   consumerOnly = true



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd merged PR #12317:
URL: https://github.com/apache/camel/pull/12317


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20185 - Kubernetes CronJob Component [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #12317:
URL: https://github.com/apache/camel/pull/12317#discussion_r1415397551


##########
components/camel-kubernetes/src/main/docs/kubernetes-cronjob-component.adoc:
##########
@@ -0,0 +1,46 @@
+= Kubernetes Cronjob Component
+:doctitle: Kubernetes Cronjob
+:shortname: kubernetes-cronjob
+:artifactid: camel-kubernetes
+:description: Perform operations on Kubernetes CronJob.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Both producer and consumer are supported
+//Manually maintained attributes
+:group: Kubernetes
+:camel-spring-boot-name: kubernetes
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Kubernetes CronJob component is one of xref:kubernetes-summary.adoc[Kubernetes Components] which

Review Comment:
   I guess it's a copy paste and it's wrong even in other places. I'll check.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org