dotcfg

package
v0.0.0-...-dd6e5a6 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirName        = ".cfg"         // this dir resides in ./
	FileName       = ".cfg.json"    // this file resides in ./
	KeyfileName    = "key.json"     // this file resides in ./.cfg/
	SnapsFileName  = "snaps.json"   // this file resides in ./.cfg/
	SchemasDirName = ".cfg_schemas" // this file resides in ./
)

Variables

This section is empty.

Functions

func GetAbsAndRelPaths

func GetAbsAndRelPaths(baseDir, filePath string) (string, string, error)

GetAbsAndRelPaths takes a baseDir and an absolute or relative (to cwd) file path. The absolute file path and relative (to baseDir) file paths are returned, along with any errors which occured.

func GetBaseDir

func GetBaseDir() (string, error)

func GetRelativeToBaseDir

func GetRelativeToBaseDir(baseDir, filePath string) (string, error)

GetRelativeToBaseDir takes a baseDir and a filePath. The relative path from baseDir to filePath is returned. If filePath stats with /, it is interpreted as an absolute path. Otherwise, it is is interpreted as a relative path.

Types

type File

type File struct {
	Templates  []Template  `json:"templates"`
	Instances  []Instance  `json:"instances"`
	Singletons []Singleton `json:"singletons"`
	NoGit      bool        `json:"noGit"`
}

.cfg.json is tracked by git

func LoadCfg

func LoadCfg(baseDir string) (*File, error)

func MustLoadCfg

func MustLoadCfg(baseDir string) *File

func NewCfg

func NewCfg() *File

func (*File) Commit

func (cfg *File) Commit(baseDir string) error

func (*File) CommitSelf

func (cfg *File) CommitSelf(baseDir string) error

func (*File) GetUntrackedFiles

func (cfg *File) GetUntrackedFiles() ([]string, error)

func (*File) Infer

func (cfg *File) Infer(baseDir, filePath string) error

Infer takes a baseDir and a filePath which is either an absolute path or a path relative to the cwd.

func (*File) MustCommit

func (cfg *File) MustCommit(baseDir string)

func (*File) MustRmSchema

func (cfg *File) MustRmSchema(target string, onlyFromIndex bool)

func (*File) MustSerialize

func (f *File) MustSerialize(baseDir string, tx *rollback.Tx)

func (*File) MustStage

func (cfg *File) MustStage(baseDir string)

func (*File) MustStageSelf

func (cfg *File) MustStageSelf(baseDir string)

func (*File) MustWarnDiffs

func (cfgFile *File) MustWarnDiffs(baseDir, templName, instFilePath string, wErr io.Writer)

func (*File) RmSchema

func (cfg *File) RmSchema(target string, onlyFromIndex bool) error

func (*File) Serialize

func (cfgFile *File) Serialize(baseDir string, tx *rollback.Tx) error

Serialize serializes the cfgfile at the given destination. If the destination is an empty string, cwd is used instead.

func (*File) Stage

func (cfg *File) Stage(baseDir string) error

func (*File) StageSelf

func (cfg *File) StageSelf(baseDir string) error

func (*File) WarnDiffs

func (cfgFile *File) WarnDiffs(baseDir, templName, instFilePath string, wErr io.Writer) error

type FileInfo

type FileInfo interface {
	Name() string
	IsDir() bool
}

type Instance

type Instance struct {
	FilePath   string     `json:"filePath"`
	TemplNames []string   `json:"templateName"`
	Schema     JSONSchema `json:"schema"`
}

func NewInstance

func NewInstance(filePath string) *Instance

type JSONSchema

type JSONSchema struct {
	FilePath string `json:"filePath"`
}

type Key

type Key struct {
	Email    string            `json:"email"`
	Remotes  map[string]string `json:"remotes"`
	BaseName string            `json:"baseName"`
}

everything in .cfg/ (including .cfg/key.json) is not tracked by git

func MustLoadKey

func MustLoadKey(baseDir string) *Key

func NewKey

func NewKey(baseName string) *Key

func (*Key) MustSerialize

func (k *Key) MustSerialize(baseDir string, tx *rollback.Tx)

func (*Key) Serialize

func (k *Key) Serialize(baseDir string, tx *rollback.Tx) error

type Schemas

type Schemas struct {
	BaseDir string
}

func NewSchemas

func NewSchemas(baseDir string) *Schemas

type SentinelFileInfo

type SentinelFileInfo struct{}

func (SentinelFileInfo) IsDir

func (s SentinelFileInfo) IsDir() bool

func (SentinelFileInfo) Name

func (s SentinelFileInfo) Name() string

type Singleton

type Singleton struct {
	FilePath string     `json:"filePath"`
	Schema   JSONSchema `json:"schema"`
}

type Snaps

type Snaps struct {
	Current   Snapshot   `json:"current"`
	Snapshots []Snapshot `json:"snapshots"`
}

everything in .cfg/ (including .cfg/snaps) is not tracked by git however, snaps are pushed to Confbase servers

func MustLoadSnaps

func MustLoadSnaps(baseDir string) *Snaps

func NewSnaps

func NewSnaps() *Snaps

func (*Snaps) MustSerialize

func (s *Snaps) MustSerialize(baseDir string, tx *rollback.Tx)

func (*Snaps) Serialize

func (s *Snaps) Serialize(baseDir string, tx *rollback.Tx) error

type Snapshot

type Snapshot struct {
	Name string `json:"name"`
}

type Template

type Template struct {
	Name     string     `json:"name"`
	FilePath string     `json:"filePath"`
	Schema   JSONSchema `json:"schema"`
}

Jump to

Keyboard shortcuts

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