Skip to content

Commit

Permalink
refactor: Move pkg
Browse files Browse the repository at this point in the history
Moved senders directory to notifier directory, because senders have no sense without notifier, senders is a part of notifier. Also resolve some warnings
  • Loading branch information
Dimedrolity committed Nov 17, 2022
1 parent 82fdc94 commit b62ddd7
Show file tree
Hide file tree
Showing 66 changed files with 32 additions and 38 deletions.
28 changes: 14 additions & 14 deletions notifier/registrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ package notifier

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders/discord"
"github.com/moira-alert/moira/notifier/senders/mail"
"github.com/moira-alert/moira/notifier/senders/mattermost"
"github.com/moira-alert/moira/notifier/senders/msteams"
"github.com/moira-alert/moira/notifier/senders/opsgenie"
"github.com/moira-alert/moira/notifier/senders/pagerduty"
"github.com/moira-alert/moira/notifier/senders/pushover"
"github.com/moira-alert/moira/notifier/senders/script"
"github.com/moira-alert/moira/notifier/senders/selfstate"
"github.com/moira-alert/moira/notifier/senders/slack"
"github.com/moira-alert/moira/notifier/senders/telegram"
"github.com/moira-alert/moira/notifier/senders/twilio"
"github.com/moira-alert/moira/notifier/senders/victorops"
"github.com/moira-alert/moira/notifier/senders/webhook"
"strings"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders/discord"
"github.com/moira-alert/moira/senders/mail"
"github.com/moira-alert/moira/senders/mattermost"
"github.com/moira-alert/moira/senders/msteams"
"github.com/moira-alert/moira/senders/opsgenie"
"github.com/moira-alert/moira/senders/pagerduty"
"github.com/moira-alert/moira/senders/pushover"
"github.com/moira-alert/moira/senders/script"
"github.com/moira-alert/moira/senders/selfstate"
"github.com/moira-alert/moira/senders/slack"
"github.com/moira-alert/moira/senders/telegram"
"github.com/moira-alert/moira/senders/twilio"
"github.com/moira-alert/moira/senders/victorops"
"github.com/moira-alert/moira/senders/webhook"
// "github.com/moira-alert/moira/senders/kontur"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package discord
import (
"bytes"
"fmt"
"github.com/moira-alert/moira/notifier/senders"
"net/http"
"regexp"
"strings"

"github.com/bwmarrin/discordgo"
"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
)

