StackStorm / st2docs

StackStorm Documentation.
https://docs.stackstorm.com/
64 stars 170 forks source link

Could criteria not be a list of tiggers? #1169

Open Rooba opened 7 months ago

Rooba commented 7 months ago

In the docs --

Due to a issue^1 in PyYAML, criteria keys must be unique. This sometimes becomes relevant when you want to apply different operators (like contains and ncontains) to the same trigger data:

criteria:
  trigger.payload.commit.tags:  # duplicate key - ignored!
    type: ncontains
    pattern: StackStorm
  trigger.payload.commit.tags:  # duplicate key - evaluated
    type: contains
    pattern: pull request
  trigger.payload.commit.message:  # unique key - evaluated
    type: ncontains
    pattern: ST2

I would think the following would be a fairly simple way to get around that issue

criteria:
  - trigger.payload.commit.tags:
      type: ncontains
      pattern: StackStorm
  - trigger.payload.commit.tags:
      type: contains
      pattern: pull request
  - trigger.payload.commit.message:
      type: ncontains
      pattern: ST2

or even something like

criteria:
  - trigger: payload.commit.tags
    type: ncontains
    pattern: StackStorm
  - trigger: payload.commit.tags 
    type: contains
    pattern: pull request
  - trigger: payload.commit.message
    type: ncontains
    pattern: ST2
fdrab commented 7 months ago

can't you write a regex for the tags criteria?