events

package
v0.0.0-...-6a2011c Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPretext

func DefaultPretext(action string, e gerritssh.Event) string

DefaultPretext returns the default title with the given action

Types

type Attachment

type Attachment struct {
	Fallback  string         `json:"fallback"`
	Pretext   string         `json:"pretext"`
	Title     string         `json:"title"`
	TitleLink string         `json:"title_link"`
	Text      string         `json:"text"`
	Color     string         `json:"color"`
	Fields    []MessageField `json:"fields"`
}

Attachment is a slack attachment

type ChangeMerged

type ChangeMerged struct{}

ChangeMerged handles the change-merged event

func (ChangeMerged) Ignore

func (ChangeMerged) Ignore(e gerritssh.Event, pcfg project.Config) (bool, error)

Ignore implements the EventHandler interface

func (ChangeMerged) Message

func (ChangeMerged) Message(e gerritssh.Event, _ project.Config, _ *gerrit.Client, me MessageEnricher) (Message, error)

Message implements the EventHandler interface

func (ChangeMerged) Type

func (ChangeMerged) Type() string

Type implements the EventHandler interface

type CommentAdded

type CommentAdded struct{}

CommentAdded handles the comment-added event

func (CommentAdded) Ignore

func (CommentAdded) Ignore(e gerritssh.Event, pcfg project.Config) (bool, error)

Ignore implements the EventHandler interface

func (CommentAdded) Message

func (CommentAdded) Message(e gerritssh.Event, _ project.Config, c *gerrit.Client, me MessageEnricher) (Message, error)

Message implements the EventHandler interface

func (CommentAdded) Type

func (CommentAdded) Type() string

Type implements the EventHandler interface

type EventHandler

type EventHandler interface {
	// Type should return the type the handler handles
	Type() string

	// Ignore should return true if the event should be ignored
	Ignore(gerritssh.Event, project.Config) (bool, error)

	// Message should return a Message for the event
	Message(gerritssh.Event, project.Config, *gerrit.Client, MessageEnricher) (Message, error)
}

EventHandler takes a given Event and generates a Message

func Handler

func Handler(e gerritssh.Event, _ project.Config) (EventHandler, bool)

Handler returns a registered handler for the sent event

type Message

type Message struct {
	Attachment
	Channel string
}

Message is a single-attachment message

func (Message) MarshalJSON

func (m Message) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

type MessageEnricher

type MessageEnricher interface {
	// MentionUser takes an email and name and returns either a mention or their
	// name
	MentionUser(string, string) string
}

MessageEnricher is used when building a message to mention a user

type MessageField

type MessageField struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

MessageField is a slack field

func OwnerField

func OwnerField(e gerritssh.Event, me MessageEnricher) MessageField

OwnerField returns a Owner field with their name

func ProjectField

func ProjectField(e gerritssh.Event) MessageField

ProjectField returns a Project field with the name

func ReviewersField

func ReviewersField(e gerritssh.Event, rs []gerrit.ReviewerInfo, me MessageEnricher) MessageField

ReviewersField returns a Reviewers field with reviewers

type PatchSetCreated

type PatchSetCreated struct{}

PatchSetCreated handles the patchset-created event

func (PatchSetCreated) Ignore

func (PatchSetCreated) Ignore(e gerritssh.Event, pcfg project.Config) (bool, error)

Ignore implements the EventHandler interface

func (PatchSetCreated) Message

Message implements the EventHandler interface

func (PatchSetCreated) Type

func (PatchSetCreated) Type() string

Type implements the EventHandler interface

type ReviewerAdded

type ReviewerAdded struct{}

ReviewerAdded handles the reviewer-added event

func (ReviewerAdded) Ignore

func (ReviewerAdded) Ignore(e gerritssh.Event, pcfg project.Config) (bool, error)

Ignore implements the EventHandler interface

func (ReviewerAdded) Message

func (ReviewerAdded) Message(e gerritssh.Event, _ project.Config, _ *gerrit.Client, me MessageEnricher) (Message, error)

Message implements the EventHandler interface

func (ReviewerAdded) Type

func (ReviewerAdded) Type() string

Type implements the EventHandler interface

Jump to

Keyboard shortcuts

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