synchers

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const LOCAL_ENVIRONMENT_NAME = "local"

Variables

View Source
var RsyncAssetPath = "/tmp/rsync"

Functions

func GenerateRemoteCommand

func GenerateRemoteCommand(remoteEnvironment Environment, command string, sshOptions SSHOptions) string

func PrerequisiteCleanUp

func PrerequisiteCleanUp(environment Environment, rsyncPath string, dryRun bool, sshOptionWrapper *SSHOptionWrapper) error

func RegisterSyncer

func RegisterSyncer(plugin SyncerPlugin)

func SyncCleanUp

func SyncCleanUp(environment Environment, syncer Syncer, dryRun bool, sshOptionWrapper *SSHOptionWrapper) error

func SyncRunSourceCommand

func SyncRunSourceCommand(remoteEnvironment Environment, syncer Syncer, dryRun bool, sshOptionWrapper *SSHOptionWrapper) error

func SyncRunTargetCommand

func SyncRunTargetCommand(targetEnvironment Environment, syncer Syncer, dryRun bool, sshOptionWrapper *SSHOptionWrapper) error

func SyncRunTransfer

func SyncRunTransfer(sourceEnvironment Environment, targetEnvironment Environment, syncer Syncer, dryRun bool, sshOptionWrapper *SSHOptionWrapper) error

func UnmarshalIntoStruct

func UnmarshalIntoStruct(pluginIn interface{}, pluginOut interface{}) error

takes interface, marshals back to []byte, then unmarshals to desired struct from https://github.com/go-yaml/yaml/issues/13#issuecomment-428952604

Types

type BaseCustomSync added in v0.8.0

type BaseCustomSync struct {
}

func (BaseCustomSync) IsBaseCustomStructureEmpty added in v0.8.0

func (m BaseCustomSync) IsBaseCustomStructureEmpty() bool

type BaseCustomSyncCommands added in v0.8.0

type BaseCustomSyncCommands struct {
	Commands []string `yaml:"commands"`
}

type BaseDrupalconfigSync

type BaseDrupalconfigSync struct {
	SyncPath        string `yaml:"syncpath"`
	OutputDirectory string
}

type BaseFilesSync

type BaseFilesSync struct {
	SyncPath string `yaml:"sync-directory"`
	Exclude  []string
}

func (BaseFilesSync) IsBaseFilesSyncStructEmpty

func (m BaseFilesSync) IsBaseFilesSyncStructEmpty() bool

type BaseMariaDbSync

type BaseMariaDbSync struct {
	DbHostname      string   `yaml:"hostname"`
	DbUsername      string   `yaml:"username"`
	DbPassword      string   `yaml:"password"`
	DbPort          string   `yaml:"port"`
	DbDatabase      string   `yaml:"database"`
	IgnoreTable     []string `yaml:"ignore-table"`
	IgnoreTableData []string `yaml:"ignore-table-data"`
	OutputDirectory string
}

func (BaseMariaDbSync) IsBaseMariaDbStructureEmpty

func (m BaseMariaDbSync) IsBaseMariaDbStructureEmpty() bool

func (*BaseMariaDbSync) SetDefaults added in v0.8.0

func (mariadbConfig *BaseMariaDbSync) SetDefaults()

type BaseMongoDbSync

type BaseMongoDbSync struct {
	DbHostname      string `yaml:"hostname"`
	DbPort          string `yaml:"port"`
	DbDatabase      string `yaml:"database"`
	OutputDirectory string
}

func (BaseMongoDbSync) IsBaseMongoDbStructureEmpty

func (m BaseMongoDbSync) IsBaseMongoDbStructureEmpty() bool

type BasePostgresSync

type BasePostgresSync struct {
	DbHostname       string   `yaml:"hostname"`
	DbUsername       string   `yaml:"username"`
	DbPassword       string   `yaml:"password"`
	DbPort           string   `yaml:"port"`
	DbDatabase       string   `yaml:"database"`
	ExcludeTable     []string `yaml:"exclude-table"`
	ExcludeTableData []string `yaml:"exclude-table-data"`
	OutputDirectory  string
}

func (BasePostgresSync) IsBasePostgresDbStructureEmpty

func (m BasePostgresSync) IsBasePostgresDbStructureEmpty() bool

func (*BasePostgresSync) SetDefaults added in v0.8.0

func (postgresConfig *BasePostgresSync) SetDefaults()

SetDefaults is a public function that is used to set all defaults for this struct

type CustomSyncPlugin added in v0.8.0

type CustomSyncPlugin struct {
	CustomRoot string
	// contains filtered or unexported fields
}

func (CustomSyncPlugin) GetPluginId added in v0.8.0

