config

package
v0.0.0-...-deb4dbf Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrScope = "config"

	ErrCodeParameter = 1
)

Variables

This section is empty.

Functions

func CheckFileWritable

func CheckFileWritable(path string) bool

Check this file path is writable. Will create directories first.

func SplitID

func SplitID(id string) (owner, name string, err error)

Types

type Cli

type Cli struct {
	DisableProgressBar bool `yaml:"disable_progress_bar"`
}

type Config

type Config struct {
	ConfigPath    string `yaml:"config"`
	AccessToken   string `yaml:"access_token" validate:"required"`
	MaxConcurrent int    `yaml:"max_concurrent"`
	LogRespHead   int    `yaml:"log_resp_head"`
	StartPoint    `yaml:"start_point"`
	Network       Net     `yaml:"network"`
	Output        Output  `yaml:"output"`
	Github        Github  `yaml:"github"`
	Cli           Cli     `yaml:"cli"`
	Log           Loggers `yaml:"log"`
}

func GetConfig

func GetConfig(cp ConfigParser) (Config, error)

func NewProtectedConfig

func NewProtectedConfig(config Config) Config

func (*Config) Validate

func (c *Config) Validate() error

type ConfigParser

type ConfigParser interface {
	Parse() (Config, error)
}

type Github

type Github struct {
	HTMLHost string `yaml:"html_host"`
	ApiHost  string `yaml:"api_host"`
}

type Logger

type Logger struct {
	Level   string `yaml:"level"`
	Path    string `yaml:"path"`
	Console bool   `yaml:"console"`
}

type Loggers

type Loggers struct {
	Main Logger `yaml:"main"`
	Http Logger `yaml:"http"`
}

type Net

type Net struct {
	RetryTime     int           `yaml:"retry_time"`
	RetryInterval time.Duration `yaml:"retry_interval"`
}

type Output

type Output struct {
	Path string `yaml:"path"`
}

type StartPoint

type StartPoint struct {
	Path          string `yaml:"path" validate:"required"`
	ID            github.RepoID
	SectionFilter []string
}

type YAMLParser

type YAMLParser struct {
	// contains filtered or unexported fields
}

func NewYAMLParser

func NewYAMLParser(fpath string) (*YAMLParser, error)

func (*YAMLParser) Parse

func (p *YAMLParser) Parse() (Config, error)

Jump to

Keyboard shortcuts

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