bot

package
v0.0.0-...-c5ab296 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoveApprovalPrefix = "rm approval"
)

Variables

View Source
var (
	BotEventTextToResponse = map[string][]string{
		"help": {
			`Here's a list of supported commands`,
			`- "get deployments" -> get a list of all deployments`,
			`- "get approvals" -> get a list of approvals`,
			`- "rm approval <approval identifier>" -> remove approval`,
			`- "approve <approval identifier>" -> approve update request`,
			`- "reject <approval identifier>" -> reject update request`,
		},
	}

	ApprovalResponseKeyword = "approve"
	RejectResponseKeyword   = "reject"
)

Functions

func ApprovalsResponse

func ApprovalsResponse(approvalsManager approvals.Manager) string

func IsBotCommand

func IsBotCommand(eventText string) bool

func RegisterBot

func RegisterBot(name string, b Bot)

RegisterBot makes a bot implementation available by the provided name.

func RemoveApprovalHandler

func RemoveApprovalHandler(identifier string, approvalsManager approvals.Manager) string

func Run

func Run(approvalsManager approvals.Manager)

Run all implemented bots

func Stop

func Stop()

func UnregisterBot

func UnregisterBot(name string)

UnregisterBot removes a Sender with a particular name from the list.

Types

type ApprovalResponse

type ApprovalResponse struct {
	User   string
	Status types.ApprovalStatus
	Text   string
}

ApprovalResponse - used to track approvals once vote begins

func IsApproval

func IsApproval(eventUser string, eventText string) (resp *ApprovalResponse, ok bool)

type Bot

type Bot interface {
	Configure(approvalsRespCh chan *ApprovalResponse, botMessagesChannel chan *BotMessage) bool
	Start(ctx context.Context) error
	Respond(text string, channel string)
	RequestApproval(req *types.Approval) error
	ReplyToApproval(approval *types.Approval) error
}

type BotManager

type BotManager struct {
	// contains filtered or unexported fields
}

BotManager holds approvalsManager and k8sImplementer for every bot

func (*BotManager) ProcessApprovalResponses

func (bm *BotManager) ProcessApprovalResponses(ctx context.Context, reply BotReplyApproval) error

func (*BotManager) ProcessBotMessages

func (bm *BotManager) ProcessBotMessages(ctx context.Context, respond BotMessageResponder)

func (*BotManager) SetupBot

func (bm *BotManager) SetupBot(botName string, bot Bot)

func (*BotManager) SubscribeForApprovals

func (bm *BotManager) SubscribeForApprovals(ctx context.Context, approval BotRequestApproval) error

type BotMessage

type BotMessage struct {
	Message string
	User    string
	Name    string
	Channel string
}

BotMessage represents abstract container for any bot Message add here more fields if you needed for a new bot implementation

type BotMessageResponder

type BotMessageResponder func(response string, channel string)

type BotReplyApproval

type BotReplyApproval func(approval *types.Approval) error

type BotRequestApproval

type BotRequestApproval func(req *types.Approval) error

type Filter

type Filter struct {
	Namespace string
	All       bool // bow or not
}

Filter - deployment filter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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