Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support append/prepend operations for trigger parameters #315

Closed
marxarelli opened this issue Jul 26, 2019 · 1 comment
Closed

Support append/prepend operations for trigger parameters #315

marxarelli opened this issue Jul 26, 2019 · 1 comment

Comments

@marxarelli
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm looking to use Argo Events to respond to patchset-created events generated by Gerrit code review, creating a workflow that runs CI tasks based on a workflow file stored in the patchset's project repo. Gerrit does not include the full clone URL for the project in the event data and so it must be constructed from a prefix and the project name. However, this isn't possible given the fact that templateParameters can only overwrite values, not prepend/append existing ones.

Describe the solution you'd like
I would love a TriggerParameter.Operation field of some sort that supported keywords such as overwrite (default), prepend, and append. (Or something similar that achieves the desired functionality.) I'm down to author a pull request if that's helpful but I thought I'd ask first to judge how it might be received.

Describe alternatives you've considered
I've thought about writing a Gerrit plugin to include additional information in the event payload but then I'd have to write more Java and that's no fun.

Additional context
Full example of what I'm hoping for:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: gerrit-webhook-sensor
  labels:
    sensors.argoproj.io/sensor-controller-instanceid: argo-events
    argo-events-sensor-version: v0.10
spec:
  template:
    spec:
      containers:
        - name: "sensor"
          image: "argoproj/sensor"
          imagePullPolicy: Always
      serviceAccountName: argo-events-sa
  dependencies:
    - name: "gerrit-webhook-gateway:gerrit-events"
      filters:
        context:
          # source: { host: gerrit.git.wmflabs.org }
          contentType: application/json
        data:
          - path: type
            type: string
            value: [ patchset-created ]
  eventProtocol:
    type: "HTTP"
    http:
      port: "9300"
  triggers:
    - template:
        name: gerrit-webhook-workflow-trigger
        group: argoproj.io
        version: v1alpha1
        kind: Workflow
        source:
          git:
            url: https://gerrit.git.wmflabs.org/r/
            cloneDirectory: /src
            filePath: .pipeline/argo-workflow.yaml
            branch: REPLACED_WITH_PATCHSET_REF
      templateParameters:
        - src:
            event: "gerrit-webhook-gateway:gerrit-events"
            path: patchSet.ref
          dest: source.git.branch
        - src:
            event: "gerrit-webhook-gateway:gerrit-events"
            path: change.project
          dest: source.git.url
          operation: append # would <3 if i could do this
@VaibhavPage
Copy link
Contributor

Looks like a nice feature to have. I'll add it in the next release.

marxarelli added a commit to marxarelli/argo-events that referenced this issue Jul 26, 2019
Implemented an additional `operation` field for trigger parameters that
dictates what is to be done with the current value at `dest`. Possible
keyword values are:

 - `overwrite` Overwrite the current value (default/prior behavior)
 - `prepend` Prepend the value at `dest` with the value at `source.path`
 - `append` Append the value at `dest` with the value at `source.path`
VaibhavPage pushed a commit that referenced this issue Jul 27, 2019
* Support different trigger parameter operations (#315)

Implemented an additional `operation` field for trigger parameters that
dictates what is to be done with the current value at `dest`. Possible
keyword values are:

 - `overwrite` Overwrite the current value (default/prior behavior)
 - `prepend` Prepend the value at `dest` with the value at `source.path`
 - `append` Append the value at `dest` with the value at `source.path`

* Specified that `operation` is optional and generated openapi specs
juliev0 pushed a commit to juliev0/argo-events that referenced this issue Mar 29, 2022
…oj#319)

* Support different trigger parameter operations (argoproj#315)

Implemented an additional `operation` field for trigger parameters that
dictates what is to be done with the current value at `dest`. Possible
keyword values are:

 - `overwrite` Overwrite the current value (default/prior behavior)
 - `prepend` Prepend the value at `dest` with the value at `source.path`
 - `append` Append the value at `dest` with the value at `source.path`

* Specified that `operation` is optional and generated openapi specs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants