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(file) allow condition to only check for file existence #382

Merged
merged 2 commits into from
Nov 20, 2021

Conversation

dduportal
Copy link
Contributor

@dduportal dduportal commented Nov 17, 2021

Fix #290

No need for a specific atttribute: only have to disable the source input in condition.
2 examples added in the PR to show how to use it + test units to cover additional cases.

It also add improved output for end user:

  • info message for each condition to report if it passed, did not pass, or errored (easier to read when multiple conditions)
  • more debug messages on the text package and file condition

Test

To test this pull request, you can run the following commands:

go build -o ./dist/updatecli
./dist/updatecli diff --config ./examples/updateCli.generic/file.yaml

Additional Information

Tradeoff

Potential improvement

@dduportal dduportal added condition Modify condition resource enhancement New feature or request resource-file Resource of kind File labels Nov 17, 2021
@dduportal dduportal added this to the 0.15.0 milestone Nov 17, 2021
@dduportal dduportal modified the milestones: 0.15.0, 0.16.0 Nov 18, 2021
Signed-off-by: Damien Duportal <damien.duportal@gmail.com>
pkg/core/text/main.go Outdated Show resolved Hide resolved
if passing {
logrus.Infof("%s Condition on file %q passed", result.SUCCESS, f.spec.File)
} else {
logrus.Infof("%s Condition on file %q did not pass", result.FAILURE, f.spec.File)
Copy link
Member

Choose a reason for hiding this comment

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

What would you think to use a different message than failiure?

Suggested change
logrus.Infof("%s Condition on file %q did not pass", result.FAILURE, f.spec.File)
logrus.Infof("%s Condition on file %q did not pass", result.ATTENTION, f.spec.File)

"\u26A0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels weird to use « attention » since it is the symbol used when a target changes a file. Might be something to reconsider overall: choosing 2 symbols for failure and not passing, and 2 other symbols for « success » and « changed »

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the fact of sharing the same error symbol is why I took care of having 2 really different text messages to easily discern failure from condition not passing. Maybe we could remove the « cross » from failure since it generate a clear error message in red.

olblak
olblak previously approved these changes Nov 19, 2021
Copy link
Member

@olblak olblak left a comment

Choose a reason for hiding this comment

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

Excepted minor comment, this pull request looks great to me. Thanks @dduportal for the improvement

@olblak
Copy link
Member

olblak commented Nov 19, 2021

Feel free to merge once you are ready

Co-authored-by: Olivier Vernin <me@olblak.com>
@dduportal dduportal merged commit 65a6443 into updatecli:main Nov 20, 2021
@dduportal dduportal deleted the gh-290 branch November 20, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
condition Modify condition resource enhancement New feature or request resource-file Resource of kind File
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request [Resource "File"] allow condition to only check for existence of a file (and not the value)
2 participants