themekit: Index | Files

package env

import ""


Package Files

conf.go env.go


var (

    // ErrEnvDoesNotExist is returned when an environment that does not exist in the config is requested
    ErrEnvDoesNotExist = errors.New("environment does not exist in this environments list")
    // ErrEnvNotDefined is returned if the environment was found but had no config, this usually means poor conf
    ErrEnvNotDefined = errors.New("environment was found but not defined")
    // ErrNoEnvironmentsDefined is returned when trying to save an empty config
    ErrNoEnvironmentsDefined = errors.New("no environments defined, nothing to write")
    // ErrInvalidEnvironmentName is returned if an environment is trying to be set with a blank name
    ErrInvalidEnvironmentName = errors.New("environment name cannot be blank")
var Default = Env{
    Name:    "development",
    Timeout: 30 * time.Second,

Default is the default values for a environment

func SourceVariables Uses

func SourceVariables(flagpath string) error

SourceVariables will find the environment files for configuration and import their environment variables into the current running process

type Conf Uses

type Conf struct {
    Envs map[string]*Env
    // contains filtered or unexported fields

Conf is a map of configurations to their environment name.

func Load Uses

func Load(configPath string) (Conf, error)

Load will read in the file from the configPath provided and then unmarshal the data into conf.

func New Uses

func New(configPath string) Conf

New will build a new blank config

func (*Conf) Get Uses

func (c *Conf) Get(name string, overrides ...Env) (*Env, error)

Get will check if an environment exists and then return it. If the environment does not exists it will return an error

func (Conf) Save Uses

func (c Conf) Save() error

Save will write out the config to a file.

func (*Conf) Set Uses

func (c *Conf) Set(name string, initial Env, overrides ...Env) (*Env, error)

Set will set the environment value and then mixin any overrides passed in. The os overrides and defaults will also be mixed into the new environment

type Env Uses

type Env struct {
    Name         string        `yaml:"-" json:"-" env:"-"`
    Password     string        `yaml:"password,omitempty" json:"password,omitempty" env:"THEMEKIT_PASSWORD"`
    ThemeID      string        `yaml:"theme_id,omitempty" json:"theme_id,omitempty" env:"THEMEKIT_THEME_ID"`
    Domain       string        `yaml:"store" json:"store" env:"THEMEKIT_STORE"`
    Directory    string        `yaml:"directory,omitempty" json:"directory,omitempty" env:"THEMEKIT_DIRECTORY"`
    IgnoredFiles []string      `yaml:"ignore_files,omitempty" json:"ignore_files,omitempty" env:"THEMEKIT_IGNORE_FILES" envSeparator:":"`
    Proxy        string        `yaml:"proxy,omitempty" json:"proxy,omitempty" env:"THEMEKIT_PROXY"`
    Ignores      []string      `yaml:"ignores,omitempty" json:"ignores,omitempty" env:"THEMEKIT_IGNORES" envSeparator:":"`
    Timeout      time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" env:"THEMEKIT_TIMEOUT"`
    ReadOnly     bool          `yaml:"readonly,omitempty" json:"readonly,omitempty" env:"-"`
    Notify       string        `yaml:"notify,omitempty" json:"notify,omitempty" env:"THEMEKIT_NOTIFY"`

Env is the structure of a configuration for an environment.

Package env imports 15 packages (graph) and is imported by 5 packages. Updated 2019-09-19. Refresh now. Tools for package owners.