func (m CustomSyncPlugin) GetPluginId() string

func (CustomSyncPlugin) UnmarshallYaml added in v0.8.0

func (m CustomSyncPlugin) UnmarshallYaml(root SyncherConfigRoot, targetService string) (Syncer, error)

type CustomSyncRoot added in v0.8.0

type CustomSyncRoot struct {
	Type             string                 `yaml:"type" json:"type"`
	TransferResource string                 `yaml:"transfer-resource"`
	Source           BaseCustomSyncCommands `yaml:"source"`
	Target           BaseCustomSyncCommands `yaml:"target"`
}

func (CustomSyncRoot) GetFilesToCleanup added in v0.8.0

func (m CustomSyncRoot) GetFilesToCleanup(environment Environment) []string

func (CustomSyncRoot) GetLocalCommand added in v0.8.0

func (m CustomSyncRoot) GetLocalCommand(targetEnvironment Environment) []SyncCommand

func (CustomSyncRoot) GetPrerequisiteCommand added in v0.8.0

func (root CustomSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (CustomSyncRoot) GetRemoteCommand added in v0.8.0

func (root CustomSyncRoot) GetRemoteCommand(sourceEnvironment Environment) []SyncCommand

func (CustomSyncRoot) GetTransferResource added in v0.8.0

func (m CustomSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (CustomSyncRoot) IsInitialized added in v0.8.0

func (m CustomSyncRoot) IsInitialized() (bool, error)

func (CustomSyncRoot) PrepareSyncer added in v0.8.0

func (root CustomSyncRoot) PrepareSyncer() (Syncer, error)

Sync related functions follow

func (CustomSyncRoot) SetTransferResource added in v0.8.0

func (m CustomSyncRoot) SetTransferResource(transferResourceName string) error

type DrupalConfigSyncPlugin

type DrupalConfigSyncPlugin struct {
}

func (DrupalConfigSyncPlugin) GetPluginId

func (m DrupalConfigSyncPlugin) GetPluginId() string

func (DrupalConfigSyncPlugin) UnmarshallYaml

func (m DrupalConfigSyncPlugin) UnmarshallYaml(syncerConfigRoot SyncherConfigRoot, targetService string) (Syncer, error)

type DrupalconfigSyncLocal

type DrupalconfigSyncLocal struct {
	Config BaseDrupalconfigSync
}

type DrupalconfigSyncRoot

type DrupalconfigSyncRoot struct {
	Config         BaseDrupalconfigSync
	LocalOverrides DrupalconfigSyncLocal `yaml:"local"`
	TransferId     string
}

func (DrupalconfigSyncRoot) GetFilesToCleanup added in v0.7.0

func (m DrupalconfigSyncRoot) GetFilesToCleanup(environment Environment) []string

func (DrupalconfigSyncRoot) GetLocalCommand

func (m DrupalconfigSyncRoot) GetLocalCommand(environment Environment) []SyncCommand

func (DrupalconfigSyncRoot) GetOutputDirectory

func (root DrupalconfigSyncRoot) GetOutputDirectory() string

func (DrupalconfigSyncRoot) GetPrerequisiteCommand

func (root DrupalconfigSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (DrupalconfigSyncRoot) GetRemoteCommand

func (root DrupalconfigSyncRoot) GetRemoteCommand(environment Environment) []SyncCommand

func (DrupalconfigSyncRoot) GetTransferResource

func (m DrupalconfigSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (DrupalconfigSyncRoot) IsInitialized

func (m DrupalconfigSyncRoot) IsInitialized() (bool, error)

func (DrupalconfigSyncRoot) PrepareSyncer

func (root DrupalconfigSyncRoot) PrepareSyncer() (Syncer, error)

func (*DrupalconfigSyncRoot) SetTransferResource added in v0.8.0

func (m *DrupalconfigSyncRoot) SetTransferResource(transferResourceName string) error

type Environment

type Environment struct {
	ProjectName     string `yaml:"projectName"`
	EnvironmentName string `yaml:"environmentName"`
	ServiceName     string `yaml:"serviceName"` // This is used to determine which Lagoon service we need to rsync
	RsyncAvailable  bool   `yaml:"rsyncAvailable"`
	RsyncPath       string `yaml:"rsyncPath"`
	RsyncLocalPath  string `yaml:"rsyncLocalPath"`
}

func RunPrerequisiteCommand

func RunPrerequisiteCommand(environment Environment, syncer Syncer, syncerType string, dryRun bool, sshOptionWrapper *SSHOptionWrapper) (Environment, error)

func (Environment) GetOpenshiftProjectName

func (r Environment) GetOpenshiftProjectName() string

type FilesSyncLocal

type FilesSyncLocal struct {
	Config BaseFilesSync
}

type FilesSyncPlugin

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

func (FilesSyncPlugin) GetPluginId

func (m FilesSyncPlugin) GetPluginId() string

func (FilesSyncPlugin) UnmarshallYaml

func (m FilesSyncPlugin) UnmarshallYaml(root SyncherConfigRoot, targetService string) (Syncer, error)

type FilesSyncRoot

type FilesSyncRoot struct {
	Type           string `yaml:"type" json:"type"`
	ServiceName    string `yaml:"serviceName"`
	Config         BaseFilesSync
	LocalOverrides FilesSyncLocal `yaml:"local"`
	TransferId     string
}

func (*FilesSyncRoot) GetFilesToCleanup added in v0.7.0

func (m *FilesSyncRoot) GetFilesToCleanup(environment Environment) []string

func (*FilesSyncRoot) GetLocalCommand

func (m *FilesSyncRoot) GetLocalCommand(environment Environment) []SyncCommand

func (*FilesSyncRoot) GetPrerequisiteCommand

func (root *FilesSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (*FilesSyncRoot) GetRemoteCommand

func (root *FilesSyncRoot) GetRemoteCommand(environment Environment) []SyncCommand

func (*FilesSyncRoot) GetTransferResource

func (m *FilesSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (*FilesSyncRoot) IsInitialized

func (m *FilesSyncRoot) IsInitialized() (bool, error)

func (*FilesSyncRoot) PrepareSyncer

func (root *FilesSyncRoot) PrepareSyncer() (Syncer, error)

func (*FilesSyncRoot) SetTransferResource added in v0.8.0

func (m *FilesSyncRoot) SetTransferResource(transferResourceName string) error

type MariadbSyncLocal

type MariadbSyncLocal struct {
	Config BaseMariaDbSync
}

type MariadbSyncPlugin

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

func (MariadbSyncPlugin) GetPluginId

func (m MariadbSyncPlugin) GetPluginId() string

func (MariadbSyncPlugin) UnmarshallYaml

func (m MariadbSyncPlugin) UnmarshallYaml(root SyncherConfigRoot, targetService string) (Syncer, error)

type MariadbSyncRoot

type MariadbSyncRoot struct {
	Type                     string `yaml:"type" json:"type"`
	ServiceName              string `yaml:"serviceName"`
	Config                   BaseMariaDbSync
	LocalOverrides           MariadbSyncLocal `yaml:"local"`
	TransferId               string
	TransferResourceOverride string
}

func (*MariadbSyncRoot) GetFilesToCleanup added in v0.7.0

func (m *MariadbSyncRoot) GetFilesToCleanup(environment Environment) []string

func (*MariadbSyncRoot) GetLocalCommand

func (m *MariadbSyncRoot) GetLocalCommand(targetEnvironment Environment) []SyncCommand

func (*MariadbSyncRoot) GetOutputDirectory

func (root *MariadbSyncRoot) GetOutputDirectory() string

func (*MariadbSyncRoot) GetPrerequisiteCommand

func (root *MariadbSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (*MariadbSyncRoot) GetRemoteCommand

func (root *MariadbSyncRoot) GetRemoteCommand(sourceEnvironment Environment) []SyncCommand

func (*MariadbSyncRoot) GetTransferResource

func (m *MariadbSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (*MariadbSyncRoot) IsInitialized

func (m *MariadbSyncRoot) IsInitialized() (bool, error)

func (*MariadbSyncRoot) PrepareSyncer

func (root *MariadbSyncRoot) PrepareSyncer() (Syncer, error)

func (*MariadbSyncRoot) SetTransferResource added in v0.8.0

func (m *MariadbSyncRoot) SetTransferResource(transferResourceName string) error

type MongoDbSyncLocal

type MongoDbSyncLocal struct {
	Config BaseMongoDbSync
}

type MongoDbSyncPlugin

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

func (MongoDbSyncPlugin) GetPluginId

func (m MongoDbSyncPlugin) GetPluginId() string

func (MongoDbSyncPlugin) UnmarshallYaml

func (m MongoDbSyncPlugin) UnmarshallYaml(root SyncherConfigRoot, targetService string) (Syncer, error)

type MongoDbSyncRoot

type MongoDbSyncRoot struct {
	Type                     string `yaml:"type" json:"type"`
	Config                   BaseMongoDbSync
	LocalOverrides           MongoDbSyncLocal `yaml:"local"`
	TransferId               string
	TransferResourceOverride string
}

func (*MongoDbSyncRoot) GetFilesToCleanup added in v0.7.0

func (m *MongoDbSyncRoot) GetFilesToCleanup(environment Environment) []string

func (*MongoDbSyncRoot) GetLocalCommand

func (m *MongoDbSyncRoot) GetLocalCommand(targetEnvironment Environment) []SyncCommand

func (*MongoDbSyncRoot) GetOutputDirectory

func (root *MongoDbSyncRoot) GetOutputDirectory() string

func (*MongoDbSyncRoot) GetPrerequisiteCommand

func (root *MongoDbSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (*MongoDbSyncRoot) GetRemoteCommand

func (root *MongoDbSyncRoot) GetRemoteCommand(sourceEnvironment Environment) []SyncCommand

func (*MongoDbSyncRoot) GetTransferResource

func (m *MongoDbSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (*MongoDbSyncRoot) IsInitialized

func (m *MongoDbSyncRoot) IsInitialized() (bool, error)

func (*MongoDbSyncRoot) PrepareSyncer

func (root *MongoDbSyncRoot) PrepareSyncer() (Syncer, error)

Sync related functions follow

func (*MongoDbSyncRoot) SetTransferResource added in v0.8.0

func (m *MongoDbSyncRoot) SetTransferResource(transferResourceName string) error

type PostgresSyncLocal

type PostgresSyncLocal struct {
	Config BasePostgresSync
}

type PostgresSyncPlugin

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

func (PostgresSyncPlugin) GetPluginId

func (m PostgresSyncPlugin) GetPluginId() string

func (PostgresSyncPlugin) UnmarshallYaml

func (m PostgresSyncPlugin) UnmarshallYaml(syncerConfigRoot SyncherConfigRoot, targetService string) (Syncer, error)

type PostgresSyncRoot

type PostgresSyncRoot struct {
	Type                     string `yaml:"type" json:"type"`
	ServiceName              string `yaml:"serviceName"`
	Config                   BasePostgresSync
	LocalOverrides           PostgresSyncLocal `yaml:"local"`
	TransferId               string
	TransferResourceOverride string
}

func (*PostgresSyncRoot) GetFilesToCleanup added in v0.7.0

func (m *PostgresSyncRoot) GetFilesToCleanup(environment Environment) []string

func (*PostgresSyncRoot) GetLocalCommand

func (m *PostgresSyncRoot) GetLocalCommand(environment Environment) []SyncCommand

func (*PostgresSyncRoot) GetOutputDirectory

func (root *PostgresSyncRoot) GetOutputDirectory() string

func (*PostgresSyncRoot) GetPrerequisiteCommand

func (root *PostgresSyncRoot) GetPrerequisiteCommand(environment Environment, command string) SyncCommand

func (*PostgresSyncRoot) GetRemoteCommand

func (root *PostgresSyncRoot) GetRemoteCommand(environment Environment) []SyncCommand

func (*PostgresSyncRoot) GetTransferResource

func (m *PostgresSyncRoot) GetTransferResource(environment Environment) SyncerTransferResource

func (*PostgresSyncRoot) IsInitialized

func (m *PostgresSyncRoot) IsInitialized() (bool, error)

func (*PostgresSyncRoot) PrepareSyncer

func (root *PostgresSyncRoot) PrepareSyncer() (Syncer, error)

func (*PostgresSyncRoot) SetTransferResource added in v0.8.0

func (m *PostgresSyncRoot) SetTransferResource(transferResourceName string) error

type RunSyncProcessFunctionType added in v0.6.4

type RunSyncProcessFunctionType = func(args RunSyncProcessFunctionTypeArguments) error

type RunSyncProcessFunctionTypeArguments added in v0.7.0

type RunSyncProcessFunctionTypeArguments struct {
	SourceEnvironment    Environment
	TargetEnvironment    Environment
	LagoonSyncer         Syncer
	SyncerType           string
	DryRun               bool
	SshOptionWrapper     *SSHOptionWrapper
	SkipSourceCleanup    bool
	SkipTargetCleanup    bool
	SkipTargetImport     bool
	TransferResourceName string
}

type SSHConfig added in v0.6.2

type SSHConfig struct {
	SSH SSHOptions `yaml:"ssh,omitempty" json:"SSH"`
}

type SSHOptionWrapper added in v0.8.0

type SSHOptionWrapper struct {
	ProjectName string                // this is primarily used to ensure someone doesn't do something silly - it's an assertion
	Options     map[string]SSHOptions // a map off all named ssh options - environment => ssh config
	Default     SSHOptions            // this will be returned if no explicit match is found in `Options`
}

SSHOptionWrapper is passed around instead of specific SSHOptions - this allows resolution of the ssh endpoint when and where it's needed

func NewSshOptionWrapper added in v0.8.0

func NewSshOptionWrapper(projectName string, defaultSshOptions SSHOptions) *SSHOptionWrapper

func (*SSHOptionWrapper) AddSsshOptionForEnvironment added in v0.8.0

func (receiver *SSHOptionWrapper) AddSsshOptionForEnvironment(environmentName string, sshOptions SSHOptions)

func (*SSHOptionWrapper) GetSSHOptionsForEnvironment added in v0.8.0

func (receiver *SSHOptionWrapper) GetSSHOptionsForEnvironment(environmentName string) SSHOptions

func (*SSHOptionWrapper) SetDefaultSshOptions added in v0.8.0

func (receiver *SSHOptionWrapper) SetDefaultSshOptions(sshOptions SSHOptions)

type SSHOptions added in v0.5.0

type SSHOptions struct {
	Host       string `yaml:"host,omitempty" json:"host,omitempty"`
	Port       string `yaml:"port,omitempty" json:"port,omitempty"`
	Verbose    bool   `yaml:"verbose,omitempty" json:"verbose,omitempty"`
	PrivateKey string `yaml:"privateKey,omitempty" json:"privateKey,omitempty"`
	SkipAgent  bool
	RsyncArgs  string `yaml:"rsyncArgs,omitempty" json:"rsyncArgs,omitempty"`
}

type SyncCommand

type SyncCommand struct {
	NoOp bool // NoOp can be set to true if this command performs no operation (in situations like file transfers)
	// contains filtered or unexported fields
}

func (SyncCommand) GetCommand

func (c SyncCommand) GetCommand() (string, error)

type Syncer

type Syncer interface {
	// GetPrerequisiteCommand will return the command to run on source or target environment to extract information.
	GetPrerequisiteCommand(environment Environment, command string) SyncCommand
	// GetRemoteCommand will return the command to be run on the source system
	GetRemoteCommand(environment Environment) []SyncCommand
	// GetLocalCommand will return the command to be run on the target system
	GetLocalCommand(environment Environment) []SyncCommand
	// GetTransferResource will return the command that executes the transfer
	GetTransferResource(environment Environment) SyncerTransferResource
	// SetTransferResource allows for the overriding of the resource transfer name that's typically generated
	SetTransferResource(transferResourceName string) error
	// GetFilesToCleanup will return a list of files to be deleted after completing the transfer
	GetFilesToCleanup(environment Environment) []string
	// PrepareSyncer does any preparations required on a Syncer before it is used
	PrepareSyncer() (Syncer, error)
	// IsInitialized will tell client code if the syncer is ready to rumble
	IsInitialized() (bool, error)
}

func GetCustomSync added in v0.8.0

func GetCustomSync(configRoot SyncherConfigRoot, syncerName string) (Syncer, error)

func GetSyncerForTypeFromConfigRoot

func GetSyncerForTypeFromConfigRoot(syncerId string, root SyncherConfigRoot) (Syncer, error)

type SyncerPlugin

type SyncerPlugin interface {
	GetPluginId() string
	UnmarshallYaml(root SyncherConfigRoot, targetService string) (Syncer, error)
}

type SyncerTransferResource

type SyncerTransferResource struct {
	Name             string   `yaml:"name,omitempty" json:"name,omitempty"`
	IsDirectory      bool     `yaml:"isDirectory,omitempty" json:"isDirectory,omitempty"`
	ExcludeResources []string `yaml:"excludeResources,omitempty" json:"excludeResources,omitempty"`
	SkipCleanup      bool     `yaml:"skipCleanup,omitempty" json:"skipCleanup,omitempty"`
}

SyncerTransferResource describes what it is the is produced by the actions of GetRemoteCommand()

type SyncherConfigRoot

type SyncherConfigRoot struct {
	Api           string                              `yaml:"api,omitempty" json:"api,omitempty"`
	Project       string                              `yaml:"project" json:"project,omitempty"`
	LagoonSync    map[string]interface{}              `yaml:"lagoon-sync" json:"lagoonSync,omitempty"`
	Prerequisites []prerequisite.GatheredPrerequisite `yaml:"prerequisites" json:"prerequisites,omitempty"`
}

SyncherConfigRoot is used to unmarshall yaml config details generally

func UnmarshallLagoonYamlToLagoonSyncStructure

func UnmarshallLagoonYamlToLagoonSyncStructure(data []byte) (SyncherConfigRoot, error)

UnmarshallLagoonYamlToLagoonSyncStructure will take a bytestream and return a fully parsed lagoon sync config structure

Jump to

Keyboard shortcuts

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