config

package
v0.0.0-...-b052d37 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientVersion = "0.1"
)

Variables

This section is empty.

Functions

func LoadOrInit

func LoadOrInit(name string) error

LoadOrInit loads default config from given file. If file not exists, it will create file, and returns default config.

func RemoveAlias

func RemoveAlias(alias string)

RemoveAlias remove alias from default Config.

func Save

func Save(name string) error

Save saves default config to file.

func SetAlias

func SetAlias(alias string, cfg *AliasConfig) bool

SetAlias sets an alias for default Config.

Types

type AliasConfig

type AliasConfig struct {
	URL       string `json:"url"`
	SecretID  string `json:"secretID"`
	SecretKey string `json:"secretKey"`
}

AliasConfig is a COS bucket config.

func GetAlias

func GetAlias(alias string) (*AliasConfig, bool)

GetAlias gets alias from default Config.

type Config

type Config struct {
	Version string                  `json:"version"`
	Aliases map[string]*AliasConfig `json:"aliases"`
	// contains filtered or unexported fields
}

Config is cos-cli config

func Default

func Default() *Config

Default returns the default config.

func Load

func Load(name string) (*Config, error)

Load loads default config from file.

func New

func New() *Config

New returns the default *Config.

func (*Config) GetAlias

func (c *Config) GetAlias(alias string) (*AliasConfig, bool)

GetAlias return the AliasConfig that named alias, if alias not exist, it returns nil, false.

func (*Config) Load

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

func (*Config) LoadOrInit

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

func (*Config) RemoveAlias

func (c *Config) RemoveAlias(alias string)

RemoveAlias removes alias from config.

func (*Config) Save

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

Save saves config to file.

func (*Config) SetAlias

func (c *Config) SetAlias(alias string, cfg *AliasConfig) bool

SetAlias sets alias config, if alias exists, it will be updated and return true.

func (*Config) WriteTo

func (c *Config) WriteTo(w io.Writer) (int64, error)

WriteTo writes config data to w.

Jump to

Keyboard shortcuts

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