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

feat: add IN and NOTIN to step condition operators #129

Merged
merged 3 commits into from
May 6, 2020

Conversation

wI2L
Copy link
Contributor

@wI2L wI2L commented Apr 16, 2020

These operators allows to check that a value is present or not
in a list of values. The allowed/disabled values are represented
as a comma-separated string.

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Feature.

  • What is the current behavior? (You can also link to an open issue here)

A value cannot be checked against a list of potential candidates in a step condition.

  • What is the new behavior (if this is a feature change)?

This permits to assert that a value is present or not in a list of acceptable values.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No.

@wI2L wI2L requested review from loopfz and rbeuque74 April 16, 2020 12:13
func matchList(valStr, expStr string) bool {
values := strings.Split(expStr, ",")
for _, v := range values {
if valStr == v {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always paranoid about whitespaces messing up comparisons.
Should we TrimSpace(v) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If complexity is a problem, we could have a Prepare() step on resolution load

conditions:
- type: check
if:
- value: '{{.step.this.output.items}}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the condition is backwards, isnt it?

foo IS IN foo,bar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it doesn't match the code. Fixing.

@loopfz
Copy link
Member

loopfz commented Apr 16, 2020

Looks good overall, 2 issues to address imo:

  • whitespace trim (see earlier comment)
  • update doc to cover the new operators, mentionning specifically the order of operands (expected vs value)

@wI2L wI2L force-pushed the collection-operators branch 2 times, most recently from 338b8bc to e57e9a6 Compare April 17, 2020 09:24
@wI2L wI2L marked this pull request as ready for review April 17, 2020 09:34
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
loopfz
loopfz previously approved these changes Apr 20, 2020
Copy link
Member

@loopfz loopfz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ovh-cds
Copy link
Collaborator

ovh-cds commented Apr 21, 2020

CDS Report test#600.0 ✘

  • Stage 1
    • Test ✘

@rbeuque74 rbeuque74 self-requested a review April 28, 2020 14:01
Copy link
Member

@rbeuque74 rbeuque74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the feature.

Missing: patch of template-schema.json to include the new feature: https://github.com/ovh/utask/blob/master/hack/template-schema.json#L656

Test doesn't pass.

@ovh-cds
Copy link
Collaborator

ovh-cds commented May 6, 2020

CDS Report test#648.0 ✘

  • Stage 1
    • Test ✘

wI2L and others added 2 commits May 6, 2020 15:45
These operators allows to check that a value is present or not
in a list of values. The allowed/disabled values are represented
as a comma-separated string.

Signed-off-by: William Poussier <william.poussier@gmail.com>
Co-Authored-By: Thomas Schaffer <thomas.schaffer@corp.ovh.com>
Signed-off-by: Thomas Schaffer <thomas.schaffer@corp.ovh.com>
Signed-off-by: William Poussier <william.poussier@gmail.com>
@loopfz loopfz merged commit c109b1f into master May 6, 2020
@loopfz loopfz deleted the collection-operators branch July 24, 2020 09:37
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

Successfully merging this pull request may close these issues.

4 participants