server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DialogSessions map[string]*DialogSession = make(map[string]*DialogSession, 0)
View Source
var Providers map[string]*OpsCommand = make(map[string]*OpsCommand)

Functions

func FindConfigFile

func FindConfigFile(fileName string) string

func GenerateEnrichedSlashResponse

func GenerateEnrichedSlashResponse(title, text, color, respType string) []byte

func GenerateIncomingWebhookRequest

func GenerateIncomingWebhookRequest(channelName, title, text, color string) []byte

func GenerateStandardSlashResponse

func GenerateStandardSlashResponse(text string, respType string) string

func LoadCommands

func LoadCommands()

func LoadConfig

func LoadConfig(fileName string)

func Log

func Log(level string, msg string, args ...interface{})

func LogCritical

func LogCritical(msg string, args ...interface{})

func LogError

func LogError(msg string, args ...interface{})

func LogInfo

func LogInfo(msg string, args ...interface{})

func SendDialogRequest

func SendDialogRequest(url string, request *model.OpenDialogRequest)

func SendViaIncomingHook

func SendViaIncomingHook(hook, channelName, title, text, color string)

func Start

func Start()

func Stop

func Stop()

func WriteEnrichedResponse

func WriteEnrichedResponse(w http.ResponseWriter, title, resp, color, style string)

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, err *AppError)

func WriteResponse

func WriteResponse(w http.ResponseWriter, resp string, style string)

Types

type AppError

type AppError struct {
	ErrorDescription string
	Parent           error
}

func NewError

func NewError(description string, parent error) *AppError

func (*AppError) Error

func (err *AppError) Error() string

type Color

type Color struct {
	Color  string `yaml:"color"`
	Status string `yaml:"status"`
}

type DialogSession

type DialogSession struct {
	CallbackID   string
	MMHookURL    string
	SlashCommand *MMSlashCommand
	OpsCommand   *OpsCommand
}

type DialogSubmission

type DialogSubmission struct {
	Type       string `json:"type"`
	CallbackID string `json:"callback_id"`
	State      string `json:"state"`
	UserID     string `json:"user_id"`
	ChannelID  string `json:"channel_id"`
	TeamID     string `json:"team_id"`
	//nolint:misspell // cancelled is misspelled but it is sent from mattermost-server.
	Canceled   bool              `json:"cancelled"`
	Submission map[string]string `json:"submission"`
}

func ParseDialogSubmission

func ParseDialogSubmission(r *http.Request) (*DialogSubmission, error)

type HookResponse

type HookResponse struct {
	Title        string
	Color        string
	ResponseType string
	Body         string
}

type MMSlashCommand

type MMSlashCommand struct {
	ChannelID   string `schema:"channel_id"`
	ChannelName string `schema:"channel_name"`
	Command     string `schema:"command"`
	TeamName    string `schema:"team_domain"`
	TeamID      string `schema:"team_id"`
	Text        string `schema:"text"`
	Token       string `schema:"token"`
	UserID      string `schema:"user_id"`
	Username    string `schema:"user_name"`
	ResponseURL string `schema:"response_url"`
	TriggerID   string `schema:"trigger_id"`
}

func ParseSlashCommand

func ParseSlashCommand(r *http.Request) (*MMSlashCommand, error)

type OpsCommand

type OpsCommand struct {
	Command          string               `yaml:"command"`
	SubCommand       string               `yaml:"subcommand"`
	Name             string               `yaml:"name"`
	Description      string               `yaml:"description"`
	Provides         []string             `yaml:"provides"`
	ProvidedCommands []*OpsCommand        `yaml:"-"`
	Variables        []OpsCommandVariable `yaml:"vars"`
	Exec             []string             `yaml:"exec"`
	Response         OpsCommandResponse   `yaml:"response"`
	Users            []string             `yaml:"users"`
	Dialog           *OpsCommandDialog    `yaml:"dialog"`
}

func (*OpsCommand) CanTrigger

func (opsCmd *OpsCommand) CanTrigger(username string) bool

func (*OpsCommand) Execute

func (opsCmd *OpsCommand) Execute(mmCommand *MMSlashCommand, args []string, envValues map[string]string) (*OpsCommandOutput, error)

type OpsCommandDialog

type OpsCommandDialog struct {
	Title       string                     `yaml:"title"`
	URL         string                     `yaml:"url"`
	CallbackURL string                     `yaml:"callbackUrl"`
	MMHookURL   string                     `yaml:"hook"`
	Text        string                     `yaml:"introduction_text"`
	Elements    []*OpsCommandDialogElement `yaml:"elements"`
}

type OpsCommandDialogElement

type OpsCommandDialogElement struct {
	DisplayName string                    `yaml:"display_name"`
	Name        string                    `yaml:"name"`
	Type        string                    `yaml:"type"`
	SubType     string                    `yaml:"subtype"`
	Default     string                    `yaml:"default"`
	Placeholder string                    `yaml:"placeholder"`
	HelpText    string                    `yaml:"help_text"`
	Optional    bool                      `yaml:"optional"`
	MinLength   int                       `yaml:"min_length"`
	MaxLength   int                       `yaml:"max_length"`
	Options     []*OpsCommandDialogOption `yaml:"options"`
}

type OpsCommandDialogOption

type OpsCommandDialogOption struct {
	Text  string `yaml:"text"`
	Value string `yaml:"value"`
}

type OpsCommandOutput

type OpsCommandOutput struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data"`
}

type OpsCommandResponse

type OpsCommandResponse struct {
	Type           string             `yaml:"type"`
	Colors         []Color            `yaml:"colors"`
	TemplateString string             `yaml:"template"`
	Template       *template.Template `yaml:"-"`
	Generate       bool               `yaml:"-"`
}

type OpsCommandVariable

type OpsCommandVariable struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

type OpsToolConfig

type OpsToolConfig struct {
	Listen                string              `yaml:"listen"`
	Token                 string              `yaml:"token"`
	CommandConfigurations []string            `yaml:"commands"`
	ScheduledCommands     []*ScheduledCommand `yaml:"scheduler"`
}
var Config *OpsToolConfig = &OpsToolConfig{}

type ScheduledCommand

type ScheduledCommand struct {
	Name     string   `yaml:"name"`
	Channel  string   `yaml:"channel"`
	Provider string   `yaml:"provider"`
	Command  string   `yaml:"command"`
	Args     []string `yaml:"args"`
	Cron     string   `yaml:"cron"`
	Hook     string   `yaml:"hook"`
}

Jump to

Keyboard shortcuts

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