# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: exec-sink
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "3.21.0"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4wIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiB3aWR0aD0iMTI4MC4wMDAwMDBwdCIgaGVpZ2h0PSIxMDEyLjAwMDAwMHB0IiB2aWV3Qm94PSIwIDAgMTI4MC4wMDAwMDAgMTAxMi4wMDAwMDAiCiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0Ij4KPG1ldGFkYXRhPgpDcmVhdGVkIGJ5IHBvdHJhY2UgMS4xNSwgd3JpdHRlbiBieSBQZXRlciBTZWxpbmdlciAyMDAxLTIwMTcKPC9tZXRhZGF0YT4KPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsMTAxM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MTE0NyAxNzUgMTE1NiAxNzYKMTMyMCAyNTQgMjY0IDEyNSA0NDIgMzY1IDQ4NSA2NDkgNiAzNyA4IDE2NiA2IDI4NyBsLTMgMjIwIC05MSA0MzAgYy04NyA0MTIKLTE5MyA5MTkgLTM0MiAxNjMwIC0zOCAxODIgLTE0MSA2NzQgLTIyOSAxMDk1IC04OCA0MjEgLTI2NCAxMjYyIC0zOTEgMTg2OQotMTI3IDYwNyAtMjU1IDEyMjIgLTI4NSAxMzY1IC0zMSAxNDQgLTY3IDMwMSAtODEgMzUwIC04OSAzMTAgLTMzMCA1NDYgLTY0Mgo2MjcgLTc2IDIwIC0yNjQgMzMgLTMyNyAyM3ogbTIzODIgLTc3MTYgYy0zIC03IC01IC0yIC01IDEyIDAgMTQgMiAxOSA1IDEzIDIKLTcgMiAtMTkgMCAtMjV6IG0tODU0MiAtMTQ5OCBjMTAgLTExIDE2IC0yMCAxMyAtMjAgLTMgMCAtMTMgOSAtMjMgMjAgLTEwIDExCi0xNiAyMCAtMTMgMjAgMyAwIDEzIC05IDIzIC0yMHoiLz4KPC9nPgo8L3N2Zz4K"
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Exec"
    camel.apache.org/kamelet.namespace: "System"
  labels:
    camel.apache.org/kamelet.type: sink
spec:
  definition:
    title: Exec Sink
    description: |-
      Execute system commands

      The Kamelet expects the following headers to be set:

      - `args` / `ce-args`: as the args to be set on the executable.

      If the header won't be set the executable will be run without arguments.
    required:
    - executable
    type: object
    properties:
      executable:
        title: Executable Command
        description: The command to execute
        type: string
  dependencies:
    - "camel:core"
    - "camel:exec"
    - "camel:kamelet"
  template:
    from:
      uri: kamelet:source
      steps:
      - choice:
          when:
          - simple: "${header[args]}"
            steps:
            - set-header:
                name: CamelExecCommandArgs
                simple: "${header[args]}"
          - simple: "${header[ce-args]}"
            steps:
            - set-header:
                name: CamelExecCommandArgs
                simple: "${header[ce-args]}"
      - to:
          uri: "exec:{{executable}}"
      - set-body:
          simple: "${body.stdout}"