config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config contains a Config struct for QingCloud SDK.

Index

Constants

View Source
const DefaultConfigFile = "~/.qingcloud/config.yaml"

DefaultConfigFile is the default config file.

View Source
const DefaultConfigFileContent = `` /* 351-byte string literal not displayed */

DefaultConfigFileContent is the default config file content.

Variables

This section is empty.

Functions

func GetUserConfigFilePath

func GetUserConfigFilePath() string

GetUserConfigFilePath returns the user config file path.

func InstallDefaultUserConfig

func InstallDefaultUserConfig() error

InstallDefaultUserConfig install the default user config file.

Types

type Config

type Config struct {
	AccessKeyID     string `yaml:"qy_access_key_id"`
	SecretAccessKey string `yaml:"qy_secret_access_key"`

	Host              string `yaml:"host"`
	Port              int    `yaml:"port"`
	Protocol          string `yaml:"protocol"`
	URI               string `yaml:"uri"`
	ConnectionRetries int    `yaml:"connection_retries"`
	ConnectionTimeout int    `yaml:"connection_timeout"`

	JSONDisableUnknownFields bool   `yaml:"json_disable_unknown_fields"`
	LogLevel                 string `yaml:"log_level"`
	Zone                     string `yaml:"zone"`

	Connection *http.Client
}

A Config stores a configuration of this sdk.

func LoadConfigFromContent

func LoadConfigFromContent(content []byte) (*Config, error)

LoadConfigFromContent loads configuration from a given byte slice. It returns error if yaml decode failed.

func LoadConfigFromFilepath

func LoadConfigFromFilepath(filepath string) (*Config, error)

LoadConfigFromFilepath loads configuration from a specified local path. It returns error if file not found or yaml decode failed.

func LoadUserConfig

func LoadUserConfig() (*Config, error)

LoadUserConfig loads user configuration in ~/.qingcloud/config.yaml for Config. It returns error if file not found.

func MustLoadUserConfig

func MustLoadUserConfig() *Config

MustLoadUserConfig loads user configuration in ~/.qingcloud/config.yaml for Config. It panic if failed.

func New

func New(accessKeyID, secretAccessKey string) (*Config, error)

New create a Config with given AccessKeyID and SecretAccessKey.

func NewDefault

func NewDefault() (*Config, error)

NewDefault loads the default configuration for Config.

func (*Config) LoadConfigFromContent

func (c *Config) LoadConfigFromContent(content []byte) error

LoadConfigFromContent loads configuration from a given byte slice. It returns error if yaml decode failed.

func (*Config) LoadConfigFromFilepath

func (c *Config) LoadConfigFromFilepath(filepath string) error

LoadConfigFromFilepath loads configuration from a specified local path. It returns error if file not found or yaml decode failed.

func (*Config) LoadDefaultConfig

func (c *Config) LoadDefaultConfig() error

LoadDefaultConfig loads the default configuration for Config. It returns error if yaml decode failed.

func (*Config) LoadUserConfig

func (c *Config) LoadUserConfig() error

LoadUserConfig loads user configuration in ~/.qingcloud/config.yaml for Config. It returns error if file not found.

Jump to

Keyboard shortcuts

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