config

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2016 License: MIT Imports: 13 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// LocalConfigDirname is the directory relative to the repository root
	// that is being used to store all SalsaFlow-related files.
	LocalConfigDirname = ".salsaflow"

	// LocalConfigFilename is the filename of the configuration file
	// that represents local project-specific SalsaFlow configuration.
	//
	// This file is expected to be placed in the repository root.
	LocalConfigFilename = "config.json"
)
View Source
const (
	// GlobalConfigFilename is the filename of the configuration file
	// that represents global user-specific SalsaFlow configuration.
	//
	// This file is expected to be placed in the user's home directory,
	// although the location can be configured by a command line flag.
	GlobalConfigFilename = ".salsaflow.json"
)

Variables

This section is empty.

Functions

func EnsureValueFilled added in v0.16.0

func EnsureValueFilled(value interface{}, path string) error

EnsureValueFilled returns an error in case the value passed in is not set.

The function checks structs and slices recursively.

func GlobalConfigFileAbsolutePath

func GlobalConfigFileAbsolutePath() (string, error)

func LocalConfigDirectoryAbsolutePath

func LocalConfigDirectoryAbsolutePath() (string, error)

LocalConfigFileAbsolutePath returns the absolute path of the local configuration directory.

func LocalConfigFileAbsolutePath added in v0.16.0

func LocalConfigFileAbsolutePath() (string, error)

LocalConfigFileAbsolutePath returns the absolute path of the local configuration file.

func Marshal added in v0.16.0

func Marshal(v interface{}) ([]byte, error)

func Unmarshal added in v0.16.0

func Unmarshal(in []byte, v interface{}) error

func WriteGlobalConfig added in v0.16.0

func WriteGlobalConfig(config *GlobalConfig) error

WriteGlobalConfig writes the given configuration struct into the global configuration file.

In case the target path does not exist, it is created, including the parent directories.

In case the file exists, it is truncated.

func WriteLocalConfig added in v0.16.0

func WriteLocalConfig(config *LocalConfig) error

WriteLocalConfig writes the given configuration struct into the global configuration file.

In case the target path does not exist, it is created, including the parent directories.

In case the file exists, it is truncated.

Types

type ConfigRecord added in v0.16.0

type ConfigRecord struct {
	RawConfig []byte
	// contains filtered or unexported fields
}

func (*ConfigRecord) Path added in v0.16.0

func (ms *ConfigRecord) Path() string

type ConfigurationsSection added in v0.16.0

type ConfigurationsSection struct {
	Records map[string]*json.RawMessage `json:"configuration"`
}

func (*ConfigurationsSection) ConfigRecord added in v0.16.0

func (section *ConfigurationsSection) ConfigRecord(configKey string) (*ConfigRecord, error)

func (*ConfigurationsSection) SetConfigRecord added in v0.16.0

func (section *ConfigurationsSection) SetConfigRecord(configKey string, rawConfig []byte)

type ErrConfigRecordNotFound added in v0.16.0

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

ErrConfigRecordNotFound is returned from ConfigurationsSection.ConfigRecord when the section specified by the given module kind cannot be found.

func (*ErrConfigRecordNotFound) Error added in v0.16.0

func (err *ErrConfigRecordNotFound) Error() string

type ErrKeyInvalid

type ErrKeyInvalid struct {
	Key   string
	Value interface{}
}

ErrKeyInvalid can be returned when a configuration value is not valid.

func (*ErrKeyInvalid) Error

func (err *ErrKeyInvalid) Error() string

type ErrKeyNotSet

type ErrKeyNotSet struct {
	Key string
}

ErrKeyNotSet is returned when a configuration key is not set.

func (*ErrKeyNotSet) Error

func (err *ErrKeyNotSet) Error() string

type GlobalConfig added in v0.16.0

type GlobalConfig struct {
	*ConfigurationsSection
}

func NewEmptyGlobalConfig added in v0.16.0

func NewEmptyGlobalConfig() *GlobalConfig

func ReadGlobalConfig added in v0.16.0

func ReadGlobalConfig() (*GlobalConfig, error)

ReadGlobalConfig reads and parses the global configuration file and returns a struct representing the content.

func (*GlobalConfig) SaveChanges added in v0.16.0

func (global *GlobalConfig) SaveChanges() error

type LocalConfig added in v0.16.0

type LocalConfig struct {
	EnabledTimestamp *time.Time `json:"salsaflow_enabled_timestamp"`

	Modules struct {
		IssueTracking string `json:"issue_tracking"`
		CodeReview    string `json:"code_review"`
		ReleaseNotes  string `json:"release_notes"`
	} `json:"active_modules,omitempty"`

	*ConfigurationsSection
}

LocalConfig represents the local configuration file content.

func NewEmptyLocalConfig added in v0.16.0

func NewEmptyLocalConfig() *LocalConfig

func ReadLocalConfig added in v0.16.0

func ReadLocalConfig() (*LocalConfig, error)

ReadLocalConfig reads and parses the global configuration file and returns a struct representing the content.

func (*LocalConfig) SaveChanges added in v0.16.0

func (local *LocalConfig) SaveChanges() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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