config

package
v2.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: MIT Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug   bool          `toml:"debug"`
	LogPath string        `toml:"log_path"`
	HTTP    *HTTP         `toml:"http"`
	Server  []*EtcdServer `toml:"server"`
	Users   []*User       `toml:"user"`
}

Config 配置

func GetCfg

func GetCfg() *Config

GetCfg 获取配置

func LoadConfig

func LoadConfig(cfgPath string) (*Config, error)

LoadConfig 读取配置

func (*Config) GetUserByUsername

func (c *Config) GetUserByUsername(username string) *User

GetUserByUsername 根据用户名获取用户信息

type EtcdServer

type EtcdServer struct {
	Title     string         `toml:"title"`
	Name      string         `toml:"name"`
	Address   []string       `toml:"address"`
	Username  string         `toml:"username"`
	Password  string         `toml:"password"`
	KeyPrefix string         `toml:"key_prefix"`
	Desc      string         `toml:"desc"`
	TLSEnable bool           `toml:"tls_enable"` // 是否启用tls连接
	TLSConfig *EtcdTLSConfig `toml:"tls_config"` // 启用tls时必须配置此内容
	Roles     []string       `toml:"roles"`      // 可访问此etcd服务的角色列表
}

EtcdServer etcd 服务

func GetEtcdServer

func GetEtcdServer(name string) *EtcdServer

GetEtcdServer 根据服务标识查找服务

type EtcdTLSConfig

type EtcdTLSConfig struct {
	CertFile string `toml:"cert_file"`
	KeyFile  string `toml:"key_file"`
	CAFile   string `toml:"ca_file"`
}

EtcdTLSConfig etcd tls配置

type HTTP

type HTTP struct {
	Address               string   `toml:"address"`
	Port                  int      `toml:"port"`
	TLSEnable             bool     `toml:"tls_enable"`               // 是否启用tls连接
	TLSConfig             *HTTPTls `toml:"tls_config"`               // 启用tls时必须配置此内容
	TLSEncryptEnable      bool     `toml:"tls_encrypt_enable"`       // 是否启用 Let's Encrypt tls
	TLSEncryptDomainNames []string `toml:"tls_encrypt_domain_names"` // 启用 Let's Encrypt 时的域名列表
}

HTTP http 件套配置

type HTTPTls

type HTTPTls struct {
	CertFile string `toml:"cert_file"`
	KeyFile  string `toml:"key_file"`
}

HTTPTls http tls配置

type User

type User struct {
	Username string `toml:"username"`
	Password string `toml:"password"`
	Role     string `toml:"role"`
}

User 用户

Jump to

Keyboard shortcuts

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