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

[#196][feat] add where condition to manifests #213

Merged
merged 1 commit into from
Jul 24, 2022
Merged

[#196][feat] add where condition to manifests #213

merged 1 commit into from
Jul 24, 2022

Conversation

icepuma
Copy link
Member

@icepuma icepuma commented Jul 23, 2022

  • use rhai scripts to use condition
    • if the rhai script resolves to true -> run manifest
    • if the rhai script fails or resolves to false -> don't run manifest
  • context variables can be used

I'm submitting a

  • bug fix
  • feature

What is the motivation / use case for changing the behavior?

If a manifest runs or not depends on the dry run option. Manifest execution can be fine tuned by adding where conditions.

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2022

Codecov Report

Merging #213 (6c82b2a) into main (24adc3d) will decrease coverage by 0.26%.
The diff coverage is 7.14%.

@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
- Coverage   46.98%   46.71%   -0.27%     
==========================================
  Files          67       67              
  Lines        2088     2102      +14     
==========================================
+ Hits          981      982       +1     
- Misses       1107     1120      +13     
Impacted Files Coverage Δ
app/src/commands/apply.rs 0.00% <0.00%> (ø)
lib/src/actions/file/link.rs 92.85% <ø> (ø)
lib/src/manifests/mod.rs 73.07% <ø> (ø)
lib/src/contexts/mod.rs 77.63% <100.00%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 24adc3d...6c82b2a. Read the comment docs.

@rawkode
Copy link
Member

rawkode commented Jul 23, 2022

This is a different implementation that we use for actions and I'm wondering if we need them to be comparable?

So far, for actions we support a single string and that string can be evaluated with multiples only within that string, such as:

variables.name == "David" && variables.location != "The Moon"

We should make manifests do this, or update actions to be a list too?

Or maybe it's not a big deal. I'd like to hear thoughts

@icepuma
Copy link
Member Author

icepuma commented Jul 23, 2022

Yeah, @theowenyoung was asking for or operations. Therefore I will make it a one-liner. Then it's possible to let the user decide the logic behind where.

@icepuma
Copy link
Member Author

icepuma commented Jul 23, 2022

The good thing is, that yaml supports multiline strings and therefore more or less the thing I tried to model with the multiple where conditions

@icepuma
Copy link
Member Author

icepuma commented Jul 24, 2022

I changed from multiple conditions to one. Feels better and more consistent.

@icepuma icepuma changed the title [#196][feat] add where conditions to manifests [#196][feat] add where condition to manifests Jul 24, 2022
@icepuma icepuma marked this pull request as ready for review July 24, 2022 20:16
@icepuma icepuma requested a review from rawkode July 24, 2022 20:16
tests/basic_usage.rs Outdated Show resolved Hide resolved
- use rhai scripts to use condition
  - if the rhai script resolves to true -> run manifest
  - if the rhai script fails or resolves to false -> don't run manifest
- context variables can be used
Copy link
Member

@rawkode rawkode left a comment

Choose a reason for hiding this comment

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

If the build passes, merge at your own convenience. Great addition.

@icepuma icepuma merged commit 669cdf8 into comtrya:main Jul 24, 2022
@icepuma icepuma deleted the where branch July 26, 2022 10:03
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.

None yet

3 participants