config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Repository     = "mattermost-plugin-apps"
	CommandTrigger = "apps"
	ManifestsFile  = "manifests.json"

	BotUsername    = "appsbot"
	BotDisplayName = "Mattermost Apps"
	BotDescription = "Mattermost Apps Registry and API proxy."
)

Internal configuration apps.of mattermost-plugin-apps

View Source
const (
	// TODO replace Interactive Dialogs with Modal, eliminate the need for
	// /dialog endpoints.
	InteractiveDialogPath = "/dialog"

	// Top-level path(s) for HTTP example apps.
	HelloHTTPPath = "/example/hello"

	// Path to the Call API
	// <>/<> TODO: ticket migrate to gateway
	PathCall = "/call"

	// Top-level path for the Apps namespaces, followed by /{AppID}/...
	PathApps = "/apps"

	// OAuth2 App's HTTP endpoints in the {PluginURL}/apps/{AppID} space.
	PathMattermostOAuth2Connect  = "/oauth2/mattermost/connect"
	PathMattermostOAuth2Complete = "/oauth2/mattermost/complete"
	PathRemoteOAuth2Connect      = "/oauth2/remote/connect"
	PathRemoteOAuth2Complete     = "/oauth2/remote/complete"

	// Static assets are served from {PluginURL}/static/...
	PathStatic = "/" + apps.StaticFolder

	// Marketplace sub-paths.
	PathMarketplace = "/marketplace"

	WebSocketEventRefreshBindings = "refresh_bindings"
)
View Source
const (
	PropTeamID    = "team_id"
	PropChannelID = "channel_id"
	PropPostID    = "post_id"
	PropUserAgent = "user_agent_type"
)
View Source
const (
	// KVAppPrefix is the Apps namespace. Short, maximize the app keyspace
	KVAppPrefix = "kv."

	// KVOAuth2Prefix is used to store OAuth2-related information (state,
	// tokens)
	KVOAuth2Prefix      = "o."
	KVOAuth2StatePrefix = "s."

	// KVSubPrefix is used for keys storing subscriptions.
	KVSubPrefix = "sub."

	// KVInstalledAppPrefix is used to store App records.
	KVInstalledAppPrefix = "app."

	// KVLocalManifestPrefix is used to store locally-listed manifests.
	KVLocalManifestPrefix = "man."

	// KVCallOnceKey and KVClusterMutexKey are used for invoking App Calls once,
	// usually upon a Mattermost instance startup.
	KVCallOnceKey     = "CallOnce"
	KVClusterMutexKey = "Cluster_Mutex"
)

KV namespace. The use of '.' in the prefixes is to avoid conflicts with base64 URL encoding that already uses '-' and '_'.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildConfig

type BuildConfig struct {
	model.Manifest
	BuildDate      string
	BuildHash      string
	BuildHashShort string
}

type Config

type Config struct {
	StoredConfig
	BuildConfig

	BotUserID              string
	MattermostSiteHostname string
	MattermostSiteURL      string
	PluginURL              string
	PluginURLPath          string

	// Maximum size of incoming remote webhook messages
	MaxWebhookSize int64
}

Config represents the the metadata handed to all request runners (command, http).

Config should be abbreviated as `conf`.

func (Config) AppPath added in v0.3.0

func (c Config) AppPath(appID apps.AppID) string

func (Config) SetContextDefaults added in v0.3.0

func (c Config) SetContextDefaults(cc *apps.Context) *apps.Context

func (Config) SetContextDefaultsForApp added in v0.3.0

func (c Config) SetContextDefaultsForApp(appID apps.AppID, cc *apps.Context) *apps.Context

type Configurable

type Configurable interface {
	Configure(Config)
}

type Service

type Service interface {
	GetConfig() Config
	GetMattermostConfig() *model.Config
	Reconfigure(StoredConfig, ...Configurable) error
	StoreConfig(sc StoredConfig) error
}

Configurator should be abbreviated as `cfg`

func NewService

func NewService(mattermost *pluginapi.Client, buildConfig BuildConfig, botUserID string) Service

type StoredConfig

type StoredConfig struct {
	// InstalledApps is a list of all apps installed on the Mattermost instance.
	//
	// For each installed app, an entry of string(AppID) -> sha1(App) is added,
	// and the App struct is stored in KV under app_<sha1(App)>. Implementation
	// in `store.App`.
	InstalledApps map[string]string `json:"installed_apps,omitempty"`

	// LocalManifests is a list of locally-stored manifests. Local is in
	// contrast to the "global" list of manifests which in the initial version
	// is loaded from S3.
	//
	// For each installed app, an entry of string(AppID) -> sha1(Manifest) is
	// added, and the Manifest struct is stored in KV under
	// manifest_<sha1(Manifest)>. Implementation in `store.Manifest`.
	LocalManifests map[string]string `json:"local_manifests,omitempty"`
}

StoredConfig represents the data stored in and managed with the Mattermost config.

StoredConfig should be abbreviated as sc.

type TestConfigurator added in v0.3.0

type TestConfigurator struct {
	// contains filtered or unexported fields
}

func NewTestConfigurator

func NewTestConfigurator(config Config) *TestConfigurator

func (*TestConfigurator) GetConfig added in v0.3.0

func (c *TestConfigurator) GetConfig() Config

func (*TestConfigurator) GetMattermostConfig added in v0.3.0

func (c *TestConfigurator) GetMattermostConfig() *model.Config

func (*TestConfigurator) Reconfigure added in v0.3.0

func (c *TestConfigurator) Reconfigure(StoredConfig, ...Configurable) error

func (*TestConfigurator) StoreConfig added in v0.3.0

func (c *TestConfigurator) StoreConfig(sc StoredConfig) error

func (TestConfigurator) WithMattermostConfig added in v0.3.0

func (c TestConfigurator) WithMattermostConfig(mmconfig model.Config) *TestConfigurator

Jump to

Keyboard shortcuts

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