data

package
v0.3.0-dev.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

README

This package includes data containers that are shared between the Cog server and the relay or API service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 {
	Name        string                   `yaml:"name,omitempty"`
	Description string                   `yaml:"description,omitempty"`
	Docker      BundleDocker             `yaml:"docker,omitempty"`
	Commands    map[string]BundleCommand `yaml:"commands,omitempty"`
}

Bundle represents a bundle as defined in the "bundles" section of the config.

type BundleCommand

type BundleCommand struct {
	Description string   `yaml:"description,omitempty"`
	Executable  []string `yaml:"executable,omitempty"`
	Name        string   `yaml:"-"`
}

BundleCommand represents a bundle command, as defined in the "bundles/commands" section of the config.

type BundleDocker

type BundleDocker struct {
	Image string `yaml:"image,omitempty"`
	Tag   string `yaml:"tag,omitempty"`
}

BundleDocker represents the "bundles/docker" subsection of the config doc

type CogConfig

type CogConfig struct {
	CogServerConfigs CogServerConfigs `yaml:"cog,omitempty"`
	GlobalConfigs    GlobalConfigs    `yaml:"global,omitempty"`
	DatabaseConfigs  DatabaseConfigs  `yaml:"database,omitempty"`
	DockerConfigs    DockerConfigs    `yaml:"docker,omitempty"`
	SlackProviders   []SlackProvider  `yaml:"slack,omitempty"`
	BundleConfigs    []Bundle         `yaml:"bundles,omitempty"`
}

CogConfig is the top-level configuration object

type CogServerConfigs

type CogServerConfigs struct {
	AllowSelfRegistration bool   `yaml:"allow_self_registration,omitempty"`
	APIAddress            string `yaml:"api_address,omitempty"`
	APIURLBase            string `yaml:"api_url_base,omitempty"`
	EnableSpokenCommands  bool   `yaml:"enable_spoken_commands,omitempty"`
}

CogServerConfigs is the data wrapper for the "cog" section.

type CommandEntry

type CommandEntry struct {
	Bundle  Bundle
	Command BundleCommand
}

CommandEntry conveniently wraps a bundle and one command within that bundle.

type CommandRequest

type CommandRequest struct {
	CommandEntry
	Adapter    string   // The name of the adapter this request originated from.
	ChannelID  string   // The channel that the request originated in.
	UserID     string   // The ID of the user making thise request.
	Parameters []string // Tokenized command parameters
}

CommandRequest represents a user command request as triggered in (probably) a chat provider.

func (CommandRequest) CommandString

func (r CommandRequest) CommandString() string

CommandString is a convenience method that outputs the normalized command string, more or less as the user typed it.

type CommandResponse

type CommandResponse struct {
	Command CommandRequest
	Status  int64
	Title   string   // Command Error
	Output  []string // Contents of the commands stdout.
	Error   error
}

CommandResponse is returned by a relay to indicate that a command has been executed. It includes the original CommandRequest, the command's exit status code, and the commands entire stdout as a slice of lines. Title can be used to build a user output message, and generally contains a short description of the result.

TODO Add a request ID that correcponds with the request, so that we can more directly link it back to its user and adapter of origin.

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"`
	PoolSize     int    `yaml:"pool_size,omitempty"`
	PoolTimeout  int    `yaml:"pool_timeout,omitempty"`
	QueryTimeout int    `yaml:"query_timeout,omitempty"`
}

DatabaseConfigs is the data wrapper for the "database" section.

type DockerConfigs

type DockerConfigs struct {
	DockerHost string `yaml:"host,omitempty"`
}

DockerConfigs is the data wrapper for the "docker" section. This will move into the relay config(s) eventually.

type GlobalConfigs

type GlobalConfigs struct {
	CommandTimeoutSeconds int `yaml:"command_timeout_seconds,omitempty"`
}

GlobalConfigs is the data wrapper for the "global" 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"`
	APIToken         string `yaml:"api_token,omitempty"`
	IconURL          string `yaml:"icon_url,omitempty"`
}

SlackProvider is the data wrapper for a Slack provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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