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

Allow complex precondition conditions #598

Open
yohamta opened this issue Jul 4, 2024 · 0 comments
Open

Allow complex precondition conditions #598

yohamta opened this issue Jul 4, 2024 · 0 comments
Labels
enhancement New feature to be implemented

Comments

@yohamta
Copy link
Collaborator

yohamta commented Jul 4, 2024

Brief overview

We aim to support more complex conditions in the preconditions field.

Proposed solution: Inline script

We suggest allowing the use of JavaScript in the condition field.

Javascript

preconditions:
  - condition: "$EXIT_CODE == 1 || $EXIT_CODE == 2"
    expected: true

Alternative Approaches

Option 1: Functional Programming

preconditions:
  - condition: "(or (eq $EXIT_CODE 1) (eq $EXIT_CODE 2))"
    expected: true

Option 2: Logic Programming

preconditions:
  - condition: "member($EXIT_CODE, [1, 2])"
    expected: true

Alternative solution: operator field

preconditions:
  - condition: "$EXIT_CODE"
     operator: "ne"
    expected: "2"

When operator field is not provided, it will be handled as "eq". Valid values are as follows:

  • != or ne
  • == or eq
  • >= or ge
  • > or gt
  • <= or le
  • < or lt
  • OR or AND
  • conditions

Complex example that matches only when EXIT_CODE is neither 1 or 2:

preconditions:
    operator: "AND"
    conditions:
    - condition: "$EXIT_CODE"
       operator: "ne"
      expected: "1"
    - condition: "$EXIT_CODE"
       operator: "ne"
      expected: "2"
@yohamta yohamta added the enhancement New feature to be implemented label Jul 4, 2024
@yohamta yohamta changed the title Add optional operator field to precondition setting Add optional operator field to precondition setting Jul 4, 2024
@yohamta yohamta changed the title Add optional operator field to precondition setting Allow complex precondition conditions Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature to be implemented
Projects
None yet
Development

No branches or pull requests

1 participant