auth

Paddy 2015-04-11 Parent:8267e1c8bcd1

157:202e991accc2 Go to Latest

auth/postgres.go

Wire up the postgres database for authd. Have authd use the AUTH_PG_DB environment variable to detect support for the postgres *Stores, and if postgres is supported, use it. If postgres isn't supported, fall back on the in-memory store. Also create-if-not-exists the test scopes, instead of panicking when the scope already exists.

History
1 package auth
3 import (
4 "database/sql"
5 )
7 func NewPostgres(conn string) (postgres, error) {
8 db, err := sql.Open("postgres", conn)
9 if err != nil {
10 return postgres{}, err
11 }
12 return postgres{db: db}, nil
13 }
15 type postgres struct {
16 db *sql.DB
17 }