Documentation ¶
Overview ¶
Package sync provides the routines that determine which files need to be transfered to the deployment target. The actual deployment actions are delegated to functions provided by the caller to allow different deployment targets. Note that we assume there are no huge files here - the file contents are passed around as byte arrays for comparisons etc
Index ¶
- func DeployChanges(srcDir string, dstDir string, minify bool, handleFunc commandHandler, ...) error
- type CommandType
- type DeployCommand
- type DeployScanner
- type Deployer
- type FTPDeployer
- func (f *FTPDeployer) ApplyCommand(cmd *DeployCommand) error
- func (f *FTPDeployer) Cleanup() error
- func (f *FTPDeployer) GetName() string
- func (f *FTPDeployer) Initialise() error
- func (f *FTPDeployer) MakeDirectory(path string) error
- func (f *FTPDeployer) RemoveDirectory(path string) error
- func (f *FTPDeployer) RemoveFile(path string) error
- func (f *FTPDeployer) UploadFile(path string, data []byte) error
- type FileDeployer
- func (f *FileDeployer) ApplyCommand(cmd *DeployCommand) error
- func (f *FileDeployer) Cleanup() error
- func (f *FileDeployer) GetName() string
- func (f *FileDeployer) Initialise() error
- func (f *FileDeployer) MakeDirectory(path string) error
- func (f *FileDeployer) RemoveDirectory(path string) error
- func (f *FileDeployer) RemoveFile(path string) error
- func (f *FileDeployer) UploadFile(path string, data []byte) error
- type SFTPDeployer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeployChanges ¶
func DeployChanges(srcDir string, dstDir string, minify bool, handleFunc commandHandler, skipFiles []string) error
DeployChanges recursively walks through srcDir and compares each file with the equivalent location in dstDir. If minify is set, each file in srcDir will be minified in memory. If the file in srcDir differs from that in dstDir handleFunc is called with an ADD or UPD command. DeployChanges then walks the dstDir to see if there are any files there which are not in srcDir, in which case handleFunc is called with a DEL command
Types ¶
type CommandType ¶
type CommandType int
const ( COMMAND_FILE_ADD CommandType = 1 << iota COMMAND_DIR_ADD COMMAND_FILE_UPD COMMAND_FILE_DEL COMMAND_DIR_DEL )
type DeployCommand ¶
type DeployCommand struct { RelPath string Contents []byte Command CommandType }
func (*DeployCommand) GetCommandDesc ¶
func (cmd *DeployCommand) GetCommandDesc() string
type DeployScanner ¶
type DeployScanner struct {
// contains filtered or unexported fields
}
func (*DeployScanner) Sync ¶
func (d *DeployScanner) Sync(dst, src string) error
Sync copies files and directories inside src into dst.
type Deployer ¶
type Deployer interface { GetName() string //May not need this Initialise() error Cleanup() error ApplyCommand(cmd *DeployCommand) error }
Deployer interface
type FTPDeployer ¶
type FTPDeployer struct { HostID string Port string UID string PWD string RootDir string DisableTLS bool // contains filtered or unexported fields }
func (*FTPDeployer) ApplyCommand ¶
func (f *FTPDeployer) ApplyCommand(cmd *DeployCommand) error
func (*FTPDeployer) Cleanup ¶
func (f *FTPDeployer) Cleanup() error
func (*FTPDeployer) GetName ¶
func (f *FTPDeployer) GetName() string
func (*FTPDeployer) Initialise ¶
func (f *FTPDeployer) Initialise() error
func (*FTPDeployer) MakeDirectory ¶
func (f *FTPDeployer) MakeDirectory(path string) error
func (*FTPDeployer) RemoveDirectory ¶
func (f *FTPDeployer) RemoveDirectory(path string) error
func (*FTPDeployer) RemoveFile ¶
func (f *FTPDeployer) RemoveFile(path string) error
func (*FTPDeployer) UploadFile ¶
func (f *FTPDeployer) UploadFile(path string, data []byte) error
type FileDeployer ¶
type FileDeployer struct {
TargetDir string
}
func (*FileDeployer) ApplyCommand ¶
func (f *FileDeployer) ApplyCommand(cmd *DeployCommand) error
func (*FileDeployer) Cleanup ¶
func (f *FileDeployer) Cleanup() error
func (*FileDeployer) GetName ¶
func (f *FileDeployer) GetName() string
func (*FileDeployer) Initialise ¶
func (f *FileDeployer) Initialise() error
func (*FileDeployer) MakeDirectory ¶
func (f *FileDeployer) MakeDirectory(path string) error
func (*FileDeployer) RemoveDirectory ¶
func (f *FileDeployer) RemoveDirectory(path string) error
func (*FileDeployer) RemoveFile ¶
func (f *FileDeployer) RemoveFile(path string) error
func (*FileDeployer) UploadFile ¶
func (f *FileDeployer) UploadFile(path string, data []byte) error
type SFTPDeployer ¶
type SFTPDeployer struct { HostID string Port string UID string PWD string // contains filtered or unexported fields }
func (*SFTPDeployer) ApplyCommand ¶
func (s *SFTPDeployer) ApplyCommand(cmd *DeployCommand) error
func (*SFTPDeployer) Cleanup ¶
func (s *SFTPDeployer) Cleanup() error
func (*SFTPDeployer) GetName ¶
func (s *SFTPDeployer) GetName() string
func (*SFTPDeployer) Initialise ¶
func (s *SFTPDeployer) Initialise() error