config

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package config defines the structure of the configuration for the `dev` tool. I expect it to be YAML, but am providing support for JSON via the struct tags to keep the options open.

There's a global configuration instance which should be populated by the controller and consumed from all other parts of the view or controller layers.

Index

Constants

View Source
const (
	// RegexpFileName defines a regular expression pattern which is used
	// to decide whether a file is a `dev` configuration file based on
	// the file name
	RegexpFileName = `^\.dev(?P<label>\.[a-zA-Z0-9\-\_]+)*\.y(a)?ml$`
)

Variables

View Source
var Global = &Config{
	Dev:          Dev{},
	Links:        Links{},
	Networks:     Networks{},
	Platforms:    Platforms{},
	Softwares:    Softwares{},
	Repositories: Repositories{},
}

Global contains the global configuration usable by all CLI commands, all root properties are guaranteed to exist

View Source
var Loaded = map[string]Config{}

Loaded contains a dictionary of configurations where the key equals the file's absolute path and the value containing the loaded configuration

Functions

func FilterConfigurations added in v0.1.0

func FilterConfigurations(fileInfos []os.FileInfo) []os.FileInfo

FilterConfigurations accepts a list of `os.FileInfo` and returns a list of `os.FileInfo`s whose file names comply to the configuration file name pattern as defined by RegexpFileName

func GetFiles added in v0.1.0

func GetFiles(opt ...GetFilesOptions) ([]string, error)

GetFiles returns a list of absolute file paths corresponding to configuration files found in 1. the current user's home directory and 2. the current working directory

func PromptSelectLoadedConfiguration added in v0.1.6

func PromptSelectLoadedConfiguration(promptMessage string, useOtherReader ...io.Reader) (string, error)

PromptSelectLoadedConfiguration does a cli prompt to ask the user to select a loaded configuration for changes to be made

Types

type Config added in v0.0.7

type Config struct {
	Dev          Dev          `json:"dev" yaml:"dev,omitempty"`
	Links        Links        `json:"links" yaml:"links,omitempty"`
	Networks     Networks     `json:"networks" yaml:"networks,omitempty"`
	Platforms    Platforms    `json:"platforms" yaml:"platforms,omitempty"`
	Softwares    Softwares    `json:"softwares" yaml:"softwares,omitempty"`
	Repositories Repositories `json:"repositories" yaml:"repositories,omitempty"`
}

func NewFromFile

func NewFromFile(filePath string) (*Config, error)

NewFromFile is a convenience function that reads the configuration in from a file at the provided :filePath

func (*Config) MergeWith added in v0.0.7

func (f *Config) MergeWith(other *Config) []error

MergeWith merges the current Config configuration instance with a second provided :other Config configuration instance, intention for this is to merge a local configuration with a global configuration

type Dev

type Dev struct {
	Repository dev.Repository `json:"repository" yaml:"repository,omitempty"`
	Client     dev.Client     `json:"client" yaml:"client,omitempty"`
}

Dev specifies the configurations available for the CLI tool itself

func (*Dev) MergeWith added in v0.1.4

func (d *Dev) MergeWith(o Dev) []error

type GetFilesOptions added in v0.1.35

type GetFilesOptions struct {
	// ContextualWorkspacePath defines where to draw context specific configuration from
	ContextualWorkspacePath string
	// GlobalWorkspacePath defines where to draw globval configuration from
	GlobalWorkspacePath string
}

GetFilesOptions enables parameterisation of the GetFiles function by differentiating between the contextual configuration and the global configuration

type Links []link.Link

Links represents a list of links which the uesr should be able to access

func (*Links) MergeWith added in v0.0.7

func (l *Links) MergeWith(o Links)

MergeWith merges the current Links instance with a provided Links instance. The merge strategy is add-only

type Networks

type Networks []network.Network

Networks represents a list of networks that the user's machine should be able to connect to

func (*Networks) MergeWith added in v0.0.7

func (n *Networks) MergeWith(o Networks)

MergeWith merges the current Networks instance with a provided Networks instance. The merge strategy is add-only

type Platforms

type Platforms struct {
	PivotalTracker pivotaltracker.Config `json:"pivotaltracker" yaml:"pivotaltracker,omitempty"`
	Github         github.Config         `json:"github" yaml:"github,omitempty"`
	Gitlab         gitlab.Config         `json:"gitlab" yaml:"gitlab,omitempty"`
	Trello         trello.Config         `json:"trello" yaml:"trello,omitempty"`
}

Platforms specifies the configurations available

func (Platforms) GetSanitized

func (p Platforms) GetSanitized() Platforms

GetSanitized returns a sanitised deep copy of the current Platforms instance

type Repositories

type Repositories []repository.Repository

Repositories represents a list of repositories a user should have access to on their machines

func (Repositories) GetWorkspaces added in v0.0.15

func (r Repositories) GetWorkspaces() []string

GetWorkspaces returns a list of strings corresponding to all the workspaces listed in this instance of Repositories

func (Repositories) Len added in v0.1.2

func (r Repositories) Len() int

Len implements `sort.Interface`

func (Repositories) Less added in v0.1.2

func (r Repositories) Less(i, j int) bool

Less implements `sort.Interface`

func (*Repositories) MergeWith added in v0.0.8

func (r *Repositories) MergeWith(o Repositories)

MergeWith merges the current Repositories instance with a provided Repositories instance. The merge strategy is add-only

func (*Repositories) Sort added in v0.1.2

func (r *Repositories) Sort()

Sort sorts the repositories in alphabetical order

func (Repositories) Swap added in v0.1.2

func (r Repositories) Swap(i, j int)

Swap implements `sort.Interface`

type Softwares

type Softwares []software.Software

Softwares represents a list of software the user should have on their machine

func (*Softwares) MergeWith added in v0.0.8

func (s *Softwares) MergeWith(o Softwares)

MergeWith merges the current Softwares instance with a provided Softwares instance. The merge strategy is add-only

Directories

Path Synopsis
dev

Jump to

Keyboard shortcuts

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