Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

get triggerName in template #417

Open
dexter-hwang opened this issue Jul 5, 2022 · 0 comments
Open

get triggerName in template #417

dexter-hwang opened this issue Jul 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@dexter-hwang
Copy link

dexter-hwang commented Jul 5, 2022

Summary

I'm configuring a webhook-forwarder layer for multiple sources and multiple targets.

so, I made all triggers use same template like this.

  template.app-common: |
    webhook:
      forwarder:
        method: POST
        body: |-
          {
            "app": {
              "metadata": {
                "name": "{{.app.metadata.name}}"
              },
              "status": {
                "health": {
                  "status": "{{.app.status.health.status}}"
                },
                "operationState": {
                  "operation": {
                    "sync": {
                      "revision": "{{.app.status.operationState.operation.sync.revision}}"
                    }
                  },
                  "finishedAt": "{{.app.status.operationState.finishedAt}}",
                  "message": "{{.app.status.operationState.message}}",
                  "phase": "{{.app.status.operationState.phase}}"
                },
                "sync": {
                  "status": "{{.app.status.sync.status}}",
                  "revision": "{{.app.status.sync.revision}}"
                },
                "conditions": [
                  {{range $index, $c := .app.status.conditions}}
                  {{if ne $index 0}},{{end}}
                  {
                    "type": "{{$c.type}}",
                    "message": "{{$c.message}}"
                  }
                  {{end}}
                ]
              }
            },
            "context": {
              "argocdUrl": "{{.context.argocdUrl}}"
            }
          }
  trigger.on-deployed:  |
    - when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
      oncePer: app.status.sync.revision
      send: [app-common]
  trigger.on-health-degraded: |
    - when: app.status.health.status == 'Degraded'
      send: [app-common]
  trigger.on-sync-failed: |
    - when: app.status.operationState.phase in ['Error', 'Failed']
      send: [app-common]
  trigger.on-sync-running: |
    - when: app.status.operationState.phase in ['Running']
      send: [app-common]
  trigger.on-sync-status-unknown: |
    - when: app.status.sync.status == 'Unknown'
      send: [app-common]
  trigger.on-sync-succeeded: |
    - when: app.status.operationState.phase in ['Succeeded']
      send: [app-common]

but, in template cannot figure out that what trigger is triggering the webhook.

I want to get trigger name in template something like this..

  template.app-common: |
    webhook:
      forwarder:
        method: POST
        body: |-
          {
            "app": {
              "metadata": {
                "name": "{{.app.metadata.name}}",
                "trigger": "{{.triggerName}}" // on-sync-failed, on-sync-succeeded ....
              },

Use Cases

this feature will be useful when managing a custom webhook template.


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@dexter-hwang dexter-hwang added the enhancement New feature or request label Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant