config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) interface{}

func Init

func Init(opts ...Option) error

func Load

func Load() error

func Scan

func Scan(key string, to interface{}) error

func Set

func Set(key string, value interface{})

func String

func String() string

Types

type AgentConfig

type AgentConfig struct {
	Watchers `mapstructure:"watchers"`
	Server   ServerConfig      `mapstructure:"server"`
	Retry    map[string]string `mapstructure:"retry"`
}

type Config

type Config interface {
	Init(opts ...Option) error
	Get(key string) interface{}
	Set(key string, value interface{})
	Scan(key string, value interface{}) error
	Load() error
	String() string
}

func NewConfig

func NewConfig(opts ...Option) (Config, error)

func NewViperConfig

func NewViperConfig(opts ...Option) (Config, error)

type ConfigOption

type ConfigOption struct {
	// Path of config file
	Path string
	// Cobra cmd
	Cmd *cobra.Command
}

type Option

type Option func(o *ConfigOption)

func WithCobraCmd

func WithCobraCmd(cmd *cobra.Command) Option

func WithConfigPath

func WithConfigPath(path string) Option

type ServerConfig

type ServerConfig struct {
	Host               string `mapstructure:"host"`
	Port               string `mapstructure:"port"`
	Store              string `mapstructure:"store"`
	Bucket             string `mapstructure:"bucket"`
	Endpoint           string `mapstructure:"endpoint"`
	AwsAccessKey       string `mapstructure:"aws_access_key"`
	AwsSecretKey       string `mapstructure:"aws_secret_key"`
	PathAddressingMode string `mapstructure:"path_addressing_mode"`
}

type Watcher

type Watcher struct {
	Watch string                   `mapstructure:"watch" json:"watch"`
	Tags  []map[string]interface{} `mapstructure:"tags" json:"tags"`
}

type Watchers

type Watchers []Watcher

Jump to

Keyboard shortcuts

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