catalog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultName = "stash.yml"

DefaultName is the default catalog name.

Variables

This section is empty.

Functions

func GroupByService

func GroupByService(files map[string]File) map[string]map[string]File

GroupByService ...

func GroupByServiceSlice

func GroupByServiceSlice(files map[string]File) map[string][]File

GroupByServiceSlice ...

func Save

func Save(file string, c Catalog) error

Save ...

Types

type ByPath

type ByPath []File

func (ByPath) Len

func (f ByPath) Len() int

func (ByPath) Less

func (f ByPath) Less(i, j int) bool

func (ByPath) Swap

func (f ByPath) Swap(i, j int)

type Catalog

type Catalog struct {
	Version string `yaml:"version"`

	Context string `yaml:"context"`

	AutoClean bool `yaml:"clean" mapstructure:"clean"`

	Files map[string]File `yaml:"files"`
}

Catalog is reference file for the stashed configuration files.

func ExpandEnv

func ExpandEnv(c Catalog) (Catalog, error)

func Init

func Init(context, catalogFile string, dep InitDep) (Catalog, error)

Init creates a new or loads an existing catalog file.

func Read

func Read(catalogFile string) (Catalog, error)

Read loads an existing catalog file.

func (*Catalog) AddFile

func (c *Catalog) AddFile(key, filePath, service string, tags []string) error

AddFile ...

func (*Catalog) Filter

func (c *Catalog) Filter(filter Filter) map[string]File

Filter ...

func (*Catalog) GetFile

func (c *Catalog) GetFile(path string) (File, bool)

GetFile ...

func (*Catalog) LookupService

func (c *Catalog) LookupService(filePath string) string

func (*Catalog) MergeResults

func (c *Catalog) MergeResults(files []service.File)

MergeResults ...

type File

type File struct {
	// Path is the local location.
	Path string `yaml:"path"`

	// Type is the local file type. (e.g. env,json,txt,etc.)
	Type string `yaml:"type,omitempty"`

	// Service specifies the remote service.
	Service string `yaml:"service,omitempty"`

	// Options allow services to persist user preferences locally.
	Options map[string]string `yaml:"opt,omitempty" mapstructure:"opt"`

	// Keys allows services to track which fields are stashed.
	Keys []string `yaml:"keys,omitempty"`

	// Tags allow files to be grouped; so, they can be listed, purged,
	// and restored in a single command.
	Tags []string `yaml:"tags,omitempty"`

	// Clean deletes the local files after changes have been pushed
	// to the remote service.
	Clean bool `yaml:"clean,omitempty"`
}

File represents a configuration file that is remotely stashed. All fields in this model should be safe to be shared and checked into source control.

func (*File) AddTag

func (f *File) AddTag(tag string)

AddTag ...

func (*File) LookupState

func (f *File) LookupState(context string) (State, error)

LookupState ...

func (*File) Matches

func (f *File) Matches(filter Filter) bool

Matches ...

func (*File) RecordState

func (f *File) RecordState(context string) error

RecordState ...

func (*File) RemoveTag

func (f *File) RemoveTag(tag string)

RemoveTag ...

func (File) ToServiceModel

func (f File) ToServiceModel(context, key string, remote service.IService, data []byte) (service.File, error)

ToServiceModel ...

type Filter

type Filter struct {
	Files []string
	Tags  []string

	Service string
}

Filter ...

func NewGetFilter

func NewGetFilter(files, tags []string, service string) Filter

NewGetFilter ...

func NewPushFilter

func NewPushFilter(files, tags []string, service string) Filter

NewPushFilter ...

func (Filter) Empty

func (f Filter) Empty() bool

Empty ...

func (Filter) Format

func (f Filter) Format(delimiter string) string

Format ...

type InitDep

type InitDep struct {
	Stdin  *os.File
	Stdout *os.File
	Stderr *os.File
}

InitDep ...

type State

type State struct {
	Synced time.Time
}

Jump to

Keyboard shortcuts

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