diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2017-12-05 17:50:29 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-12-14 23:59:21 +0000 |
commit | 16237fe067362f73d0ce5699cef9b3b62a45dd3e (patch) | |
tree | 72cbcec4c11e310897b733d653f22cae75ccc0f6 /libpod/sql_state.go | |
parent | 2bc20dd4d212ebbf14ee0de8fae7ce115fe00926 (diff) | |
download | podman-16237fe067362f73d0ce5699cef9b3b62a45dd3e.tar.gz podman-16237fe067362f73d0ce5699cef9b3b62a45dd3e.tar.bz2 podman-16237fe067362f73d0ce5699cef9b3b62a45dd3e.zip |
Add networking configuration to the libpod DB
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #109
Approved by: mheon
Diffstat (limited to 'libpod/sql_state.go')
-rw-r--r-- | libpod/sql_state.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libpod/sql_state.go b/libpod/sql_state.go index 02cbd63d8..d0969a783 100644 --- a/libpod/sql_state.go +++ b/libpod/sql_state.go @@ -15,7 +15,7 @@ import ( // DBSchema is the current DB schema version // Increments every time a change is made to the database's tables -const DBSchema = 2 +const DBSchema = 3 // SQLState is a state implementation backed by a persistent SQLite3 database type SQLState struct { @@ -267,7 +267,7 @@ func (s *SQLState) HasContainer(id string) (bool, error) { func (s *SQLState) AddContainer(ctr *Container) (err error) { const ( addCtr = `INSERT INTO containers VALUES ( - ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? + ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );` addCtrState = `INSERT INTO containerState VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? @@ -287,6 +287,16 @@ func (s *SQLState) AddContainer(ctr *Container) (err error) { return errors.Wrapf(err, "error marshaling container %s labels to JSON", ctr.ID()) } + mounts, err := json.Marshal(ctr.config.Mounts) + if err != nil { + return errors.Wrapf(err, "error marshaling container %s mounts to JSON", ctr.ID()) + } + + portsJSON, err := json.Marshal(ctr.config.PortMappings) + if err != nil { + return errors.Wrapf(err, "error marshaling container %s port mappings to JSON", ctr.ID()) + } + tx, err := s.db.Begin() if err != nil { return errors.Wrapf(err, "error beginning database transaction") @@ -299,10 +309,6 @@ func (s *SQLState) AddContainer(ctr *Container) (err error) { } }() - mounts, err := json.Marshal(ctr.config.Mounts) - if err != nil { - return errors.Wrapf(err, "error marshaling container %s monunts to JSON", ctr.ID()) - } // Add static container information _, err = tx.Exec(addCtr, ctr.ID(), @@ -311,6 +317,8 @@ func (s *SQLState) AddContainer(ctr *Container) (err error) { ctr.config.MountLabel, string(mounts), ctr.config.ShmDir, + boolToSQL(ctr.config.CreateNetNS), + string(portsJSON), ctr.config.StaticDir, boolToSQL(ctr.config.Stdin), string(labelsJSON), |