Made database file configurable through ZEIT_DB
This commit is contained in:
parent
2aafaf9501
commit
a8f46b9c94
1 changed files with 7 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package z
|
package z
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"log"
|
"log"
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -14,7 +15,12 @@ type Database struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitDatabase() (*Database, error) {
|
func InitDatabase() (*Database, error) {
|
||||||
db, err := buntdb.Open(":memory:") // TODO: Replace with file
|
dbfile, ok := os.LookupEnv("ZEIT_DB")
|
||||||
|
if ok == false || dbfile == "" {
|
||||||
|
return nil, errors.New("please `export ZEIT_DB` to the location the zeit database should be stored at")
|
||||||
|
}
|
||||||
|
|
||||||
|
db, err := buntdb.Open(dbfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue