Documentation
¶
Index ¶
- Variables
- func CoerceVersionToSemver(version string) string
- func CompareHashAndPassword(hashedPassword string, password string) bool
- func GenerateRandomToken(length int) (string, error)
- func HashPassword(pwd string) (string, error)
- type AbstractProvider
- type Bundle
- type BundleCommand
- type BundleInfo
- type BundleKubernetes
- type CommandEntry
- type CommandParameters
- type CommandRequest
- type CommandResponse
- type CommandResponseData
- type CommandResponseEnvelope
- type CommandResponseEnvelopeOption
- type DatabaseConfigs
- type DiscordProvider
- type DockerConfigs
- type GlobalConfigs
- type GortConfig
- type GortServerConfigs
- type JaegerConfigs
- type KubernetesConfigs
- type Provider
- type SlackProvider
- type TemplateType
- type Templates
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCryptoHash is returned by HashPassword and will wrap its // underlying error. ErrCryptoHash = errors.New("failed to generate password hash") // ErrCryptoIO is returned by GenerateRandomToken if it can't retrieve // random bytes from rand.Read() ErrCryptoIO = errors.New("failed to retrieve randomness") )
Functions ¶
func CoerceVersionToSemver ¶ added in v0.9.0
CoerceVersionToSemver takes a version number and attempts to coerce it into a semver-compliant dotted-tri format. It also understands semver pre-release and metadata decorations.
func CompareHashAndPassword ¶
CompareHashAndPassword receives a plaintext password and its hash, and returns true if they match.
func GenerateRandomToken ¶
GenerateRandomToken generates a random character token.
func HashPassword ¶
HashPassword receives a plaintext password and returns its hashed equivalent.
Types ¶
type AbstractProvider ¶
type AbstractProvider struct {
BotName string `yaml:"bot_name,omitempty"`
Name string `yaml:"name,omitempty"`
}
AbstractProvider is used to contain the general properties shared by all providers.
type Bundle ¶
type Bundle struct {
GortBundleVersion int `yaml:"gort_bundle_version,omitempty" json:",omitempty"`
Name string `yaml:",omitempty" json:",omitempty"`
Version string `yaml:",omitempty" json:",omitempty"`
Enabled bool `yaml:",omitempty" json:",omitempty"`
Author string `yaml:",omitempty" json:",omitempty"`
Homepage string `yaml:",omitempty" json:",omitempty"`
Description string `yaml:",omitempty" json:",omitempty"`
Image string `yaml:",omitempty" json:",omitempty"`
InstalledOn time.Time `yaml:"-" json:",omitempty"`
InstalledBy string `yaml:",omitempty" json:",omitempty"`
LongDescription string `yaml:"long_description,omitempty" json:",omitempty"`
Kubernetes BundleKubernetes `yaml:",omitempty" json:",omitempty"`
Permissions []string `yaml:",omitempty" json:",omitempty"`
Commands map[string]*BundleCommand `yaml:",omitempty" json:",omitempty"`
Default bool `yaml:"-" json:",omitempty"`
Templates Templates `yaml:",omitempty" json:",omitempty"`
}
Bundle represents a bundle as defined in the "bundles" section of the config.
func (Bundle) ImageFull ¶ added in v0.9.0
ImageFull returns the full image name, consisting of a repository and tag.
func (Bundle) ImageFullParts ¶ added in v0.9.0
ImageFullParts returns the image repository and tag. If the tag isn't specified in b.Image, the returned tag will be "latest".
func (Bundle) Semver ¶ added in v0.9.0
Semver returns b.Version as a semver.Version value, which makes it easier to compare and sort version numbers. If b.Version == "", a zero-value Version{} is returned. If b.Version isn't valid per Semantic Versioning 2.0.0 (https://semver.org), it will attempt to coerce it into a correct semantic version (since users be crazy). If it fails, a zero-value Version{} is returned.
type BundleCommand ¶
type BundleCommand struct {
Description string `yaml:",omitempty" json:"description,omitempty"`
Executable []string `yaml:",omitempty,flow" json:"executable,omitempty"`
LongDescription string `yaml:"long_description,omitempty" json:"long_description,omitempty"`
Name string `yaml:"-" json:"-"`
Rules []string `yaml:",omitempty" json:"rules,omitempty"`
Templates Templates `yaml:",omitempty" json:"templates,omitempty"`
}
BundleCommand represents a bundle command, as defined in the "bundles/commands" section of the config.
type BundleInfo ¶
BundleInfo wraps a minimal amount of data about a bundle.
type BundleKubernetes ¶ added in v0.9.0
type BundleKubernetes struct {
ServiceAccountName string `yaml:"serviceAccountName,omitempty" json:"serviceAccountName,omitempty"`
}
BundleKubernetes represents the "bundles/kubernetes" subsection of the config doc
type CommandEntry ¶
type CommandEntry struct {
Bundle Bundle
Command BundleCommand
}
CommandEntry conveniently wraps a bundle and one command within that bundle.
type CommandParameters ¶ added in v0.9.0
type CommandParameters []string
func (CommandParameters) String ¶ added in v0.9.0
func (c CommandParameters) String() string
type CommandRequest ¶
type CommandRequest struct {
CommandEntry
Adapter string // The name of the adapter this request originated from
ChannelID string // The provider ID of the channel that the request originated in
Context context.Context // The request context
Parameters CommandParameters // Tokenized command parameters
RequestID int64 // A unique requestID
Timestamp time.Time // The time this request was triggered
UserID string // The provider ID of user making this request
UserEmail string // The email address associated with the user making the request
UserName string // The gort username of the user making the request
}
CommandRequest represents a user command request as triggered in (probably) a chat provider.
func (CommandRequest) String ¶ added in v0.9.0
func (r CommandRequest) String() string
String is a convenience method that outputs the normalized command string more or less as the user typed it.
type CommandResponse ¶
type CommandResponse struct {
// Lines contains the command output (from both stdout and stderr) as
// a string slice, delimitted along newlines.
Lines []string
// Out The command output as a single block of text, with lines joined
// with newlines.
Out string
// Structured is true if the command output is valid JSON. If so, then it
// also be unmarshalled as Payload; else Payload will be a string (equal
// to Out).
Structured bool
// Title includes a title. Usually only set by the relay for certain
// internally-detected errors. It can be used to build a user output
// message, and generally contains a short description of the result.
Title string
}
CommandResponse wraps the response text emitted by an executed command.
type CommandResponseData ¶ added in v0.9.0
type CommandResponseData struct {
// Duration is how long the command required to execute.
// TODO(mtitmus) What are the start and endpoints? Do we want to track
// multiple durations for "framework time" and "command time" and whatever
// else?
Duration time.Duration
// ExitCode is the exit code reported by the command.
ExitCode int16
// Error is set by the relay under certain internal error conditions.
Error error
}
CommandResponseData contains about a command execution, including its duration and exit code. If the relay set an an explicit error, it will be here as well.
type CommandResponseEnvelope ¶ added in v0.9.0
type CommandResponseEnvelope struct {
// Request is the original request used to execute the command. It contains
// the original CommandEntry value as well as the user and adapter data.
Request CommandRequest
// Response contains the
Response CommandResponse
// Data contains about the command execution, including its duration and exit code.
// If the relay set an an explicit error, it will be here as well.
Data CommandResponseData
// Payload includes the command output. If the output is structured JSON,
// it will be unmarshalled and placed here where it can be accessible to
// Go templates. If it's not, this will be a string equal to Out.
Payload interface{}
}
CommandResponseEnvelope encapsulates the data and metadata around a command execution and response. It's returned by a relay when a command has been executed. It is passed directly into the templating engine where it can be accessed by the Go templates that describe the response formats.
func NewCommandResponseEnvelope ¶ added in v0.9.0
func NewCommandResponseEnvelope(request CommandRequest, opts ...CommandResponseEnvelopeOption) CommandResponseEnvelope
NewCommandResponseEnvelope can be used to generate a new CommandResponseEnvelope value with the provided options.
type CommandResponseEnvelopeOption ¶ added in v0.9.0
type CommandResponseEnvelopeOption func(e *CommandResponseEnvelope)
CommandResponseEnvelopeOption is returned by the various WithX functions and accepted by NewCommandResponseEnvelope.
func WithError ¶ added in v0.9.0
func WithError(title string, err error, code int16) CommandResponseEnvelopeOption
WithError sets Data.Error, Data.ExitCode, Response.Lines, Response.Out, Response.Structured, Response.Title, and Payload (as err.Error).
func WithExitCode ¶ added in v0.9.0
func WithExitCode(code int16) CommandResponseEnvelopeOption
WithExitCode sets Data.ExitCode. It does NOT set
func WithResponseLines ¶ added in v0.9.0
func WithResponseLines(r []string) CommandResponseEnvelopeOption
WithResponseLines sets Response.Lines, Response.Out, Response.Structured, and Payload.
type DatabaseConfigs ¶
type DatabaseConfigs struct {
Host string `yaml:"host,omitempty"`
Port int `yaml:"port,omitempty"`
User string `yaml:"user,omitempty"`
Password string `yaml:"password,omitempty"`
SSLEnabled bool `yaml:"ssl_enabled,omitempty"`
ConnectionMaxIdleTime time.Duration `yaml:"connection_max_idle_time,omitempty"`
ConnectionMaxLifetime time.Duration `yaml:"connection_max_life_time,omitempty"`
MaxIdleConnections int `yaml:"max_idle_connections,omitempty"`
MaxOpenConnections int `yaml:"max_open_connections,omitempty"`
QueryTimeout time.Duration `yaml:"query_timeout,omitempty"`
}
DatabaseConfigs is the data wrapper for the "database" section.
type DiscordProvider ¶ added in v0.8.4
type DiscordProvider struct {
AbstractProvider `yaml:",inline"`
BotToken string `yaml:"bot_token,omitempty"`
}
DiscordProvider is the data wrapper for a Discord App provider.
type DockerConfigs ¶
type DockerConfigs struct {
DockerHost string `yaml:"host,omitempty"`
Network string `yaml:"network,omitempty"`
}
DockerConfigs is the data wrapper for the "docker" section.
type GlobalConfigs ¶
GlobalConfigs is the data wrapper for the "global" section
type GortConfig ¶
type GortConfig struct {
GortServerConfigs GortServerConfigs `yaml:"gort,omitempty"`
GlobalConfigs GlobalConfigs `yaml:"global,omitempty"`
DatabaseConfigs DatabaseConfigs `yaml:"database,omitempty"`
DockerConfigs DockerConfigs `yaml:"docker,omitempty"`
JaegerConfigs JaegerConfigs `yaml:"jaeger,omitempty"`
KubernetesConfigs KubernetesConfigs `yaml:"kubernetes,omitempty"`
SlackProviders []SlackProvider `yaml:"slack,omitempty"`
DiscordProviders []DiscordProvider `yaml:"discord,omitempty"`
Templates Templates `yaml:"templates,omitempty"`
}
GortConfig is the top-level configuration object
type GortServerConfigs ¶
type GortServerConfigs struct {
AllowSelfRegistration bool `yaml:"allow_self_registration,omitempty"`
APIAddress string `yaml:"api_address,omitempty"`
APIURLBase string `yaml:"api_url_base,omitempty"`
DevelopmentMode bool `yaml:"development_mode,omitempty"`
EnableSpokenCommands bool `yaml:"enable_spoken_commands,omitempty"`
TLSCertFile string `yaml:"tls_cert_file,omitempty"`
TLSKeyFile string `yaml:"tls_key_file,omitempty"`
}
GortServerConfigs is the data wrapper for the "gort" section.
type JaegerConfigs ¶
type JaegerConfigs struct {
Endpoint string `yaml:"endpoint,omitempty"`
Password string `yaml:"password,omitempty"`
Username string `yaml:"username,omitempty"`
}
JaegerConfigs is the data wrapper for the "jaeger" section.
type KubernetesConfigs ¶ added in v0.9.0
type KubernetesConfigs struct {
Namespace string `yaml:"namespace,omitempty"`
EndpointFieldSelector string `yaml:"endpoint_field_selector,omitempty"`
EndpointLabelSelector string `yaml:"endpoint_label_selector,omitempty"`
PodFieldSelector string `yaml:"pod_field_selector,omitempty"`
PodLabelSelector string `yaml:"pod_label_selector,omitempty"`
}
KubernetesConfigs is the data wrapper for the "kubernetes" section.
type Provider ¶
type Provider interface{}
Provider is the general interface for all providers. Currently only Slack is supported, with HipChat coming in time.
type SlackProvider ¶
type SlackProvider struct {
AbstractProvider `yaml:",inline"`
IconURL string `yaml:"icon_url,omitempty"`
// App and Bot tokens, used for Socket mode.
AppToken string `yaml:"app_token,omitempty"`
BotToken string `yaml:"bot_token,omitempty"`
// Deprecated, used for Classic Slack apps
APIToken string `yaml:"api_token,omitempty"`
}
SlackProvider is the data wrapper for a Slack App provider.
type TemplateType ¶ added in v0.9.0
type TemplateType string
const ( // Command templates are used to format the outputs from successfully // executed commands. Command TemplateType = "command" // CommandError templates are used to format the error messages produced // by commands that return with a non-zero status. CommandError TemplateType = "command_error" // Message templates are used to format standard informative (non-error) // messages from the Gort system (not commands). Message TemplateType = "message" // MessageError templates are used to format error messages from the Gor // system (not commands). MessageError TemplateType = "message_error" )
type Templates ¶ added in v0.9.0
type Templates struct {
// Command templates are used to format the outputs from successfully
// executed commands.
Command string `yaml:"command,omitempty" json:"command,omitempty"`
// CommandError templates are used to format the error messages produced
// by commands that return with a non-zero status.
CommandError string `yaml:"command_error,omitempty" json:"command_error,omitempty"`
// Message templates are used to format standard informative (non-error)
// messages from the Gort system (not commands).
Message string `yaml:"message,omitempty" json:"message,omitempty"`
// MessageError templates are used to format error messages from the Gort
// system (not commands).
MessageError string `yaml:"message_error,omitempty" json:"message_error,omitempty"`
}
Templates describes (or not) a set of templates that can be used to format command output. It is used in several places, including bundles, bundle commands, and the application config.