-
Notifications
You must be signed in to change notification settings - Fork 883
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 a label take precedence argument #1754
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congratulations on opening your first pull request! We'll get back to you as soon as possible. In the meantime, please make sure you've updated the documentation to reflect your changes and have added test automation as needed. Thanks! 🙏🏼
Fix dual blank line in arguments.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping out with this!
Env variable -> arguments
env variable -> arguments
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1754 +/- ##
==========================================
+ Coverage 67.60% 68.03% +0.43%
==========================================
Files 26 26
Lines 2380 2387 +7
==========================================
+ Hits 1609 1624 +15
+ Misses 672 664 -8
Partials 99 99
☔ View full report in Codecov by Sentry. |
I made a generalised helper to implement the logic, to make it easier to visually understand the logic/flow: func (c Container) getContainerOrGlobalBool(globalVal bool, label string, contPrecedence bool) bool {
if contVal, err := c.getBoolLabelValue(label); err != nil {
if !errors.Is(err, errorLabelNotFound) {
logrus.WithField("error", err).WithField("label", label).Warn("Failed to parse label value")
}
return globalVal
} else {
if contPrecedence {
return contVal
} else {
return contVal || globalVal
}
}
} Are you OK with me pushing this? I can also add some more tests to increase the coverage. |
Of course I'm, this is clearly better |
This PR add an argument to have labels take precedence over arguments.
By default watchtower have argument taking precedence over label which is not very convenient because arguments are global while label specific to container.
This is useful to allow specific container to be updated when monitor only is set to true
it close #1745
Test has been added to ensure that container are updated when monitor only is global set to true but set to false on the container level.
Documentation has been updated to include this new argument.
Additionally documentation has been updated to better describe the label enable argument which not only disable update but also disable monitoring