Skip to content

Commit

Permalink
add remove subscriptions flag
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Dec 27, 2023
1 parent ad9cd9b commit 8c736b0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ var (
plotting = flag.Bool("plotting", false, "enable images in all notifications")
)

var (
removeSubscriptions = flag.String("remove-subscriptions", "", "Remove given comma-separated subscriptions.")
)

var (
cleanupUsers = flag.Bool("cleanup-users", false, "Disable/delete contacts and subscriptions of missing users")
cleanupLastChecks = flag.Bool("cleanup-last-checks", false, "Delete abandoned triggers last checks.")
Expand Down Expand Up @@ -320,6 +324,18 @@ func main() { //nolint
}
logger.Info().Msg("Dump was pushed")
}

if *removeSubscriptions != "" {
subscriptionIDs := strings.Split(*removeSubscriptions, ",")
for _, subscriptionID := range subscriptionIDs {
if err := database.RemoveSubscription(subscriptionID); err != nil {
logger.Error().
Error(err).
Msg("Failed to remove subscription")
}
}
logger.Info().Msg("Delition of subscriptions finished")
}
}

func GetDumpBriefInfo(dump *dto.TriggerDump) string {
Expand All @@ -334,7 +350,7 @@ func GetDumpBriefInfo(dump *dto.TriggerDump) string {
func initApp() (cleanupConfig, moira.Logger, moira.Database) {
flag.Parse()
if *printVersion {
fmt.Println("Moira - alerting system based on graphite data")
fmt.Println("Moira - alerting system based on graphite or prometheus data")
fmt.Println("Version:", MoiraVersion)
fmt.Println("Git Commit:", GitCommit)
fmt.Println("Go Version:", GoVersion)
Expand Down

0 comments on commit 8c736b0

Please sign in to comment.