-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Refactor: Move inTimeIntervals
from notify
to timeinterval
#3556
Conversation
Signed-off-by: gotjosh <[email protected]>
Signed-off-by: gotjosh <[email protected]>
@@ -478,6 +478,8 @@ func run() int { | |||
timeIntervals[ti.Name] = ti.TimeIntervals | |||
} | |||
|
|||
intervener := timeinterval.NewIntervener(timeIntervals) |
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.
I started moving the loop above into timeinterval
as well but quickly realised that we have an import problem - this is part of a larger problem and I'll address it in a separate PR.
I don't understand why the marshalling of config -> struct happens with structs that live in timeinterval
when this is generally done as part of theconfig
package.
if len(muteTimeIntervalNames) == 0 { | ||
return ctx, alerts, nil | ||
} |
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.
This guard clause was missing from this path.
Signed-off-by: gotjosh <[email protected]>
Signed-off-by: gotjosh <[email protected]>
@@ -659,3 +660,97 @@ func mustLoadLocation(name string) *time.Location { | |||
} | |||
return loc | |||
} | |||
|
|||
func TestIntervener_Mutes(t *testing.T) { |
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.
These tests are technically a duplicate of what we already have in notify
- I think they have some merit in being here as there might be more we want to test as part of this interface in the future (e.g. when we introduce the marker) and it gave me more confidence in the refactor.
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.
LGTM!
…metheus#3556) * Refactor: Move `inTimeIntervals` from `notify` to `timeinterval` There's absolutely no change of functionality here and I've expanded coverage for similar logic in both places. --------- Signed-off-by: gotjosh <[email protected]>
This should make implementing #3520 a bit cleaner given that we shouldn't need to introduce a direct dependency on marker in
notify
.There's absolutely no change of functionality here and I've expanded coverage for similar logic in both places.