notify

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 17 Imported by: 0

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.

func (*Github) Send

func (g *Github) Send(ctx context.Context, text string) error

Send makes new release on github repository.

func (*Github) String

func (g *Github) String() string

String returns the string representation of the destination.

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

func NewMattermost(lg *log.Logger, cl http.Client, url string) *Mattermost

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

type Post struct {
	Log    *log.Logger
	URL    string
	Client *http.Client
}

Post sends a POST request to the given URL with release notes.

func (*Post) Send added in v0.6.0

func (p *Post) Send(ctx context.Context, text string) error

Send sends a POST request to the given URL with release notes.

func (*Post) String added in v0.6.0

func (p *Post) String() string

String returns the string representation of the notifier.

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

func (*Telegram) Send

func (t *Telegram) Send(ctx context.Context, text string) error

Send changelog via Telegram.

func (*Telegram) String

func (t *Telegram) String() string

String returns the string representation to identify this notifier.

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

type WriterNotifier struct {
	Writer io.Writer
	Name   string // used for debugging purposes
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL