From 329d154209f8da83226e729222dafff4e214b25d Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 18 Dec 2013 21:14:16 -0800 Subject: [PATCH] Move sqlite conn to graph db for cross compile support --- graphdb/conn_darwin.go | 5 +++++ graphdb/conn_linux.go | 23 +++++++++++++++++++++++ runtime.go | 16 +--------------- 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 graphdb/conn_darwin.go create mode 100644 graphdb/conn_linux.go diff --git a/graphdb/conn_darwin.go b/graphdb/conn_darwin.go new file mode 100644 index 0000000000..6e75fd8edb --- /dev/null +++ b/graphdb/conn_darwin.go @@ -0,0 +1,5 @@ +package graphdb + +func NewSqliteConn(root string) (*Database, error) { + panic("Not implemented") +} diff --git a/graphdb/conn_linux.go b/graphdb/conn_linux.go new file mode 100644 index 0000000000..2bd51940ce --- /dev/null +++ b/graphdb/conn_linux.go @@ -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) +} diff --git a/runtime.go b/runtime.go index 54c2a47e4e..a6233339cb 100644 --- a/runtime.go +++ b/runtime.go @@ -1,9 +1,7 @@ package docker import ( - _ "code.google.com/p/gosqlite/sqlite3" // registers sqlite "container/list" - "database/sql" "fmt" "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/graphdb" @@ -718,19 +716,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { } graphdbPath := path.Join(config.Root, "linkgraph.db") - initDatabase := false - 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) + graph, err := graphdb.NewSqliteConn(graphdbPath) if err != nil { return nil, err }