Skip to content

Commit

Permalink
fix: fix unsilencing by multiple labels (#24)
Browse files Browse the repository at this point in the history
* fix: fix unsilencing by multiple labels

* fix: fix unsilencing by multiple labels, part 2
  • Loading branch information
freak12techno authored Oct 11, 2023
1 parent d45d501 commit d34b65f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/app/silences_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"fmt"
"main/pkg/types/render"
"strings"

tele "gopkg.in/telebot.v3"
)
Expand All @@ -13,8 +14,9 @@ func (a *App) HandleDeleteSilence(c tele.Context) error {
Str("text", c.Text()).
Msg("Got new delete silence query")

args := c.Args()
if len(args) != 1 {
args := strings.SplitN(c.Text(), " ", 2)

if len(args) <= 1 {
return c.Reply("Usage: /unsilence <silence ID or labels>")
}

Expand All @@ -23,7 +25,7 @@ func (a *App) HandleDeleteSilence(c tele.Context) error {
return c.Reply(fmt.Sprintf("Error getting silence to delete: %s", silencesFetchErr))
}

silence, found, err := silences.FindByNameOrMatchers(args[0])
silence, found, err := silences.FindByNameOrMatchers(args[1])
if !found {
return c.Reply(fmt.Sprintf("Silence is not found by ID or matchers: %s", args[0]))
}
Expand Down Expand Up @@ -65,9 +67,9 @@ func (a *App) HandleAlertmanagerDeleteSilence(c tele.Context) error {
return c.Reply("Alertmanager is disabled.")
}

args := c.Args()
args := strings.SplitN(c.Text(), " ", 2)

if len(args) != 1 {
if len(args) <= 1 {
return c.Reply("Usage: /alertmanager_unsilence <silence ID or labels>")
}

Expand All @@ -76,7 +78,7 @@ func (a *App) HandleAlertmanagerDeleteSilence(c tele.Context) error {
return c.Reply(fmt.Sprintf("Error getting silence to delete: %s", silencesFetchErr))
}

silence, found, err := silences.FindByNameOrMatchers(args[0])
silence, found, err := silences.FindByNameOrMatchers(args[1])
if !found {
return c.Reply(fmt.Sprintf("Silence is not found by ID or matchers: %s", args[0]))
}
Expand Down

0 comments on commit d34b65f

Please sign in to comment.