Documentation
¶
Index ¶
- Variables
- func DefaultDatabaseName(profile string, databaseName string) string
- func DefaultPassword(dbType DatabaseType) string
- func DefaultUsername(dbType DatabaseType) string
- func EverythingToSnakeCase(s string) string
- type Context
- func (c *Context) AddDatabase(database *Database)
- func (c *Context) AppName() string
- func (c *Context) ApplyPlan(plan *Plan)
- func (c *Context) Databases() []*Database
- func (c *Context) Environment() *Environment
- func (c *Context) LoadSecretsToEnvironment(path string) error
- func (c *Context) NewPostgresDatabase(name string) *Database
- func (c *Context) Plan() *Plan
- func (c *Context) Ports() []uint
- func (c *Context) Profile() string
- func (c *Context) ValuePort(preferredPort uint) EnvironmentValue
- 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 ¶
var VerboseLogging bool = false
If verbose logging is enabled
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 _
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) NewPostgresDatabase ¶
func (*Context) Profile ¶
The current profile.
test = Test profile. default = Default profile. You can set the profile by passing the --m-profile flag to the executable that includes magic.
func (*Context) ValuePort ¶
func (c *Context) ValuePort(preferredPort uint) EnvironmentValue
Allocate a new port for the container (and parse it as a environment variable).
func (*Context) WithEnvironment ¶
func (c *Context) WithEnvironment(env Environment)
Set the environment.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
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.
func ValueWithBase ¶
func ValueWithBase(values []EnvironmentValue, builder func([]string) string) EnvironmentValue
Create a new environment value based on other environment values.
The index in the values array matches the output of the environment value.
type Plan ¶
type Plan struct {
AppName string `json:"app_name"`
Profile string `json:"profile"`
Environment map[string]string `json:"environment"`
DatabaseTypes []PlannedDatabaseType `json:"database_types"`
AllocatedPorts map[uint]uint `json:"ports"`
}
func FromPrintable ¶
Convert back to a plan from printable form
func (*Plan) Database ¶
func (p *Plan) Database(name string) PlannedDatabase
Get a database by its name. Panics when it can't find the database.
func (*Plan) ToPrintable ¶
Turn the plan into printable form
type PlannedDatabase ¶
type PlannedDatabase struct {
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(appName string, profile string) string
Name for the database Docker container