Documentation ¶
Index ¶
- Constants
- func ApplyMigrations(conf *goose.DBConf, db *sql.DB)
- func Down_20170818120003(txn *sql.Tx)
- func Down_20170818162837(txn *sql.Tx)
- func Down_20170829154900(txn *sql.Tx)
- func Down_20171108102900(txn *sql.Tx)
- func Down_20180413135700(txn *sql.Tx)
- func GetConnection(dc DatabaseConfig) (*sql.DB, error)
- func GetSQLLiteConnection() (*sql.DB, error)
- func ModifySQLStatement(sql string, databaseProvider string) string
- func ParseCFEnvs(db *DatabaseConfig) (bool, error)
- func Ping(db *sql.DB) error
- type By
- type DatabaseConfig
- type SSLValidationMode
- type StratosMigrationMehod
- type StratosMigrations
- func (s *StratosMigrations) Up_20170818120003(txn *sql.Tx, conf *goose.DBConf)
- func (s *StratosMigrations) Up_20170818162837(txn *sql.Tx, conf *goose.DBConf)
- func (s *StratosMigrations) Up_20170829154900(txn *sql.Tx, conf *goose.DBConf)
- func (s *StratosMigrations) Up_20171108102900(txn *sql.Tx, conf *goose.DBConf)
- func (s *StratosMigrations) Up_20180413135700(txn *sql.Tx, conf *goose.DBConf)
- type VCAPService
Constants ¶
const ( SERVICES_ENV = "VCAP_SERVICES" STRATOS_TAG = "stratos" URI_POSTGRES = "postgres://" URI_MYSQL = "mysql://" TAG_MYSQL = "mysql" TAG_POSTGRES = "postgresql" DB_URI = "uri" )
const ( // SQLite DB Provider SQLITE string = "sqlite" // PGSQL DB Provider PGSQL = "pgsql" // MYSQL DB Provider MYSQL = "mysql" )
const ( // SSLDisabled means no checking of SSL SSLDisabled SSLValidationMode = "disable" // SSLRequired requires SSL without validation SSLRequired SSLValidationMode = "require" // SSLVerifyCA verifies the CA certificate SSLVerifyCA SSLValidationMode = "verify-ca" // SSLVerifyFull verifies the certificate and hostname and the CA SSLVerifyFull SSLValidationMode = "verify-full" // SQLiteSchemaFile - SQLite schema file SQLiteSchemaFile = "./deploy/db/sqlite_schema.sql" // SQLiteDatabaseFile - SQLite database file SQLiteDatabaseFile = "./console-database.db" // Default database provider when not specified DefaultDatabaseProvider = MYSQL )
const ( // UniqueConstraintViolation is the error code for a unique constraint violation UniqueConstraintViolation = 23505 // DefaultConnectionTimeout is the default to timeout on connections DefaultConnectionTimeout = 10 )
Variables ¶
This section is empty.
Functions ¶
func Down_20170818120003 ¶
Down is executed when this migration is rolled back
func Down_20170818162837 ¶
Down is executed when this migration is rolled back
func Down_20170829154900 ¶
Down is executed when this migration is rolled back
func Down_20171108102900 ¶
func Down_20180413135700 ¶
func GetConnection ¶
func GetConnection(dc DatabaseConfig) (*sql.DB, error)
GetConnection returns a database connection to either PostgreSQL or SQLite
func GetSQLLiteConnection ¶
func ModifySQLStatement ¶
ModifySQLStatement - Modify the given DB statement for the specified provider, as appropraite e.g Postgres uses $1, $2 etc SQLite uses ?
func ParseCFEnvs ¶
func ParseCFEnvs(db *DatabaseConfig) (bool, error)
Discover cf db services via their 'uri' env var and apply settings to the DatabaseConfig objects
Types ¶
type By ¶
type By func(p1, p2 *StratosMigrationMehod) bool
func (By) Sort ¶
func (by By) Sort(methods []StratosMigrationMehod)
Sort is a method on the function type, By, that sorts the argument slice according to the function.
type DatabaseConfig ¶
type DatabaseConfig struct { DatabaseProvider string `configName:"DATABASE_PROVIDER"` Username string `configName:"DB_USER"` Password string `configName:"DB_PASSWORD"` Database string `configName:"DB_DATABASE_NAME"` Host string `configName:"DB_HOST"` Port int `configName:"DB_PORT"` SSLMode string `configName:"DB_SSL_MODE"` ConnectionTimeoutInSecs int `configName:"DB_CONNECT_TIMEOUT_IN_SECS"` SSLCertificate string `configName:"DB_CERT"` SSLKey string `configName:"DB_CERT_KEY"` SSLRootCertificate string `configName:"DB_ROOT_CERT"` }
DatabaseConfig represents the connection configuration parameters
func NewDatabaseConnectionParametersFromConfig ¶
func NewDatabaseConnectionParametersFromConfig(dc DatabaseConfig) (DatabaseConfig, error)
NewDatabaseConnectionParametersFromConfig setup database connection parameters based on contents of config struct
type SSLValidationMode ¶
type SSLValidationMode string
SSLValidationMode is the PostgreSQL driver SSL validation modes
type StratosMigrationMehod ¶
type StratosMigrations ¶
type StratosMigrations struct { }
func (*StratosMigrations) Up_20170818120003 ¶
func (s *StratosMigrations) Up_20170818120003(txn *sql.Tx, conf *goose.DBConf)
Up is executed when this migration is applied
func (*StratosMigrations) Up_20170818162837 ¶
func (s *StratosMigrations) Up_20170818162837(txn *sql.Tx, conf *goose.DBConf)
Up is executed when this migration is applied
func (*StratosMigrations) Up_20170829154900 ¶
func (s *StratosMigrations) Up_20170829154900(txn *sql.Tx, conf *goose.DBConf)
Up is executed when this migration is applied
func (*StratosMigrations) Up_20171108102900 ¶
func (s *StratosMigrations) Up_20171108102900(txn *sql.Tx, conf *goose.DBConf)
func (*StratosMigrations) Up_20180413135700 ¶
func (s *StratosMigrations) Up_20180413135700(txn *sql.Tx, conf *goose.DBConf)