const (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ some other text _italics text_`,
}

Convey("Make message", t, func() {
message := sender.makeMessage(generateTestEvents(10, trigger.ID), contact, trigger, [][]byte{[]byte{1, 0, 1}}, true) //nolint
message := sender.makeMessage(generateTestEvents(10, trigger.ID), contact, trigger, [][]byte{{1, 0, 1}}, true) //nolint
So(message.GetHeader("From")[0], ShouldEqual, sender.From)
So(message.GetHeader("To")[0], ShouldEqual, contact.Value)

Expand Down Expand Up @@ -107,7 +107,7 @@ func TestEmptyTriggerID(t *testing.T) {
}

Convey("Make message", t, func() {
message := sender.makeMessage(generateTestEvents(10, trigger.ID), contact, trigger, [][]byte{[]byte{1, 0, 1}}, true) //nolint
message := sender.makeMessage(generateTestEvents(10, trigger.ID), contact, trigger, [][]byte{{1, 0, 1}}, true) //nolint
So(message.GetHeader("From")[0], ShouldEqual, sender.From)
So(message.GetHeader("To")[0], ShouldEqual, contact.Value)
messageStr := new(bytes.Buffer)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package mattermost
import (
"crypto/tls"
"fmt"
"github.com/moira-alert/moira/notifier/senders"
"net/http"
"strconv"
"strings"
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"

"github.com/mattermost/mattermost-server/v6/model"
"github.com/moira-alert/moira"
)

// Sender posts messages to Mattermost chat.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
package mattermost_test

import (
"github.com/moira-alert/moira/notifier/senders/mattermost"
"testing"
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders/mattermost"

. "github.com/smartystreets/goconvey/convey"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package mattermost_test

import (
"github.com/moira-alert/moira/notifier/senders/mattermost"
"testing"

"github.com/moira-alert/moira/senders/mattermost"

. "github.com/smartystreets/goconvey/convey"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"bytes"
"context"
"fmt"
"github.com/moira-alert/moira/notifier/senders"
"strings"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
"github.com/opsgenie/opsgenie-go-sdk-v2/alert"
blackfriday "github.com/russross/blackfriday/v2"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package opsgenie

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders"
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
"github.com/opsgenie/opsgenie-go-sdk-v2/alert"
"github.com/opsgenie/opsgenie-go-sdk-v2/client"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package pagerduty

import (
"github.com/moira-alert/moira/notifier/senders"
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
)

// Sender implements moira sender interface for PagerDuty.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion senders/slack/slack.go → notifier/senders/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package slack
import (
"bytes"
"fmt"
"github.com/moira-alert/moira/notifier/senders"
"strconv"
"strings"
"time"

slackdown "github.com/karriereat/blackfriday-slack"
"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
blackfriday "github.com/russross/blackfriday/v2"

"github.com/slack-go/slack"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package telegram_test

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders/telegram"
"testing"
"time"

logging "github.com/moira-alert/moira/logging/zerolog_adapter"
"github.com/moira-alert/moira/senders/telegram"
. "github.com/smartystreets/goconvey/convey"
)

Expand Down
2 changes: 1 addition & 1 deletion senders/twilio/sms.go → notifier/senders/twilio/sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type twilioSenderSms struct {
twilioSender
}

func (sender *twilioSenderSms) SendEvents(events moira.NotificationEvents, contact moira.ContactData, trigger moira.TriggerData, plots [][]byte, throttled bool) error {
func (sender *twilioSenderSms) SendEvents(events moira.NotificationEvents, contact moira.ContactData, trigger moira.TriggerData, _ [][]byte, throttled bool) error {
message := sender.buildMessage(events, trigger, throttled)
sender.logger.Debugf("Calling twilio sms api to phone %s and message body %s", contact.Value, message)
twilioMessage, err := twilio.NewMessage(sender.client, sender.APIFromPhone, contact.Value, twilio.Body(message))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type twilioSenderVoice struct {
twimletsEcho bool
}

func (sender *twilioSenderVoice) SendEvents(events moira.NotificationEvents, contact moira.ContactData, trigger moira.TriggerData, plots [][]byte, throttled bool) error {
func (sender *twilioSenderVoice) SendEvents(_ moira.NotificationEvents, contact moira.ContactData, trigger moira.TriggerData, _ [][]byte, _ bool) error {
voiceURL := sender.buildVoiceURL(trigger)
twilioCall, err := twilio.NewCall(sender.client, sender.APIFromPhone, contact.Value, twilio.Callback(voiceURL))
if err != nil {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package victorops

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders/victorops/api"
"strings"
"time"

stripmd "github.com/writeas/go-strip-markdown"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders/victorops/api"
)

// SendEvents implements Sender interface Send
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package victorops

import (
"github.com/moira-alert/moira/notifier/senders/victorops/api"
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/moira-alert/moira/senders/victorops/api"

"github.com/moira-alert/moira"
mock_moira_alert "github.com/moira-alert/moira/mock/moira-alert"
. "github.com/smartystreets/goconvey/convey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package victorops

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders/victorops/api"
"time"

"github.com/moira-alert/moira/senders/victorops/api"

"github.com/moira-alert/moira"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package victorops

import (
"fmt"
"github.com/moira-alert/moira/notifier/senders/victorops/api"
"testing"
"time"

"github.com/golang/mock/gomock"
"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders/victorops/api"

logging "github.com/moira-alert/moira/logging/zerolog_adapter"
mock_moira_alert "github.com/moira-alert/moira/mock/moira-alert"
. "github.com/smartystreets/goconvey/convey"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b62ddd7

Please sign in to comment.