sync

package
v0.0.0-...-9bb7583 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Logger *logger.SyncLogger
)

Functions

func CreateTempfile

func CreateTempfile() *os.File

func CreateTempfileWithContent

func CreateTempfileWithContent(content ...string) *os.File

func FileExists

func FileExists(name string) bool

func PathExists

func PathExists(name string) bool

func RsyncPath

func RsyncPath(name string) string

func ShellErrorHandler

func ShellErrorHandler(recover interface{})

Types

type Database

type Database struct {
	// Type of database (either mysql or postgres)
	Type string `yaml:"type"`
	// Database name on remote database server
	Db string `yaml:"database"`
	// Hostname of remote database server
	Hostname string `yaml:"hostname"`
	// Port of remote database server
	Port string `yaml:"port"`
	// Username of remote database server
	User string `yaml:"user"`
	// Password of remote database server
	Password string `yaml:"password"`

	// Table filter
	Filter Filter `yaml:"filter"`
	// Connection for database sync (optional, default is Server connection)
	Connection *YamlCommandBuilderConnection `yaml:"connection"`
	// Database options
	Options DatabaseOptions `yaml:"options"`

	Local struct {
		// Database name on local database server
		Db string `yaml:"database"`
		// Hostname of local database server
		Hostname string `yaml:"hostname"`
		// Port of local database server
		Port string `yaml:"port"`
		// Username of local database server
		User string `yaml:"user"`
		// Password of local database server
		Password string `yaml:"password"`

		// Connection for database sync (optional, default is empty)
		Connection *YamlCommandBuilderConnection `yaml:"connection"`

		// Database options
		Options DatabaseOptions `yaml:"options"`
	} `yaml:"local"`
	// contains filtered or unexported fields
}

func (*Database) ApplyDefaults

func (database *Database) ApplyDefaults(server *Server)

func (*Database) Deploy

func (database *Database) Deploy()

func (*Database) GetMysql

func (database *Database) GetMysql() DatabaseMysql

func (*Database) GetPostgres

func (database *Database) GetPostgres() DatabasePostgres

func (*Database) GetType

func (database *Database) GetType() (dbtype string)

func (*Database) String

func (database *Database) String(direction string) string

func (*Database) Sync

func (database *Database) Sync()

type DatabaseMysql

type DatabaseMysql struct {
	Database
}

type DatabaseOptions

type DatabaseOptions struct {
	// Clear database with DROP/CREATE before sync
	ClearDatabase bool `yaml:"clear-database"`
	// Arguments for mysqldump command
	Mysqldump *YamlStringArray `yaml:"mysqldump"`
	// Arguments for mysql command
	Mysql *YamlStringArray `yaml:"mysql"`
	// Arguments for pgdump command
	Pgdump *YamlStringArray `yaml:"pgdump"`
	// Arguments for psql command
	Psql *YamlStringArray `yaml:"psql"`
}

type DatabasePostgres

type DatabasePostgres struct {
	Database
}

type EnvironmentVar

type EnvironmentVar struct {
	// Name of variable
	Name string `yaml:"name"`
	// Value of variable
	Value string `yaml:"value"`
}

type Execution

type Execution struct {
	// Type of execution (remote or local)
	Type string `yaml:"type"`
	// Command as string or as elements
	Command YamlStringArray `yaml:"command"`
	// Workdir for execution
	Workdir string `yaml:"workdir"`

	// Environment variables
	Environment []EnvironmentVar `yaml:"environment"`

	// Execution options
	Options struct {
	} `yaml:"options"`
}

func (*Execution) Execute

func (execution *Execution) Execute(server *Server)

func (*Execution) GetType

func (execution *Execution) GetType() (execType string)

Get execution type (local or remote)

func (*Execution) String

func (execution *Execution) String(server *Server) string

type Filesystem

type Filesystem struct {
	// Remove path
	Path string `yaml:"path"`
	// Local path (optional)
	Local string `yaml:"local"`
	// Filter
	Filter Filter `yaml:"filter"`
	// Connection for filesystem sync (optional, default is Server connection)
	Connection *YamlCommandBuilderConnection `yaml:"connection"`
	Options    FilesystemOptions             `yaml:"options"`
}

func (*Filesystem) ApplyDefaults

func (filesystem *Filesystem) ApplyDefaults(server *Server)

func (*Filesystem) Deploy

func (filesystem *Filesystem) Deploy()

General sync

func (*Filesystem) String

func (filesystem *Filesystem) String(direction string) string

func (*Filesystem) Sync

func (filesystem *Filesystem) Sync()

General sync

func (*Filesystem) SyncStubs

func (filesystem *Filesystem) SyncStubs()

General sync

type FilesystemOptions

type FilesystemOptions struct {
	// Generate stubs (small example files) instead of fetching files from remote
	GenerateStubs bool `yaml:"generate-stubs"`
	// Arguments for psql command
	Rsync *YamlStringArray `yaml:"rsync"`
}

