dot

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DecodeErrorUnused mapstructure decode option
	DecodeErrorUnused = true // TODO false if opts.Force

	// DecodeWeaklyTypedInput mapstructure decode option
	DecodeWeaklyTypedInput = true

	// Stdout writer
	Stdout io.Writer = os.Stdout
	// Stderr writer
	Stderr io.Writer = os.Stderr
	// Stdin reader
	Stdin io.Reader = os.Stdin
)
View Source
var (
	// ErrExist used when task is installed
	ErrExist = errors.New("already exists")

	// ErrNotExist ...
	ErrNotExist = errors.New("does not exists")

	// ErrFileExist ...
	ErrFileExist = errors.New("file exists")

	// ErrLinkExist ...
	ErrLinkExist = errors.New("link exists")

	// ErrNotEmpty ...
	ErrNotEmpty = errors.New("not empty")

	// ErrDirNotEmpty ...
	ErrDirNotEmpty = errors.New("directory not empty")

	// ErrSkip task
	ErrSkip = errors.New("skip")

	// ErrInvalid ...
	ErrInvalid = errors.New("invalid file")
)
View Source
var (
	// Action contains the running command name
	Action string
)

Functions

func FindConfig

func FindConfig(path, dirname string) string

FindConfig searches a given file name or path relative to the home directory, or falls back to ~/.dot/config

func IsExist

func IsExist(err error) bool

IsExist error

func IsNotExist

func IsNotExist(err error) bool

IsNotExist error

func IsSkip

func IsSkip(err error) bool

IsSkip error

Types

type Block

type Block struct {
	Task   `mapstructure:",squash"` // Action, If, OS
	Target string                   // Target file
	Data   string                   // Block content
}

Block task

func NewBlock

func NewBlock(s, d string) *Block

NewBlock task

func (*Block) Do

func (t *Block) Do() error

Do task

func (*Block) Init

func (t *Block) Init() error

Init task

func (*Block) Status

func (t *Block) Status() error

Status check task

func (*Block) String

func (t *Block) String() string

func (*Block) Undo

func (t *Block) Undo() error

Undo task

type Config

type Config struct {
	Source    string
	Target    string
	Roles     []*Role
	Platforms map[string][]*Role
	Git       *url.URL
	// contains filtered or unexported fields
}

Config struct

func NewConfig

func NewConfig(path, dirname string) (*Config, error)

NewConfig ...

func (*Config) FileUsed

func (c *Config) FileUsed() string

FileUsed path

func (*Config) Load

func (c *Config) Load() error

Load config from file

func (*Config) ParseRoles

func (c *Config) ParseRoles() error

ParseRoles config

func (*Config) PrepareRoles

func (c *Config) PrepareRoles() error

PrepareRoles config

func (*Config) SetRoleFile

func (c *Config) SetRoleFile(name string)

SetRoleFile name

type Copy

type Copy struct {
	Task   `mapstructure:",squash"` // Action, If, OS
	Source string
	Target string
	Mode   os.FileMode
}

Copy task

func (*Copy) Do

func (t *Copy) Do() error

Do task

func (*Copy) Init

func (t *Copy) Init() error

Init task

func (*Copy) RemoteString

func (t *Copy) RemoteString() string

RemoteString command

func (*Copy) Status

func (t *Copy) Status() error

Status check task

func (*Copy) String

func (t *Copy) String() string

func (*Copy) Undo

func (t *Copy) Undo() error

Undo task

type DiffError

type DiffError struct {
	Src, Dst string
	Full     string
}

DiffError ...

func (*DiffError) Error

func (e *DiffError) Error() string

func (*DiffError) String

func (e *DiffError) String() string

Full diff ouput

type Dir

type Dir struct {
	Task `mapstructure:",squash"` // Action, If, OS
	Path string
}

Dir task

func NewDir

func NewDir(s string) *Dir

NewDir task

func (*Dir) Do

func (t *Dir) Do() error

Do task

func (*Dir) Init

func (t *Dir) Init() error

Init task

func (*Dir) Status

func (t *Dir) Status() error

Status check task

func (*Dir) String

func (t *Dir) String() string

func (*Dir) Undo

func (t *Dir) Undo() error

Undo task unless the directory is not empty.

