config

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2020 License: MIT Imports: 22 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() ([]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) string

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 DevRepository `json:"repository" yaml:"repository,omitempty"`
	Client     DevClient     `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 DevClient

type DevClient struct {
	Database      DevClientDatabase      `json:"database" yaml:"database,omitempty"`
	Notifications DevClientNotifications `json:"notifications" yaml:"notifications,omitempty"`
	Platforms     DevClientPlatforms     `json:"platforms" yaml:"platforms,omitempty"`
}

DevClient holds configurations related to the CLI tool

func (*DevClient) MergeWith added in v0.1.4

func (dc *DevClient) MergeWith(o DevClient) []error

type DevClientDatabase

type DevClientDatabase struct {
	Path string `json:"path" yaml:"path,omitempty"`
}

DevClientDatabase holds configurations related to the data persistence mechanism of the CLI tool

func (*DevClientDatabase) MergeWith added in v0.1.4

func (dcdb *DevClientDatabase) MergeWith(o DevClientDatabase) []error

type DevClientNotifications

type DevClientNotifications struct {
	Telegram DevClientNotificationsTelegram `json:"telegram" yaml:"telegram,omitempty"`
}

DevClientNotifications holds configurations related to the notifications mechanisms of the CLI tool

func (*DevClientNotifications) MergeWith added in v0.1.4

type DevClientNotificationsTelegram

type DevClientNotificationsTelegram struct {
	Token string `json:"token" yaml:"token,omitempty"`
	ID    string `json:"id" yaml:"id,omitempty"`
}

DevClientNotificationsTelegram holds configurations related to the telegram integration for sending notifications

func (*DevClientNotificationsTelegram) MergeWith added in v0.1.4

type DevClientPlatforms added in v0.1.11

type DevClientPlatforms struct {
	Github DevClientPlatformsGithub `json:"github" yaml:"github,omitempty"`
}

DevClientPlatforms holds configurations related to the platform integrations for individual users

func (*DevClientPlatforms) MergeWith added in v0.1.11

func (dcp *DevClientPlatforms) MergeWith(o DevClientPlatforms) []error

type DevClientPlatformsGithub added in v0.1.11

type DevClientPlatformsGithub struct {
	ClientID     string `json:"clientId" yaml:"clientId,omitempty"`
	ClientSecret string `json:"clientSecret" yaml:"clientSecret,omitempty"`
	RedirectURI  string `json:"redirectUri" yaml:"redirectUri,omitempty"`
}

func (*DevClientPlatformsGithub) MergeWith added in v0.1.11

type DevRepository added in v0.1.14

type DevRepository struct {
	Templates []DevRepositoryTemplate `json:"templates" yaml:"templates,omitempty"`
}

DevRepository holds client configuration for operations related to repositories

func (*DevRepository) MergeWith added in v0.1.14

func (dr *DevRepository) MergeWith(o DevRepository) []error

type DevRepositoryTemplate added in v0.1.14

type DevRepositoryTemplate struct {
	Name string `json:"name" yaml:"name,omitempty"`
	URL  string `json:"url" yaml:"url,omitempty"`
	Path string `json:"path" yaml:"path,omitempty"`
}

DevRepositoryTemplate holds configurations related to repository templates that a user can use to initialise repositories on their machine

func (DevRepositoryTemplate) GetKey added in v0.1.14

func (drt DevRepositoryTemplate) GetKey() string

GetKey returns a (hopefully) unique identifer to use for de-duplicating multiple instances of DevRepositoryTemplates

func (DevRepositoryTemplate) String added in v0.1.18

func (drt DevRepositoryTemplate) String() string
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

Jump to

Keyboard shortcuts

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