type Filter

type Filter struct {
	// Exclude as strings (regexp)
	Exclude []string `yaml:"exclude"`

	// Includes as strings (regexp)
	Include []string `yaml:"include"`
	// contains filtered or unexported fields
}

func (*Filter) ApplyFilter

func (filter *Filter) ApplyFilter(lines []string) []string

Apply filter (exclude/include) and get filtered list

func (*Filter) CalcExcludes

func (filter *Filter) CalcExcludes(lines []string) []string

Apply exclude filter only and get filtered excludes

func (*Filter) CalcIncludes

func (filter *Filter) CalcIncludes(lines []string) []string

Apply includes filter only and get filtered includes

type RunConfiguration

type RunConfiguration struct {
	// Enable database sync
	Database bool
	// Enable filesystem sync
	Filesystem bool
	// Enable exec runner
	Exec bool
}

type Server

type Server struct {
	// General working path (for filesystem syncs)
	Path string `yaml:"path"`
	// General connection (default for all remote connections)
	Connection *YamlCommandBuilderConnection `yaml:"connection"`
	// Filesystem sync list
	Filesystem []Filesystem `yaml:"filesystem"`
	// Database sync list
	Database []Database `yaml:"database"`
	// Startup execution list (executed before sync)
	ExecStartup []Execution `yaml:"exec-startup"`
	// Finish execution list (executed after sync)
	ExecFinish []Execution `yaml:"exec-finish"`
	// contains filtered or unexported fields
}

func (*Server) AsYaml

func (server *Server) AsYaml() string

func (*Server) Deploy

func (server *Server) Deploy()

func (*Server) DeployDatabases

func (server *Server) DeployDatabases()

func (*Server) DeployFilesystem

func (server *Server) DeployFilesystem()

func (*Server) GetExecByWhen

func (server *Server) GetExecByWhen(when string) []Execution

func (*Server) GetLocalPath

func (server *Server) GetLocalPath() string

func (*Server) Init

func (server *Server) Init()

func (*Server) RunExec

func (server *Server) RunExec(when string)

func (*Server) SetRunConfiguration

func (server *Server) SetRunConfiguration(conf RunConfiguration)

func (*Server) Sync

func (server *Server) Sync()

func (*Server) SyncDatabases

func (server *Server) SyncDatabases()

func (*Server) SyncFilesystem

func (server *Server) SyncFilesystem()

type SyncConfig

type SyncConfig struct {
	// Sync (remote -> local) configurations
	Sync map[string]Server `yaml:"sync"`
	// Deploy (local -> remote) configurations
	Deploy map[string]Server `yaml:"deploy"`
}

func NewConfigParser

func NewConfigParser(file string) (config *SyncConfig)

func (*SyncConfig) GetDeployServer

func (config *SyncConfig) GetDeployServer(serverName string) (Server, error)

func (*SyncConfig) GetServerList

func (config *SyncConfig) GetServerList(confType string) (list []string)

func (*SyncConfig) GetSyncServer

func (config *SyncConfig) GetSyncServer(serverName string) (Server, error)

func (*SyncConfig) ListServer

func (config *SyncConfig) ListServer() (list map[string][]string)

List all possible server configurations

func (*SyncConfig) ShowConfiguration

func (config *SyncConfig) ShowConfiguration()

Show all possible server configurations in an human readable style

type YamlCommandBuilderArgument

type YamlCommandBuilderArgument struct {
	commandbuilder.Argument
}

func (*YamlCommandBuilderArgument) String

func (ysa *YamlCommandBuilderArgument) String() string

func (*YamlCommandBuilderArgument) UnmarshalYAML

func (yarg *YamlCommandBuilderArgument) UnmarshalYAML(unmarshal func(interface{}) error) error

type YamlCommandBuilderConnection

type YamlCommandBuilderConnection struct {
	Type   string
	Ssh    *YamlCommandBuilderArgument
	Docker *YamlCommandBuilderArgument

	Environment *map[string]string
	Workdir     string
	// contains filtered or unexported fields
}

func (*YamlCommandBuilderConnection) Clone

Clone yaml connection (without shell connection instance)

func (*YamlCommandBuilderConnection) GetInstance

Get (or create) connection instance will be cached one it's created

func (*YamlCommandBuilderConnection) IsEmpty

func (yconn *YamlCommandBuilderConnection) IsEmpty() (status bool)

Checks if connection is empty

type YamlStringArray

type YamlStringArray struct {
	Multi  []string
	Single string
}

func (*YamlStringArray) Array

func (ysa *YamlStringArray) Array() (command []string)

func (*YamlStringArray) String

func (ysa *YamlStringArray) String() string

func (*YamlStringArray) ToString

func (ysa *YamlStringArray) ToString(sep string) string

func (*YamlStringArray) UnmarshalYAML

func (ysa *YamlStringArray) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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