Documentation
¶
Index ¶
- func DefaultDatabaseName(config string, profile string, databaseName string) string
- func DefaultPassword(dbType DatabaseType) string
- func DefaultUsername(dbType DatabaseType) string
- func EverythingToSnakeCase(s string) string
- func IsValidDatabaseType(t DatabaseType) bool
- type Context
- func (c *Context) AddDatabase(database *Database)
- func (c *Context) ApplyPlan(plan *Plan)
- func (c *Context) Config() string
- func (c *Context) Databases() []*Database
- func (c *Context) Environment() *Environment
- func (c *Context) LoadSecretsToEnvironment(path string) error
- func (c *Context) Module() string
- func (c *Context) Plan() *Plan
- func (c *Context) Profile() string
- func (c *Context) WithEnvironment(env *Environment)
- type Database
- func (db *Database) DatabaseName(ctx *Context) EnvironmentValue
- func (db *Database) DefaultDatabaseName(ctx *Context) string
- func (db *Database) DefaultPassword() string
- func (db *Database) DefaultUsername() string
- func (db *Database) Host(ctx *Context) EnvironmentValue
- func (db *Database) Name() string
- func (db *Database) Password() EnvironmentValue
- func (db *Database) Port(ctx *Context) EnvironmentValue
- func (db *Database) Type() DatabaseType
- func (db *Database) Username() EnvironmentValue
- type DatabaseType
- type Environment
- type EnvironmentValue
- type Plan
- type PlannedDatabase
- type PlannedDatabaseType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDatabaseName ¶
Get the default database name for a database.
func DefaultPassword ¶
func DefaultPassword(dbType DatabaseType) string
Get the default password for a database by type.
func DefaultUsername ¶
func DefaultUsername(dbType DatabaseType) string
Get the default username for a database by type.
func EverythingToSnakeCase ¶
Convert every character except for letters and digits directly to _
func IsValidDatabaseType ¶
func IsValidDatabaseType(t DatabaseType) bool
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func DefaultContext ¶
func (*Context) Environment ¶
func (c *Context) Environment() *Environment
func (*Context) LoadSecretsToEnvironment ¶
Note: In case you use a relative path, expect it to start in the Magic directory.
func (*Context) WithEnvironment ¶
func (c *Context) WithEnvironment(env *Environment)
Set the environment.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewPostgresDatabase ¶
Create a new Postgres database.
func (*Database) DatabaseName ¶
func (db *Database) DatabaseName(ctx *Context) EnvironmentValue
Get the name of the database for environment variables
func (*Database) DefaultDatabaseName ¶
Get the default name for the database using the runner
func (*Database) DefaultPassword ¶
Get the default password for the database type
func (*Database) DefaultUsername ¶
Get the default username for the database type
func (*Database) Host ¶
func (db *Database) Host(ctx *Context) EnvironmentValue
Get the host of the database for environment variables
func (*Database) Password ¶
func (db *Database) Password() EnvironmentValue
Get the password of the database for environment variables
func (*Database) Port ¶
func (db *Database) Port(ctx *Context) EnvironmentValue
Get the port of the database for environment variables
func (*Database) Type ¶
func (db *Database) Type() DatabaseType
func (*Database) Username ¶
func (db *Database) Username() EnvironmentValue
Get the username of the database for environment variables
type Environment ¶
type Environment map[string]EnvironmentValue
func (*Environment) Generate ¶
func (e *Environment) Generate() map[string]string
Apply all the environment variables
type EnvironmentValue ¶
type EnvironmentValue struct {
// contains filtered or unexported fields
}
func ValueStatic ¶
func ValueStatic(value string) EnvironmentValue
Create a new static environment value.
type Plan ¶
type Plan struct { Environment map[string]string `json:"environment"` DatabaseTypes []PlannedDatabaseType `json:"database_types"` }
func FromPrintable ¶
Convert back to a plan from printable form
func (*Plan) Database ¶
func (p *Plan) Database(name string) (PlannedDatabase, error)
Get a database by its name.
func (*Plan) ToPrintable ¶
Turn the plan into printable form
type PlannedDatabase ¶
type PlannedDatabase struct { ConfigName string `json:"config_name"` // Name in the config Name string `json:"name"` Username string `json:"username"` Password string `json:"password"` Hostname string `json:"hostname"` // Just for developers to access, not included in actual plan Type DatabaseType `json:"-"` Port uint `json:"-"` }
func (*PlannedDatabase) ConnectString ¶
func (db *PlannedDatabase) ConnectString() string
Generate a connection string for the database.
type PlannedDatabaseType ¶
type PlannedDatabaseType struct { Port uint `json:"port"` Type DatabaseType `json:"type"` Databases []PlannedDatabase `json:"databases"` }
func (*PlannedDatabaseType) ContainerName ¶
func (p *PlannedDatabaseType) ContainerName(modName string, config string, profile string) string
Name for the database Docker container