mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move sqlite conn to graph db for cross compile support
This commit is contained in:
parent
681b40c801
commit
329d154209
3 changed files with 29 additions and 15 deletions
5
graphdb/conn_darwin.go
Normal file
5
graphdb/conn_darwin.go
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package graphdb
|
||||||
|
|
||||||
|
func NewSqliteConn(root string) (*Database, error) {
|
||||||
|
panic("Not implemented")
|
||||||
|
}
|
23
graphdb/conn_linux.go
Normal file
23
graphdb/conn_linux.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package graphdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "code.google.com/p/gosqlite/sqlite3" // registers sqlite
|
||||||
|
"database/sql"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewSqliteConn(root string) (*Database, error) {
|
||||||
|
initDatabase := false
|
||||||
|
if _, err := os.Stat(root); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
initDatabase = true
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
conn, err := sql.Open("sqlite3", root)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewDatabase(conn, initDatabase)
|
||||||
|
}
|
16
runtime.go
16
runtime.go
|
@ -1,9 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "code.google.com/p/gosqlite/sqlite3" // registers sqlite
|
|
||||||
"container/list"
|
"container/list"
|
||||||
"database/sql"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
"github.com/dotcloud/docker/graphdb"
|
"github.com/dotcloud/docker/graphdb"
|
||||||
|
@ -718,19 +716,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
graphdbPath := path.Join(config.Root, "linkgraph.db")
|
graphdbPath := path.Join(config.Root, "linkgraph.db")
|
||||||
initDatabase := false
|
graph, err := graphdb.NewSqliteConn(graphdbPath)
|
||||||
if _, err := os.Stat(graphdbPath); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
initDatabase = true
|
|
||||||
} else {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
conn, err := sql.Open("sqlite3", graphdbPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
graph, err := graphdb.NewDatabase(conn, initDatabase)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue