config

package
v0.0.0-...-758a821 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Config Files Names
	ConfigFileName = "config.yml"
	StateFileName  = "state.yml"

	// RC File Names
	SpaceRCFileName   = ".wospacerc"
	WorkspaceFileName = ".worc"

	// UserConfigDir Env
	WO_CONFIG_DIR   = "WO_CONFIG_DIR"
	XDG_CONFIG_HOME = "XDG_CONFIG_HOME"
	APP_DATA        = "AppData"

	// WoConfigDir
	WoXDGConfigDir = "wo"
	WoAppDataDir   = "Wo CLI"
	WoHomeDir      = ".wo"
)

Variables

View Source
var (
	ErrConfigMapFieldNotFound    = "field value not found"
	ErrConfigMapInvalidFieldAddr = "invalid field addr"
	ErrConfigValidation          = "%s validation err: %s"
)
View Source
var (

	// Global Config for schemas
	ConfigGlobalSchema = []FieldSchema{
		{
			Key:          "last_scan_editor",
			Description:  "the last editor scan time",
			Rules:        []validation.Rule{},
			DefaultValue: 0,
		},
		authSchema,
		defaultsSchema,
		editorsSchema,
		spacesSchema,
	}
	// Schema of spaceRC (.wospace)
	SpaceRCSchema = []FieldSchema{
		defaultsSchema,
		actionsSchema,
		flowsSchema,
		cyclesSchema,
	}
	// Schema of workspaceRC (.worc)
	WorkspaceRCSchema = []FieldSchema{
		{
			Key:          "name",
			Description:  "",
			DefaultValue: "",
		},
		{
			Key:          "description",
			Description:  "",
			DefaultValue: "",
		},
		{
			Key:          "version",
			Description:  "",
			DefaultValue: "v0.1",
		},
		actionsSchema,
		flowsSchema,
		cyclesSchema,
		appsSchema,
	}
)

Functions

func ConfigDir

func ConfigDir() string

ConfigDir is Wo configuration dir path

Types

type Config

type Config interface {
	Get(string) interface{}
	GetString(string) string
	Set(string, interface{}) error
	UnSet(string) error
	Reset()
	Write() error
	Map() map[string]interface{}
}

func NewBlankConfig

func NewBlankConfig() (Config, error)

func NewConfig

func NewConfig(source string, schema []FieldSchema) (Config, error)

func NewGlobalConfig

func NewGlobalConfig() (Config, error)

type ConfigMap

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

func NewConfigMap

func NewConfigMap(root map[string]interface{}, schema []FieldSchema) *ConfigMap

func (*ConfigMap) Byte

func (cm *ConfigMap) Byte() ([]byte, error)

func (*ConfigMap) Get

func (cm *ConfigMap) Get(field string) interface{}

func (*ConfigMap) GetSchema

func (cm *ConfigMap) GetSchema(key string) (*FieldSchema, error)

func (*ConfigMap) GetString

func (cm *ConfigMap) GetString(field string) string

func (ConfigMap) Map

func (cm ConfigMap) Map() map[string]interface{}

func (*ConfigMap) Reset

func (cm *ConfigMap) Reset(field string) error

func (*ConfigMap) Set

func (cm *ConfigMap) Set(field string, val interface{}) error

type FieldSchema

type FieldSchema struct {
	Key          string
	Description  string
	Rules        []validation.Rule
	DefaultValue interface{}
}

Jump to

Keyboard shortcuts

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