Documentation ¶
Overview ¶
Package notify defines interfaces each supported notification destination should implement.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Destination ¶
type Destination interface { fmt.Stringer // Send the release notes to the destination. Send(ctx context.Context, text string) error }
Destination defines interface for a given destination service, like telegram, email or stdout.
type DestinationMock ¶ added in v0.7.0
type DestinationMock struct { // SendFunc mocks the Send method. SendFunc func(ctx context.Context, text string) error // StringFunc mocks the String method. StringFunc func() string // contains filtered or unexported fields }
DestinationMock is a mock implementation of Destination.
func TestSomethingThatUsesDestination(t *testing.T) { // make and configure a mocked Destination mockedDestination := &DestinationMock{ SendFunc: func(ctx context.Context, text string) error { panic("mock out the Send method") }, StringFunc: func() string { panic("mock out the String method") }, } // use mockedDestination in code that requires Destination // and then make assertions. }
func (*DestinationMock) Send ¶ added in v0.7.0
func (mock *DestinationMock) Send(ctx context.Context, text string) error
Send calls SendFunc.
func (*DestinationMock) SendCalls ¶ added in v0.7.0
func (mock *DestinationMock) SendCalls() []struct { Ctx context.Context Text string }
SendCalls gets all the calls that were made to Send. Check the length with:
len(mockedDestination.SendCalls())
func (*DestinationMock) String ¶ added in v0.7.0
func (mock *DestinationMock) String() string
String calls StringFunc.
func (*DestinationMock) StringCalls ¶ added in v0.7.0
func (mock *DestinationMock) StringCalls() []struct { }
StringCalls gets all the calls that were made to String. Check the length with:
len(mockedDestination.StringCalls())
type Destinations ¶ added in v0.2.0
type Destinations []Destination
Destinations is an aggregation of notifiers.
func (Destinations) Send ¶ added in v0.2.0
func (d Destinations) Send(ctx context.Context, text string) error
Send sends the message to all destinations.
func (Destinations) String ¶ added in v0.2.0
func (d Destinations) String() string
String returns the names of all destinations.
type Github ¶
type Github struct { GithubParams // contains filtered or unexported fields }
Github makes a new release on Github on the given version.
func NewGithub ¶
func NewGithub(params GithubParams) (*Github, error)
NewGithub makes new instance of Github.
type GithubParams ¶
type GithubParams struct { Evaluator *eval.Evaluator Owner string Name string BasicAuthUsername string BasicAuthPassword string HTTPClient http.Client ReleaseNameTmplText string Tag string Extras map[string]string }
GithubParams describes parameters to initialize github releaser.
type Mattermost ¶ added in v0.2.0
type Mattermost struct {
// contains filtered or unexported fields
}
Mattermost sends messages to Mattermost via webhook.
func NewMattermost ¶ added in v0.2.0
NewMattermost makes a new Mattermost notifier.
func (*Mattermost) Send ¶ added in v0.2.0
func (m *Mattermost) Send(ctx context.Context, text string) error
Send sends a message to Mattermost.
func (*Mattermost) String ¶ added in v0.2.0
func (m *Mattermost) String() string
String returns the name of the notifier.
type MattermostBot ¶ added in v0.5.0
type MattermostBot struct {
// contains filtered or unexported fields
}
MattermostBot sends messages to Mattermost via webhook.
func NewMattermostBot ¶ added in v0.5.0
func NewMattermostBot(lg *log.Logger, cl http.Client, baseURL, token, channelID string) (bot *MattermostBot, err error)
NewMattermostBot makes a new Mattermost notifier.
func (*MattermostBot) Send ¶ added in v0.5.0
func (b *MattermostBot) Send(ctx context.Context, text string) error
Send sends a message to Mattermost.
func (*MattermostBot) String ¶ added in v0.5.0
func (b *MattermostBot) String() string
String returns the name of the notifier.
type Post ¶ added in v0.6.0
Post sends a POST request to the given URL with release notes.
type Telegram ¶
type Telegram struct {
TelegramParams
}
Telegram implements Destination to send changelogs to specified telegram chats.
func NewTelegram ¶
func NewTelegram(params TelegramParams) *Telegram
NewTelegram makes telegram bot for notifications
type TelegramParams ¶
type TelegramParams struct { Log *log.Logger ChatID string Client http.Client Token string DisableWebPagePreview bool }
TelegramParams defines parameters needed to initialize Telegram notifier.
type WriterNotifier ¶
WriterNotifier prints the changelog to the specified writer. Writer might be os.Stdout, in order to use in pipelines and CI/CD.
func (*WriterNotifier) Send ¶
func (w *WriterNotifier) Send(_ context.Context, text string) error
Send writes changelog to writer.
func (*WriterNotifier) String ¶
func (w *WriterNotifier) String() string
String returns the string representation to identify this notifier.