Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportDatabase ¶
func ImportDatabase(conn Connection, db Database, dataDir string, rebuildDb bool) error
ImportDatabase imports a collection into a database
Types ¶
type CollectionInfo ¶
type CollectionInfo struct { IsCapped bool `json:"isCapped" yaml:"isCapped"` Drop bool `json:"drop" yaml:"drop"` MaxBytes *int `json:"maxBytes,omitempty" yaml:"maxBytes,omitempty"` MaxDocuments *int `json:"maxDocuments,omitempty" yaml:"maxDocuments,omitempty"` Indexes map[string]IndexInfo `json:"indexes,omitempty" yaml:"indexes,omitempty"` DataFile string `json:"dataFile,omitempty" yaml:"dataFile,omitempty"` }
CollectionInfo defines a collection in Mongo. For creating a capped collection you can specify a size.
type Connection ¶
type Connection struct { DBName string `yaml:"dbName" json:"dbName"` Host string `yaml:"host" json:"host"` Port string `yaml:"port" json:"port"` KubePort KubePortForward `yaml:"kubePort" json:"kubePort"` Credentials CredentialProvider `yaml:"credentials" json:"credentials"` }
Connection defines a mongo connection. It also has support for access mongo databases running inside a kubernetes cluster using the `port-forward` command, as well as credential support using vault.
func (Connection) Prepare ¶
func (c Connection) Prepare(log *logrus.Entry) (PreparedConnection, error)
Prepare returns a PreparedConnection which may have created a port-forward for mongo and will have ensured that the credentials are populated.
type CredentialProvider ¶
type CredentialProvider struct { Type string `yaml:"type" json:"type"` Username string `yaml:"username,omitempty" json:"username,omitempty"` Password string `yaml:"password,omitempty" json:"password,omitempty"` VaultPath string `yaml:"vaultPath,omitempty" json:"vaultPath,omitempty"` AuthSource string `yaml:"authSource,omitempty" json:"authSource,omitempty"` }
CredentialProvider defines how the connection should obtain its credentials
type Database ¶
type Database struct { Name string `json:"name" yaml:"name"` // the name of the database; overrides the name on the connection Collections map[string]*CollectionInfo `json:"collections" yaml:"collections"` }
Database defines data to be imported into the target mongo database. It is the combination of a connection, collection definition, and data.
type KubePortForward ¶
type KubePortForward struct { Forward bool `yaml:"forward" json:"forward"` ServiceName string `yaml:"serviceName" json:"serviceName"` Port int `yaml:"port" json:"port"` Namespace string `yaml:"namespace" json:"namespace"` }
KubePortForward defines whether or not we need to tunnel into Kuberetes, and what port to use.
type MongoExportCommand ¶
type MongoExportCommand struct { Conn Connection DB Database DataDir string Log *logrus.Entry `json:"-"` }
func (MongoExportCommand) Execute ¶
func (e MongoExportCommand) Execute() error
type MongoImportCommand ¶
type MongoImportCommand struct { Conn Connection DB Database DataDir string RebuildDB bool Log *logrus.Entry `json:"-"` }
func (MongoImportCommand) Execute ¶
func (m MongoImportCommand) Execute() error
type PreparedConnection ¶
type PreparedConnection struct { Connection Client *mongo.Client CleanUp func() }
func GetPreparedConnection ¶
func GetPreparedConnection(log *logrus.Entry, c Connection) (PreparedConnection, error)
type ScriptCommand ¶
type ScriptCommand struct { Conn Connection Script string Log *logrus.Entry `json:"-"` }
ScriptCommand runs a database command: https://docs.mongodb.com/manual/reference/command/
func (ScriptCommand) Execute ¶
func (m ScriptCommand) Execute() error