Exemplo n.º 1
0
func init() {
	// create a cipher for ecnrypting and decrypting
	// database fields
	cipher, err := aes.NewCipher([]byte("38B241096B8DA08131563770F4CDDFAC"))
	if err != nil {
		log.Fatal(err)
	}

	// register function with meddler to encrypt and
	// decrypt database fields.
	meddler.Register("gobencrypt", &encrypt.EncryptedField{cipher})

	// Check for $DB_ENV
	dbenv := os.Getenv("DB_ENV")
	if dbenv == "mysql" {
		driver = dbenv
		dbname = "drone_test"
		login = os.Getenv("MYSQL_LOGIN")
		if len(login) == 0 {
			login = "******"
		}
		log.Println("Using mysql database ...")
	} else {
		driver = "sqlite3"
		dsn = ":memory:"
		log.Println("Using sqlite3 database ...")
	}

}
Exemplo n.º 2
0
func init() {
	// create a cipher for ecnrypting and decrypting
	// database fields
	cipher, err := aes.NewCipher([]byte("38B241096B8DA08131563770F4CDDFAC"))
	if err != nil {
		log.Fatal(err)
	}

	// register function with meddler to encrypt and
	// decrypt database fields.
	meddler.Register("gobencrypt", &encrypt.EncryptedField{cipher})

}
Exemplo n.º 3
0
func init() {
	// create a cipher for ecnrypting and decrypting
	// database fields
	cipher, err := aes.NewCipher([]byte("38B241096B8DA08131563770F4CDDFAC"))
	if err != nil {
		log.Fatal(err)
	}

	// register function with meddler to encrypt and
	// decrypt database fields.
	meddler.Register("gobencrypt", &encrypt.EncryptedField{cipher})

	// notify meddler that we are working with sqlite
	meddler.Default = meddler.SQLite
	migrate.Driver = migrate.SQLite
}
Exemplo n.º 4
0
// InitMeddler configures Meddler, including registration of custom Meddlers.
// It runs a database connection for general-purpose use.
func InitMeddler(dbUrl string) (*sql.DB, error) {
	meddler.Default = meddler.PostgreSQL
	meddler.Debug = true
	meddler.Register("monetary", MonetaryMeddler{})
	return sql.Open("postgres", dbUrl)
}