type Env

type Env map[string]string

Env map

func NewEnv

func NewEnv(i interface{}) *Env

NewEnv vars

type Hook

type Hook struct {
	Task    `mapstructure:",squash"` // Action, If, OS
	Command string
	Shell   string
	Env     *Env
	ExecDir string
}

Hook command to execute FIXME: fmt.Println(t) -> stack exceeds limit

func NewHook

func NewHook(s string) *Hook

NewHook task

func (*Hook) Do

func (t *Hook) Do() error

Do task (install, post_install)

func (*Hook) Init

func (t *Hook) Init() error

Init task

func (*Hook) Status

func (t *Hook) Status() error

Status check task

func (*Hook) String

func (t *Hook) String() string

func (*Hook) Undo

func (t *Hook) Undo() error

Undo task (remove, post_remove)

type Line

type Line struct {
	Task   `mapstructure:",squash"` // Action, If, OS
	Target string                   // Target file
	Data   string                   // Line content
}

Line task

func NewLine

func NewLine(s, d string) *Line

NewLine task

func (*Line) Do

func (t *Line) Do() error

Do task

func (*Line) Init

func (t *Line) Init() error

Init task

func (*Line) Status

func (t *Line) Status() error

Status check task

func (*Line) String

func (t *Line) String() string

func (*Line) Undo

func (t *Line) Undo() error

Undo task

type Link struct {
	Task   `mapstructure:",squash"` // Action, If, OS
	Source string
	Target string
}

Link task

func NewLink(s string) *Link

NewLink task

func (*Link) Do

func (t *Link) Do() error

Do task

func (*Link) Init

func (t *Link) Init() error

Init task

func (*Link) Status

func (t *Link) Status() error

Status check task

func (*Link) String

func (t *Link) String() string

func (*Link) Undo

func (t *Link) Undo() error

Undo task

type OpError

type OpError struct {
	Op   string
	Task Tasker
	Err  error
}

OpError ...

func (*OpError) Error

func (e *OpError) Error() string

type Pkg

type Pkg struct {
	Task    `mapstructure:",squash"` // Action, If, OS
	Name    []string
	Args    []string
	Manager string `mapstructure:"type"`
}

Pkg task

func NewPkg

func NewPkg(s string) *Pkg

NewPkg task

func (*Pkg) Do

func (t *Pkg) Do() error

Do task

func (*Pkg) Init

func (t *Pkg) Init() error

Init task

func (*Pkg) Status

func (t *Pkg) Status() error

Status check task

func (*Pkg) String

func (t *Pkg) String() string

func (*Pkg) Undo

func (t *Pkg) Undo() error

Undo task

type Role

type Role struct {
	Name string
	Path string
	URL  string   // Git repository URL
	Git  *url.URL // repo host and user

	Disabled bool `mapstructure:",omitempty"`

	OS          []string
	Env         *Env
	Vars        *Vars
	IncludeVars []string

	Deps []string `mapstructure:"depends"`
	Pkgs []*Pkg   `mapstructure:"pkg"`

	Dirs   []*Dir   `mapstructure:"dir"`
	Files  []*Copy  `mapstructure:"copy"`
	Links  []*Link  `mapstructure:"link"`
	Tpls   []*Tpl   `mapstructure:"template"`
	Lines  []*Line  `mapstructure:"line"`
	Blocks []*Block `mapstructure:"block"`

	Install     []*Hook
	PostInstall []*Hook `mapstructure:"post_install"`
	Remove      []*Hook
	PostRemove  []*Hook `mapstructure:"post_remove"`
	// contains filtered or unexported fields
}

Role struct

func (*Role) GetConfigFile

func (r *Role) GetConfigFile() string

GetConfigFile path

func (*Role) Init

func (r *Role) Init() error

Init role before install or remove

func (*Role) Load

func (r *Role) Load() error

Load role config

func (*Role) Ok

func (r *Role) Ok() bool

Ok returns true if the role already installed.

func (*Role) Parse

func (r *Role) Parse(target string) error

Parse all role tasks

func (*Role) ParseBlocks

func (r *Role) ParseBlocks(target string) error

ParseBlocks tasks

func (*Role) ParseDirs

func (r *Role) ParseDirs(target string) error

ParseDirs tasks

func (*Role) ParseEnv

func (r *Role) ParseEnv() error

ParseEnv must be executed before all tasks using it.

func (*Role) ParseFiles

func (r *Role) ParseFiles(target string) error

ParseFiles tasks

func (*Role) ParseHooks

func (r *Role) ParseHooks(target string) error

ParseHooks tasks

func (*Role) ParseLines

func (r *Role) ParseLines(target string) error

ParseLines tasks

func (r *Role) ParseLinks(target string) error

ParseLinks tasks

func (*Role) ParseTpls

func (r *Role) ParseTpls(target string) error

ParseTpls tasks

func (*Role) ParseVars

func (r *Role) ParseVars() error

ParseVars role

func (*Role) SetConfigFile

func (r *Role) SetConfigFile(name string) *Role

SetConfigFile path

func (*Role) ShouldRun

func (r *Role) ShouldRun() bool

ShouldRun check

func (*Role) Status

func (r *Role) Status() error

Status reports the state of all tasks of the role, failing at the first encountered.

func (*Role) StatusBlocks

func (r *Role) StatusBlocks() error

StatusBlocks ...

func (*Role) StatusDirs

func (r *Role) StatusDirs() error

StatusDirs ...

func (*Role) StatusFiles

func (r *Role) StatusFiles() error

StatusFiles ...

func (*Role) StatusHooks

func (r *Role) StatusHooks() error

StatusHooks ...

func (*Role) StatusLines

func (r *Role) StatusLines() error

StatusLines ...

func (r *Role) StatusLinks() error

StatusLinks ...

func (*Role) StatusPkgs

func (r *Role) StatusPkgs() error

StatusPkgs ...

func (*Role) StatusTpls

func (r *Role) StatusTpls() error

StatusTpls ...

func (*Role) String

func (r *Role) String() (s string)

func (*Role) Sync

func (r *Role) Sync() (string, error)

Sync role repository TODO update role URL?

type RoleConfig

type RoleConfig struct {
	Role *Role // `mapstructure:",squash"`
}

RoleConfig struct

type Task

type Task struct {
	Tasker
	// Action specifies a single action for which the task should be run
	Action string   `mapstructure:",omitempty"`
	OS     []string `mapstructure:",omitempty"`
	If     []string `mapstructure:",omitempty"`
}

Task struct

func (*Task) Check

func (t *Task) Check() error

Check conditions

func (*Task) CheckAction

func (t *Task) CheckAction() error

CheckAction task

func (*Task) CheckIf

func (t *Task) CheckIf() error

CheckIf task

func (*Task) CheckOS

func (t *Task) CheckOS() error

CheckOS task

func (*Task) String

func (t *Task) String() string

type Tasker

type Tasker interface {
	String() string
	Init() error
	Status() error
	// Sync() error
	Do() error
	Undo() error

	// Already implemented
	CheckAction() error
	CheckOS() error
	CheckIf() error
	Check() error
}

Tasker interface

type Tpl

type Tpl struct {
	Task        `mapstructure:",squash"` // Action, If, OS
	Source      string
	Target      string
	Ext         string   // Template extenstion (default: tpl)
	Env         *Env     // map[string]string
	Vars        *Vars    // map[string]interface{}
	IncludeVars []string `mapstructure:"include_vars"`
	// contains filtered or unexported fields
}

Tpl task

func NewTpl

func NewTpl(s string) *Tpl

NewTpl task

func (*Tpl) Do

func (t *Tpl) Do() error

Do task

func (*Tpl) Init

func (t *Tpl) Init() error

Init task

func (*Tpl) Prepare

func (t *Tpl) Prepare() error

Prepare template task

func (*Tpl) PrepareEnv

func (t *Tpl) PrepareEnv() error

PrepareEnv role

func (*Tpl) PrepareVars

func (t *Tpl) PrepareVars() error

PrepareVars role

func (*Tpl) Status

func (t *Tpl) Status() error

Status check task

func (*Tpl) String

func (t *Tpl) String() string

func (*Tpl) Undo

func (t *Tpl) Undo() error

Undo task

type Vars

type Vars map[string]interface{}

Vars map

Jump to

Keyboard shortcuts

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