config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_LOG_LEVEL   = "info"
	DEFAULT_PORT        = 8080
	DEFAULT_INTERVAL    = time.Duration(1 * time.Minute)
	DEFAULT_WORLD_DIR   = "/world"
	SERVER_TYPE_VANILLA = "vanilla"
	SERVER_TYPE_FORGE   = "forge"
	SERVER_TYPE_PAPER   = "paper"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel      string        `yaml:"logLevel,omitempty"`
	Port          int           `yaml:"port,omitempty"`
	Interval      time.Duration `yaml:"interval,omitempty"`
	ReduceMetrics bool          `yaml:"reduceMetrics,omitempty"`
	ServerType    string        `yaml:"server,omitempty"`
	DynmapEnabled bool          `yaml:"dynmap,omitempty"`
	WorldDir      string        `yaml:"world,omitempty"`
	RCON          RCONConfig    `yaml:"rcon,omitempty"`
	Remote        RemoteConfig  `yaml:"remote,omitempty"`
}

func DefaultConfig

func DefaultConfig() Config

Returns a Config with default values set

func LoadConfig

func LoadConfig(path string, env bool) (Config, error)

Loads config from file, returns error if config is invalid Arguments:

path: Path to config file
env: Determines if enviroment variables in the file will be expanded before decoding

RCON Parameters are validated inside the RCON package itself, so it is not checked here.

type ErrInvalidInterval

type ErrInvalidInterval struct {
	Interval time.Duration
}

func (*ErrInvalidInterval) Error

func (e *ErrInvalidInterval) Error() string

type ErrUnknownLogLevel

type ErrUnknownLogLevel struct {
	Level string
}

func (*ErrUnknownLogLevel) Error

func (e *ErrUnknownLogLevel) Error() string

type ErrUnknownServerType

type ErrUnknownServerType struct {
	Type string
}

func (*ErrUnknownServerType) Error

func (e *ErrUnknownServerType) Error() string

type RCONConfig

type RCONConfig struct {
	Enable   bool   `yaml:"enable"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Password string `yaml:"password"`
}

type RemoteConfig

type RemoteConfig struct {
	Enable   bool   `yaml:"enable"`
	URL      string `yaml:"url"`
	Instance string `yaml:"instance"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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