config

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRequestTimeout time used to timeout all requests to Konstellation APIs.
	DefaultRequestTimeout = 2 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultRequestTimeout time.Duration  `yaml:"defaultRequestTimeout"`
	DefaultServer         string         `yaml:"defaultServer"`
	ServerList            []ServerConfig `yaml:"servers"`
	Debug                 bool
	// contains filtered or unexported fields
}

Config holds the configuration values for the application.

func NewConfig

func NewConfig() *Config

NewConfig will read the config.yml file from current user home.

func NewConfigTest

func NewConfigTest() *Config

NewConfigTest same as NewConfig but used during tests to create a new file on each test.

func (*Config) AddServer

func (c *Config) AddServer(server ServerConfig) error

AddServer adds a ServerConfig to the config file.

func (*Config) GetByServerName

func (c *Config) GetByServerName(name string) *ServerConfig

GetByServerName returns a ServerConfig for the given server name.

func (*Config) RenderServerList

func (c *Config) RenderServerList(r render.Renderer)

RenderServerList add server information to the renderer and show it.

func (*Config) Save

func (c *Config) Save() error

Save writes config to file.

func (*Config) SetDefaultServer

func (c *Config) SetDefaultServer(name string) error

SetDefaultServer marks a server name as default to be used when no server parameter is provided.

type ServerConfig

type ServerConfig struct {
	Name     string `yaml:"name"`
	URL      string `yaml:"url"`
	APIToken string `yaml:"token"`
}

ServerConfig contains data to represent a Konstellation server.

Jump to

Keyboard shortcuts

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