Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertDependenciesFromAPI[T PluginDependencyURLsSetter[P], P any](in map[string]Dependency) map[string]T
- func ConvertDependenciesToAPI[T PluginDependencyURLsGetter](resp map[string]T) map[string]Dependency
- type Base
- type Body
- type BotNameOption
- type BotNameOptions
- type BulletList
- type BulletLists
- type Button
- type ButtonBuilder
- func (b *ButtonBuilder) DescriptionURL(name, cmd string, url string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommand(name, cmd, desc string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForCommandWithoutDesc(name, cmd string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForURL(name, url string, style ...ButtonStyle) Button
- func (b *ButtonBuilder) ForURLWithBoldDesc(name, desc, url string, style ...ButtonStyle) Button
- type ButtonDescriptionStyle
- type ButtonStyle
- type Buttons
- type ContextItem
- type ContextItems
- type Dependency
- type DispatchedInputAction
- type JSONSchema
- type LabelInput
- type LabelInputs
- type Message
- type MessageType
- type MetadataOutput
- type MultiSelect
- type OptionGroup
- type OptionItem
- type PluginDependencyURLsGetter
- type PluginDependencyURLsSetter
- type Section
- type Select
- type SelectType
- type Selects
- type TextField
- type TextFields
- type URLs
Constants ¶
const (
// MessageBotNamePlaceholder is a cross-platform placeholder for bot name.
MessageBotNamePlaceholder = "{{BotName}}"
)
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
MagicCookieKey: "BOTKUBE",
MagicCookieValue: "52ca7b74-28eb-4fac-ae79-31a9cbda2454",
}
HandshakeConfig is common handshake config between Botkube and its plugins.
Functions ¶
func ConvertDependenciesFromAPI ¶ added in v0.18.0
func ConvertDependenciesFromAPI[T PluginDependencyURLsSetter[P], P any](in map[string]Dependency) map[string]T
ConvertDependenciesFromAPI converts API dependencies to source/executor plugin dependencies.
func ConvertDependenciesToAPI ¶ added in v0.18.0
func ConvertDependenciesToAPI[T PluginDependencyURLsGetter](resp map[string]T) map[string]Dependency
ConvertDependenciesToAPI converts source/executor plugin dependencies to API dependencies.
Types ¶
type Base ¶ added in v1.0.0
Base holds generic message fields.
func ReplaceBotNameInBase ¶ added in v1.0.0
ReplaceBotNameInBase replaces bot name placeholder with a given name.
type Body ¶ added in v1.0.0
Body holds message body fields.
func ReplaceBotNameInBody ¶ added in v1.0.0
ReplaceBotNameInBody replaces bot name placeholder with a given name.
type BotNameOption ¶ added in v1.1.0
type BotNameOption func(opts *BotNameOptions)
BotNameOption allows modifying ReplaceBotNamePlaceholder related options.
func BotNameWithClusterName ¶ added in v1.1.0
func BotNameWithClusterName(clusterName string) BotNameOption
BotNameWithClusterName sets the cluster name for places where MessageBotNamePlaceholder was also specified.
type BotNameOptions ¶ added in v1.1.0
type BotNameOptions struct {
ClusterName string
}
BotNameOptions holds options used in ReplaceBotNamePlaceholder func
type BulletList ¶ added in v1.0.0
BulletList defines a bullet list primitive.
type BulletLists ¶ added in v1.0.0
type BulletLists []BulletList
BulletLists holds the bullet lists.
func (BulletLists) AreItemsDefined ¶ added in v1.0.0
func (l BulletLists) AreItemsDefined() bool
AreItemsDefined returns true if at least one list has items defined.
type Button ¶ added in v1.0.0
type Button struct { Description string // DescriptionStyle defines the style of the button description. If not provided, the default style (ButtonDescriptionStyleCode) is used. DescriptionStyle ButtonDescriptionStyle Name string Command string URL string Style ButtonStyle }
Button holds definition of action button.
type ButtonBuilder ¶ added in v1.0.0
type ButtonBuilder struct{}
ButtonBuilder provides a simplified way to construct a Button model.
func NewMessageButtonBuilder ¶ added in v1.0.0
func NewMessageButtonBuilder() *ButtonBuilder
func (*ButtonBuilder) DescriptionURL ¶ added in v1.0.0
func (b *ButtonBuilder) DescriptionURL(name, cmd string, url string, style ...ButtonStyle) Button
DescriptionURL returns link button with description.
func (*ButtonBuilder) ForCommand ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommand(name, cmd, desc string, style ...ButtonStyle) Button
ForCommand returns button command with description in adaptive code block.
For displaying description in bold, use ForCommandWithBoldDesc.
func (*ButtonBuilder) ForCommandWithBoldDesc ¶ added in v1.2.0
func (b *ButtonBuilder) ForCommandWithBoldDesc(name, desc, cmd string, style ...ButtonStyle) Button
ForCommandWithBoldDesc returns button command where description and command are different.
func (*ButtonBuilder) ForCommandWithDescCmd ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommandWithDescCmd(name, cmd string, style ...ButtonStyle) Button
ForCommandWithDescCmd returns button command where description and command are the same.
func (*ButtonBuilder) ForCommandWithoutDesc ¶ added in v1.0.0
func (b *ButtonBuilder) ForCommandWithoutDesc(name, cmd string, style ...ButtonStyle) Button
ForCommandWithoutDesc returns button command without description.
func (*ButtonBuilder) ForURL ¶ added in v1.0.0
func (b *ButtonBuilder) ForURL(name, url string, style ...ButtonStyle) Button
ForURL returns link button.
func (*ButtonBuilder) ForURLWithBoldDesc ¶ added in v1.2.0
func (b *ButtonBuilder) ForURLWithBoldDesc(name, desc, url string, style ...ButtonStyle) Button
ForURLWithBoldDesc returns link button with description.
type ButtonDescriptionStyle ¶ added in v1.2.0
type ButtonDescriptionStyle string
ButtonDescriptionStyle defines the style of the button description.
const ( // ButtonDescriptionStyleBold defines the bold style for the button description. ButtonDescriptionStyleBold ButtonDescriptionStyle = "bold" // ButtonDescriptionStyleCode defines the code style for the button description. ButtonDescriptionStyleCode ButtonDescriptionStyle = "code" )
type ButtonStyle ¶ added in v1.0.0
type ButtonStyle string
ButtonStyle is a style of Button element.
const ( ButtonStyleDefault ButtonStyle = "" ButtonStylePrimary ButtonStyle = "primary" ButtonStyleDanger ButtonStyle = "danger" )
Represents a general button styles.
type Buttons ¶ added in v1.0.0
type Buttons []Button
Buttons holds definition of interactive buttons.
func ReplaceBotNameInButtons ¶ added in v1.0.0
func ReplaceBotNameInButtons(btns Buttons, name string, opts BotNameOptions) Buttons
ReplaceBotNameInButtons replaces bot name placeholder with a given name.
func (*Buttons) AtLeastOneButtonHasDescription ¶ added in v1.0.0
AtLeastOneButtonHasDescription returns true if there is at least one button with description associated with it.
type ContextItem ¶ added in v1.0.0
type ContextItem struct {
Text string
}
ContextItem holds context item.
type ContextItems ¶ added in v1.0.0
type ContextItems []ContextItem
ContextItems holds context items.
func ReplaceBotNameInContextItems ¶ added in v1.0.0
func ReplaceBotNameInContextItems(items ContextItems, name string) ContextItems
ReplaceBotNameInContextItems replaces bot name placeholder with a given name.
func (ContextItems) IsDefined ¶ added in v1.0.0
func (c ContextItems) IsDefined() bool
IsDefined returns true if there are any context items defined.
type Dependency ¶ added in v0.18.0
type Dependency struct { // URLs holds the URLs for a given dependency depending on the platform and architecture. URLs URLs `yaml:"urls"` }
Dependency holds the dependency information.
type DispatchedInputAction ¶ added in v1.0.0
type DispatchedInputAction string
DispatchedInputAction defines when the action should be sent to our backend.
const ( NoDispatchInputAction DispatchedInputAction = "" DispatchInputActionOnEnter DispatchedInputAction = "on_enter_pressed" DispatchInputActionOnCharacter DispatchedInputAction = "on_character_entered" )
Defines the possible options to dispatch the input action.
type JSONSchema ¶ added in v0.18.0
type JSONSchema struct { // Value is the JSON schema string. Value string // RefURL is the remote reference of the schema. RefURL string }
JSONSchema contains the JSON schema or a remote reference where the schema can be found. Value and RefURL are mutually exclusive
type LabelInput ¶ added in v1.0.0
type LabelInput struct { Command string Text string Placeholder string DispatchedAction DispatchedInputAction }
LabelInput is used to create input elements to use in messages.
type LabelInputs ¶ added in v1.0.0
type LabelInputs []LabelInput
LabelInputs holds the plain text input items.
func ReplaceBotNameInLabels ¶ added in v1.0.0
func ReplaceBotNameInLabels(labels LabelInputs, name string, opts BotNameOptions) LabelInputs
ReplaceBotNameInLabels replaces bot name placeholder with a given name.
type Message ¶ added in v1.0.0
type Message struct { Type MessageType BaseBody Body Timestamp time.Time Sections []Section PlaintextInputs LabelInputs OnlyVisibleForYou bool ReplaceOriginal bool }
Message represents a generic message with interactive buttons.
func NewCodeBlockMessage ¶ added in v1.0.0
NewCodeBlockMessage returns message in a Markdown code block format.
func NewPlaintextMessage ¶ added in v1.0.0
NewPlaintextMessage returns message in a plaintext format.
func (*Message) HasInputs ¶ added in v1.0.0
HasInputs returns true if message has interactive inputs.
func (*Message) HasSections ¶ added in v1.0.0
HasSections returns true if message has interactive sections.
func (*Message) ReplaceBotNamePlaceholder ¶ added in v1.0.0
func (msg *Message) ReplaceBotNamePlaceholder(new string, opts ...BotNameOption)
ReplaceBotNamePlaceholder replaces bot name placeholder with a given name.
type MessageType ¶ added in v1.0.0
type MessageType string
MessageType defines the message type.
const ( // DefaultMessage defines a message that should be displayed in default mode supported by communicator. DefaultMessage MessageType = "" // BaseBodyWithFilterMessage defines a message that should be displayed in plaintext mode supported by communicator. // In this form the built-in filter is supported. // NOTE: only BaseBody is preserved. All other properties are ignored even if set. BaseBodyWithFilterMessage MessageType = "baseBodyWithFilter" // NonInteractiveSingleSection it is an indicator for non-interactive platforms, that they can render this event // even though they have limited capability. As a result, a given message has the following restriction: // - the whole message should have exactly one section // - section interactive elements such as buttons, select, multiselect, and inputs are ignored. // - the base body of the message is ignored // - Timestamp field is optional NonInteractiveSingleSection MessageType = "nonInteractiveEventSingleSection" // PopupMessage defines a message that should be displayed to the user as popup (if possible). PopupMessage MessageType = "form" )
type MetadataOutput ¶
type MetadataOutput struct { // Version is a version of a given plugin. It should follow the SemVer syntax. Version string // Descriptions is a description of a given plugin. Description string // JSONSchema is a JSON schema for a given plugin. JSONSchema JSONSchema // Dependencies holds the dependencies for a given platform binary. Dependencies map[string]Dependency }
MetadataOutput contains the metadata of a given plugin.
func (MetadataOutput) Validate ¶
func (m MetadataOutput) Validate() error
Validate validate the metadata fields and returns detected issues.
type MultiSelect ¶ added in v1.0.0
type MultiSelect struct { Name string Description Body Command string // Options holds all available options Options []OptionItem // InitialOptions hold already pre-selected options. MUST be a sub-set of Options. InitialOptions []OptionItem }
MultiSelect holds multi select related fields.
func ReplaceBotNameInMultiSelect ¶ added in v1.0.0
func ReplaceBotNameInMultiSelect(ms MultiSelect, name string, opts BotNameOptions) MultiSelect
ReplaceBotNameInMultiSelect replaces bot name placeholder with a given name.
func (*MultiSelect) AreOptionsDefined ¶ added in v1.0.0
func (m *MultiSelect) AreOptionsDefined() bool
AreOptionsDefined returns true if some options are available.
type OptionGroup ¶ added in v1.0.0
type OptionGroup struct { Name string Options []OptionItem }
OptionGroup holds information about options in the same group.
func ReplaceBotNameInOptionGroups ¶ added in v1.0.0
func ReplaceBotNameInOptionGroups(groups []OptionGroup, name string) []OptionGroup
ReplaceBotNameInOptionGroups replaces bot name placeholder with a given name.
type OptionItem ¶ added in v1.0.0
OptionItem defines an option model.
func ReplaceBotNameInOptionItem ¶ added in v1.0.0
func ReplaceBotNameInOptionItem(item *OptionItem, name string) *OptionItem
ReplaceBotNameInOptionItem replaces bot name placeholder with a given name.
func ReplaceBotNameInOptions ¶ added in v1.0.0
func ReplaceBotNameInOptions(items []OptionItem, name string) []OptionItem
ReplaceBotNameInOptions replaces bot name placeholder with a given name.
type PluginDependencyURLsGetter ¶ added in v0.18.0
PluginDependencyURLsGetter is an interface for getting plugin dependency URLs.
type PluginDependencyURLsSetter ¶ added in v0.18.0
type PluginDependencyURLsSetter[T any] interface { SetUrls(in map[string]string) *T // This is needed to ensure we can create an instance of the concrete type as a part of the ConvertDependenciesFromAPI function. }
PluginDependencyURLsSetter is an interface for setting plugin dependency URLs.
type Section ¶ added in v1.0.0
type Section struct { Base Buttons Buttons MultiSelect MultiSelect Selects Selects PlaintextInputs LabelInputs TextFields TextFields BulletLists BulletLists Context ContextItems }
Section holds section related fields.
type Select ¶ added in v1.0.0
type Select struct { Type SelectType Name string Command string // OptionGroups provides a way to group options in a select menu. OptionGroups []OptionGroup // InitialOption holds already pre-selected options. MUST be a sub-set of OptionGroups. InitialOption *OptionItem }
Select holds data related to the select drop-down.
type SelectType ¶ added in v1.0.0
type SelectType string
SelectType is a type of Button element.
const ( StaticSelect SelectType = "static" ExternalSelect SelectType = "external" )
Represents a select dropdown types.
type Selects ¶ added in v1.0.0
type Selects struct { // ID allows to identify a given block when we do the updated. ID string Items []Select }
Selects holds multiple Select objects.
func ReplaceBotNameInSelects ¶ added in v1.0.0
func ReplaceBotNameInSelects(selects Selects, name string, opts BotNameOptions) Selects
ReplaceBotNameInSelects replaces bot name placeholder with a given name.
func (*Selects) AreOptionsDefined ¶ added in v1.0.0
AreOptionsDefined returns true if some options are available.
type TextFields ¶ added in v1.0.0
type TextFields []TextField
TextFields holds text field items.
func ReplaceBotNameInTextFields ¶ added in v1.0.0
func ReplaceBotNameInTextFields(fields TextFields, name string) TextFields
ReplaceBotNameInTextFields replaces bot name placeholder with a given name.