Documentation ¶
Index ¶
- Constants
- func FormatErrorResponse(to, message, reason string) string
- func FormatResponseWithReason(to, message, reason string) string
- func FormatSimpleErrorResponse(to, message string) string
- func FormatSimpleResponse(to, message string) string
- func FormatUnauthorizedResponse(to, name string) string
- func FormatUsageError(name, description, example, usage string) string
- func HandleRequest(client github.Client, event *github.GenericRequestEvent) error
- func ParseCommands(message string) ([][]string, error)
- func Register(plugin Plugin)
- func ResumePlugins(ghMgr github.Manager) error
- func Setup(log logr.Logger, persistence Persistence)
- func UpdateState(pl Plugin, runID string, customState string) error
- type Persistence
- type Plugin
- type Plugins
- func (p *Plugins) Error(client github.Client, event *github.GenericRequestEvent, plugin Plugin, ...) error
- func (p *Plugins) Get(name string) (string, Plugin, error)
- func (p *Plugins) HandleRequest(client github.Client, event *github.GenericRequestEvent) error
- func (p *Plugins) Register(plugin Plugin)
- func (p *Plugins) RemoveState(pl Plugin, runID string)
- func (p *Plugins) ResumePlugins(ghMgr github.Manager) error
- func (p *Plugins) UpdateState(pl Plugin, runID string, customState string) error
- type State
Constants ¶
const AboutThisBotWithoutCommands = "" /* 128-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func FormatErrorResponse ¶
FormatErrorResponse formats a response that does not warrant additional explanation in the details section.
func FormatResponseWithReason ¶
FormatResponseWithReason formats a response with additional explanation in the details section.
func FormatSimpleErrorResponse ¶
FormatSimpleErrorResponse formats a response that does not warrant additional explanation in the details section.
func FormatSimpleResponse ¶
FormatSimpleResponse formats a response that does not warrant additional explanation in the details section.
func FormatUnauthorizedResponse ¶
FormatUnauthorizedResponse returns the user not authorized response
func FormatUsageError ¶
FormatUsageError formats Usage of a command
func HandleRequest ¶
func HandleRequest(client github.Client, event *github.GenericRequestEvent) error
HandleRequest parses a github event and executes the found Plugins
func ParseCommands ¶
ParseCommands parses a message and returns a string of commands and arguments
func Register ¶
func Register(plugin Plugin)
Register registers a plugin with its command to be executed on a event
func ResumePlugins ¶
ResumePlugins resumes all states that can be found in the persistent storage
func Setup ¶
func Setup(log logr.Logger, persistence Persistence)
Setup sets up the Plugins with a logger and a persistent storage
Types ¶
type Persistence ¶
type Persistence interface { Save(map[string]map[string]*State) error Load() (map[string]map[string]*State, error) }
Persistence describes the interface for persisting plugin states
func NewKubernetesPersistence ¶
func NewKubernetesPersistence(k8sClient client.Client, name, namespace string) (Persistence, error)
type Plugin ¶
type Plugin interface { // Command returns the unique matching command for the plugin Command() string // Authorization returns the authorization type of the plugin. // Defines who is allowed to call the plugin Authorization() github.AuthorizationType // Description returns a short description of the plugin Description() string // Example returns an example for the command Example() string // Config returns description for the default config that can be used in the repository Config() string // Flags return command line style flags for the command Flags() *pflag.FlagSet // Create a deep copy of the plugin New(runID string) Plugin // Run runs the command with the parsed flags (flag.Parse()) and the event that triggered the command Run(fs *pflag.FlagSet, client github.Client, event *github.GenericRequestEvent) error // resume the plugin execution from a persisted state ResumeFromState(client github.Client, event *github.GenericRequestEvent, state string) error }
Plugin specifies a tm github bot plugin/command that can be triggered by a user
type Plugins ¶
type Plugins struct {
// contains filtered or unexported fields
}
func (*Plugins) Error ¶
func (p *Plugins) Error(client github.Client, event *github.GenericRequestEvent, plugin Plugin, err error) error
Error responds to the client if an error occurs
func (*Plugins) HandleRequest ¶
HandleRequest parses a github event and executes the found Plugins
func (*Plugins) RemoveState ¶
RemoveState removes the state of a running plugin from the persistence
func (*Plugins) ResumePlugins ¶
ResumePlugins resumes all states that can be found in the persistent storage
type State ¶
type State struct { Event *github.GenericRequestEvent Custom string }
State describes the configuration of a running plugin that is can resume at any time