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 18, 2022
1 parent 82fdc94 commit 1fa56b2
Show file tree
Hide file tree
Showing 66 changed files with 39 additions and 38 deletions.
30 changes: 15 additions & 15 deletions notifier/registrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import (
"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"
"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"
// "github.com/moira-alert/moira/notifier/senders/kontur"
)

const (
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 @@ -9,7 +9,7 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
"github.com/moira-alert/moira/notifier/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)
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)
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 @@ -9,7 +9,7 @@ import (
"time"

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

"github.com/mattermost/mattermost-server/v6/model"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

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

. "github.com/smartystreets/goconvey/convey"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mattermost_test
import (
"testing"

"github.com/moira-alert/moira/senders/mattermost"
"github.com/moira-alert/moira/notifier/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 @@ -7,9 +7,10 @@ import (
"strings"

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

"github.com/opsgenie/opsgenie-go-sdk-v2/alert"
blackfriday "github.com/russross/blackfriday/v2"
"github.com/russross/blackfriday/v2"
)

const (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
"github.com/moira-alert/moira/notifier/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
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/moira-alert/moira"
"github.com/moira-alert/moira/senders"
"github.com/moira-alert/moira/notifier/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.
6 changes: 3 additions & 3 deletions senders/slack/slack.go → notifier/senders/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"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/moira-alert/moira/notifier/senders"

slackdown "github.com/karriereat/blackfriday-slack"
"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 @@ -6,7 +6,7 @@ import (
"time"

logging "github.com/moira-alert/moira/logging/zerolog_adapter"
"github.com/moira-alert/moira/senders/telegram"
"github.com/moira-alert/moira/notifier/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 @@ -8,7 +8,7 @@ import (
stripmd "github.com/writeas/go-strip-markdown"

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

// SendEvents implements Sender interface Send
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"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/moira-alert/moira/notifier/senders/victorops/api"

"github.com/golang/mock/gomock"
. "github.com/smartystreets/goconvey/convey"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"
"time"

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

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

// Sender implements moira sender interface for VictorOps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

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

logging "github.com/moira-alert/moira/logging/zerolog_adapter"
mock_moira_alert "github.com/moira-alert/moira/mock/moira-alert"
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 1fa56b2

Please sign in to comment.