config

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Name:   "default",
	Host:   "http://localhost:8086",
	Active: true,
}

DefaultConfig is default config without token

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string `toml:"-" json:"-"`
	Host string `toml:"url" json:"url"`
	// Token is base64 encoded sequence.
	Token          string `toml:"token" json:"token"`
	Org            string `toml:"org" json:"org"`
	Active         bool   `toml:"active,omitempty" json:"active,omitempty"`
	PreviousActive bool   `toml:"previous,omitempty" json:"previous,omitempty"`
}

Config store the crendentials of influxdb host and token.

func ParseActiveConfig

func ParseActiveConfig(r io.Reader) (Config, error)

ParseActiveConfig returns the active config from the reader.

type Configs

type Configs map[string]Config

Configs is map of configs indexed by name.

func (Configs) Active

func (cfgs Configs) Active() Config

func (Configs) Switch

func (cfgs Configs) Switch(name string) error

Switch to another config.

type Service

type Service interface {
	CreateConfig(Config) (Config, error)
	DeleteConfig(name string) (Config, error)
	UpdateConfig(Config) (Config, error)
	SwitchActive(name string) (Config, error)
	ListConfigs() (Configs, error)
}

Service is the service to list and write configs.

func NewLocalConfigSVC

func NewLocalConfigSVC(path, dir string) Service

NewLocalConfigSVC create a new local config svc.

Jump to

Keyboard shortcuts

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