config

package
v3.0.0-alpha.3+incompa... Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2017 License: MIT Imports: 10 Imported by: 57

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir is the configured config home directory. All the cli-related config files live in this directory.

func Write

func Write(f filer) error

Write stores the config into a file.

Types

type APIConfig

type APIConfig struct {
	*Config
	BaseURL   string
	Endpoints map[string]string
}

APIConfig provides API-specific configuration values.

func NewAPIConfig

func NewAPIConfig() (*APIConfig, error)

NewAPIConfig loads the config file in the config directory.

func NewEmptyAPIConfig

func NewEmptyAPIConfig() *APIConfig

NewEmptyAPIConfig doesn't load the config from file or set default values.

func (*APIConfig) Load

func (cfg *APIConfig) Load(v *viper.Viper) error

Load reads a viper configuration into the config.

func (*APIConfig) SetDefaults

func (cfg *APIConfig) SetDefaults()

SetDefaults ensures that we have all the necessary settings for the API.

func (*APIConfig) URL

func (cfg *APIConfig) URL(key string) string

URL provides the API URL for a given endpoint key.

func (*APIConfig) Write

func (cfg *APIConfig) Write() error

Write stores the config to disk.

type CLIConfig

type CLIConfig struct {
	*Config
	Tracks Tracks
}

CLIConfig contains settings specific to the behavior of the CLI.

func NewCLIConfig

func NewCLIConfig() (*CLIConfig, error)

NewCLIConfig loads the config file in the config directory.

func NewEmptyCLIConfig

func NewEmptyCLIConfig() *CLIConfig

NewEmptyCLIConfig doesn't load the config from file or set default values.

func (*CLIConfig) Load

func (cfg *CLIConfig) Load(v *viper.Viper) error

Load reads a viper configuration into the config.

func (*CLIConfig) SetDefaults

func (cfg *CLIConfig) SetDefaults()

SetDefaults ensures that we have all the necessary settings for the CLI.

func (*CLIConfig) Validate

func (cfg *CLIConfig) Validate() error

Validate ensures that the config is valid. This is called before writing it.

func (*CLIConfig) Write

func (cfg *CLIConfig) Write() error

Write stores the config to disk.

type Config

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

Config is a wrapper around a viper configuration.

func New

func New(dir, name string) *Config

New creates a default config value for the given directory.

func (*Config) File

func (cfg *Config) File() string

File is the full path to the config file.

type Track

type Track struct {
	ID             string
	IgnorePatterns []string
	// contains filtered or unexported fields
}

Track holds the CLI-related settings for a track.

func NewTrack

func NewTrack(id string) *Track

func (*Track) AcceptFilename

func (t *Track) AcceptFilename(f string) (bool, error)

func (*Track) CompileRegexes

func (t *Track) CompileRegexes() error

func (*Track) SetDefaults

func (t *Track) SetDefaults()

type Tracks

type Tracks map[string]*Track

Tracks is a collection of track-specific settings.

type UserConfig

type UserConfig struct {
	*Config
	Workspace string
	Token     string
	Home      string
}

UserConfig contains user-specific settings.

func NewEmptyUserConfig

func NewEmptyUserConfig() *UserConfig

NewEmptyUserConfig creates a user configuration without loading it.

func NewUserConfig

func NewUserConfig() (*UserConfig, error)

NewUserConfig loads a user configuration if it exists.

func (*UserConfig) Load

func (cfg *UserConfig) Load(v *viper.Viper) error

Load reads a viper configuration into the config.

func (*UserConfig) Normalize

func (cfg *UserConfig) Normalize()

Normalize ensures that we have proper values where possible.

func (*UserConfig) Write

func (cfg *UserConfig) Write() error

Write stores the config to disk.

Jump to

Keyboard shortcuts

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