pipe-cd / pipecd

The One CD for All {applications, platforms, operations}
https://pipecd.dev
Apache License 2.0
1.06k stars 149 forks source link

Support multiple value updates in EventWatcher #5088

Open tom-256 opened 2 months ago

tom-256 commented 2 months ago

What would you like to be added:

Enhance the event watcher feature to support multiple data updates in a single event registration, with the ability to associate specific data with specific file updates.

Example configuration:

eventWatcher:
  - matcher:
      name: multi-update
      labels:
        env: dev
        appName: helloworld
    handler:
      type: GIT_UPDATE
      config:
        replacements:
          - file: deployment.yaml
            yamlField: $.spec.template.spec.containers[0].image
            dataKey: image
          - file: config.yaml
            yamlField: $.data.version
            dataKey: version
          - file: ingress.yaml
            yamlField: $.spec.rules[0].host
            dataKey: hostname

Example command:

pipectl event register \
    --address=CONTROL_PLANE_API_ADDRESS \
    --api-key=API_KEY \
    --name=multi-update \
    --labels env=dev,appName=helloworld \
    --data image=gcr.io/pipecd/helloworld:v0.2.0 \
    --data version=1.2.3 \
    --data hostname=example.com

Why is this needed:

t-kikuc commented 2 months ago

Thank you for your great suggestion.

The (only one?) difficulty seems to be how to keep the compatibility of Event.data.

Probably, we have two ways: