caravan

package
v0.0.0-...-660c754 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSpec ...
	DefaultSpec = "master"
	// DefaultConfName ...
	DefaultConfName = "caravan.yml"
)

Variables

View Source
var DefaultConf = Conf{
	Source:      ".",
	Destination: ".",
	Mode:        deploy.ModeRSync,
	Incremental: true,
	Once:        false,
	Debug:       false,
	Exclude:     []string{".git", ".svn", "/node_modules"},
	ExtraArgs:   []string{},
	LogFormat:   "[%t] EVENT %e: %p",
	OnInit:      []string{},
	OnChange:    []string{},
	OnDeploy:    []string{},
	OnError:     []string{},
}

DefaultConf of Caravan

View Source
var ErrNoCommand = errors.New("No command attached")

ErrNoCommand ...

View Source
var PrintError = color.New(color.Bold, color.FgRed).PrintlnFunc()

PrintError print red text

View Source
var PrintNotice = fmt.Println

PrintNotice print normal text

View Source
var PrintSuccess = color.New(color.FgGreen).PrintlnFunc()

PrintSuccess print green text

View Source
var PrintWarning = color.New(color.Bold, color.FgYellow).PrintlnFunc()

PrintWarning print yellow text

Functions

func CaptureOutput

func CaptureOutput(f func()) string

CaptureOutput ...

func CreateDefault

func CreateDefault(path string) error

CreateDefault conf

func GetFileName

func GetFileName(path string) string

GetFileName extracts file name from path

func PrintLog

func PrintLog(text ...interface{})

PrintLog print text with time and other info

func ShowConf

func ShowConf(conf *Conf)

ShowConf prints conf

func WarningSound

func WarningSound()

WarningSound warning sound for error case

func Watch

func Watch(conf Conf, handleFunc HandleFunc)

Watch a path

Types

type Conf

type Conf struct {
	Source      string      `yaml:"src"`
	Destination string      `yaml:"dst"`
	Mode        deploy.Mode `yaml:"deploy_mode"`
	Once        bool        `yaml:"once"`
	Debug       bool        `yaml:"debug"`
	Incremental bool        `yaml:"incremental"`
	Exclude     []string    `yaml:"exclude"`
	ExtraArgs   []string    `yaml:"extra_args"`
	LogFormat   string      `yaml:"log_format"`
	OnInit      []string    `yaml:"on_init"`
	OnChange    []string    `yaml:"on_change"`
	OnDeploy    []string    `yaml:"on_deploy"`
	OnError     []string    `yaml:"on_error"`
}

Conf of van

func LoadFrom

func LoadFrom(path, spec string) (*Conf, error)

LoadFrom loads conf from path

type DeployOnceEI

type DeployOnceEI struct {
	SourcePath string
}

DeployOnceEI implements notify.EventInfo interface which is passed to events of DeployOnce

func (DeployOnceEI) Event

func (do DeployOnceEI) Event() notify.Event

Event returns event

func (DeployOnceEI) Path

func (do DeployOnceEI) Path() string

Path returns event path

func (DeployOnceEI) Sys

func (do DeployOnceEI) Sys() interface{}

Sys return sys as nil

type Event

type Event struct {
	EventType EventType
	Event     string
	Path      string
	Filename  string
}

Event body

func NewEmptyEvent

func NewEmptyEvent(et EventType) *Event

NewEmptyEvent creates an empty event with only event type

func NewEvent

func NewEvent(et EventType, ev string, path string, filename string) *Event

NewEvent creates an event

type EventCtrl

type EventCtrl struct {
	// contains filtered or unexported fields
}

EventCtrl for event scheduling

func NewEventCtrl

func NewEventCtrl(conf *Conf) *EventCtrl

NewEventCtrl creates an EventCtrl

func (*EventCtrl) EventLoop

func (ec *EventCtrl) EventLoop()

EventLoop starts event loop

func (EventCtrl) FireEvent

func (ec EventCtrl) FireEvent(event *Event)

FireEvent fires a event

type EventType

type EventType int8

EventType of a event

const (
	HookOnInit EventType = iota + 1
	HookOnChange
	HookOnDeploy
	HookOnError
)

Event hooks

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter for exclusion

func NewFilter

func NewFilter(patterns []string) *Filter

NewFilter creates a filter

func (*Filter) Exclude

func (f *Filter) Exclude(path string) (bool, error)

Exclude ...

type HandleFunc

type HandleFunc func(notify.EventInfo) error

HandleFunc of notify

type LogFormat

type LogFormat struct {
	// contains filtered or unexported fields
}

LogFormat handles user-level log Default: [%t] Event %e %p

func NewLogger

func NewLogger(format *string) *LogFormat

NewLogger create a LogFormat unit

func (LogFormat) Log

func (lf LogFormat) Log(event, path, filename string) string

Log input data as string

Jump to

Keyboard shortcuts

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