config

package
v0.0.0-...-26d883c Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config provides the main configuration for dockerbot

Index

Constants

View Source
const (
	// DefaultIdleTimeout defines the default time after which a session is terminated
	DefaultIdleTimeout = 10 * time.Minute

	// DefaultMaxTotalSessions is the default number of sessions all users are allowed to run concurrently
	DefaultMaxTotalSessions = 6

	// DefaultMaxUserSessions is the default number of sessions a user is allowed to run concurrently
	DefaultMaxUserSessions = 2

	// DefaultRecord defines if sessions are recorded by default
	DefaultRecord = false

	// DefaultUploadRecording defines if session recording are uploaded to asciinema
	DefaultUploadRecording = false

	// DefaultWeb defines if sessions have a web terminal by default
	DefaultWeb = false
)
View Source
const (
	Slack   = Platform("slack")
	Discord = Platform("discord")
	Mem     = Platform("mem")
)

All possible Platform constants

View Source
const (
	DefaultControlMode = Split
	Thread             = ControlMode("thread")
	Channel            = ControlMode("channel")
	Split              = ControlMode("split")
)

All possible ControlMode constants

View Source
const (
	DefaultWindowMode = Full
	Full              = WindowMode("full")
	Trim              = WindowMode("trim")
)

All possible WindowMode constants

View Source
const (
	DefaultAuthMode = Everyone
	OnlyMe          = AuthMode("only-me")
	Everyone        = AuthMode("everyone")
)

All possible AuthMode constants

View Source
const (
	CursorOff = time.Duration(0)
	CursorOn  = time.Duration(1)
)

Constants used to toggle the cursor on or off

Variables

View Source
var (
	Tiny   = &Size{"tiny", 60, 15}
	Small  = &Size{"small", 80, 24}
	Medium = &Size{"medium", 100, 30}
	Large  = &Size{"large", 120, 38}

	DefaultSize = Small
	Sizes       = map[string]*Size{
		Tiny.Name:   Tiny,
		Small.Name:  Small,
		Medium.Name: Medium,
		Large.Name:  Large,
	}
)

All possible Size constants

Functions

This section is empty.

Types

type AuthMode

type AuthMode string

AuthMode defines who is allowed to interact with the session by default

type Config

type Config struct {
	Token              string
	ScriptDir          string
	IdleTimeout        time.Duration
	MaxTotalSessions   int
	MaxUserSessions    int
	DefaultControlMode ControlMode
	DefaultWindowMode  WindowMode
	DefaultAuthMode    AuthMode
	DefaultSize        *Size
	DefaultWeb         bool
	WebHost            string
	ShareHost          string
	ShareKeyFile       string
	DefaultRecord      bool
	UploadRecording    bool
	Cursor             time.Duration
	RefreshInterval    time.Duration
	Debug              bool
}

Config is the main config struct for the application. Use New to instantiate a default config struct.

func New

func New(token string) *Config

New instantiates a default new config

func (*Config) Platform

func (c *Config) Platform() Platform

Platform returns the target connection type, based on the token

func (*Config) Script

func (c *Config) Script(name string) string

Script returns the path to the script with the given name. If a script with the given name does not exist, the result may be empty.

func (*Config) Scripts

func (c *Config) Scripts() []string

Scripts returns the names of all available scripts

func (*Config) ShareEnabled

func (c *Config) ShareEnabled() bool

ShareEnabled returns true if the share features is enabled

type ControlMode

type ControlMode string

ControlMode defines where the control channel and where the terminal will be opened, see config.yml for details

type Platform

type Platform string

Platform defines the target chat application platform

type Size

type Size struct {
	Name   string
	Width  int
	Height int
}

Size defines the dimensions of the terminal

func ParseSize

func ParseSize(size string) (*Size, error)

ParseSize converts a size string to a Size

func (*Size) Max

func (s *Size) Max(other *Size) *Size

Max returns the larger size of the two given sizes

type WindowMode

type WindowMode string

WindowMode defines whether white spaces are trimmed from the terminal

Jump to

Keyboard shortcuts

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