Documentation ¶
Index ¶
- Variables
- func DefaultImportToolFinder(engine, version string) (string, error)
- func DetermineEngine(file string) (string, error)
- func HasCreateStatement(file string) (bool, error)
- func NewImporter() *importer
- func PrepareArchiveFromPath(path string) (io.Reader, string, error)
- func Validate(opts *ImportOptions) error
- type ImportOptions
- type Importer
Constants ¶
This section is empty.
Variables ¶
var ( MySQLImportCommand = "mysql" PostgresImportCommand = "psql" )
var ErrUnknownDatabaseEngine = fmt.Errorf("unknown database engine detected from file")
ErrUnknownDatabaseEngine is returned when we are unable to determine the engine type from a database backup file.
Functions ¶
func DefaultImportToolFinder ¶
DefaultImportToolFinder is a tool that is used to find the executable path to the import tool such as mysql or psql. It is a func that is provided to the Importer.Import func. It will return the path to the executable or an error if the command is not found
func DetermineEngine ¶
DetermineEngine takes a file and will check if the content of the file is for mysql or postgres db imports. It will return the engine "mysql" or "postgres" if it can determine the engine. If it cannot, it will return an error.
func HasCreateStatement ¶
HasCreateStatement takes a file and will determine if the file will create a database during import. If it creates a database, it will return true otherwise it will return false.
func NewImporter ¶
func NewImporter() *importer
NewImporter takes options and returns a new database importer.
func PrepareArchiveFromPath ¶
PrepareArchiveFromPath takes a path to a file, which is presumed to be a database backup and will determine if the file is already a format the Docker API can use. If the file is a zip or tar file, it will open the sql file in the archive and write the contents to a temporary file and then use the docker archive.Generate functionality to prepare for copying the file to the API.
func Validate ¶
func Validate(opts *ImportOptions) error
Validate takes import options and returns an error if the options are missing details we need to run the import.