Save ContainerConfig.User to database

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #194
Approved by: rhatdan
This commit is contained in:
Matthew Heon
2018-01-06 12:44:33 -05:00
committed by Atomic Bot
parent 7b08aa78e4
commit 3d05f100f7
3 changed files with 9 additions and 3 deletions

View File

@ -157,6 +157,7 @@ type ContainerConfig struct {
CreatedTime time.Time `json:"createdTime"` CreatedTime time.Time `json:"createdTime"`
// User/GID to use within the container // User/GID to use within the container
User string `json:"user"` User string `json:"user"`
// TODO save log location here and pass into OCI code // TODO save log location here and pass into OCI code
// TODO allow overriding of log path // TODO allow overriding of log path
} }

View File

@ -15,7 +15,7 @@ import (
// DBSchema is the current DB schema version // DBSchema is the current DB schema version
// Increments every time a change is made to the database's tables // Increments every time a change is made to the database's tables
const DBSchema = 5 const DBSchema = 6
// SQLState is a state implementation backed by a persistent SQLite3 database // SQLState is a state implementation backed by a persistent SQLite3 database
type SQLState struct { type SQLState struct {
@ -271,7 +271,7 @@ func (s *SQLState) HasContainer(id string) (bool, error) {
func (s *SQLState) AddContainer(ctr *Container) (err error) { func (s *SQLState) AddContainer(ctr *Container) (err error) {
const ( const (
addCtr = `INSERT INTO containers VALUES ( addCtr = `INSERT INTO containers VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
);` );`
addCtrState = `INSERT INTO containerState VALUES ( addCtrState = `INSERT INTO containerState VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
@ -336,7 +336,8 @@ func (s *SQLState) AddContainer(ctr *Container) (err error) {
timeToSQL(ctr.config.CreatedTime), timeToSQL(ctr.config.CreatedTime),
ctr.config.RootfsImageID, ctr.config.RootfsImageID,
ctr.config.RootfsImageName, ctr.config.RootfsImageName,
boolToSQL(ctr.config.UseImageConfig)) boolToSQL(ctr.config.UseImageConfig),
ctr.config.User)
if err != nil { if err != nil {
return errors.Wrapf(err, "error adding static information for container %s to database", ctr.ID()) return errors.Wrapf(err, "error adding static information for container %s to database", ctr.ID())
} }

View File

@ -181,6 +181,7 @@ func prepareDB(db *sql.DB) (err error) {
RootfsImageID TEXT NOT NULL, RootfsImageID TEXT NOT NULL,
RootfsImageName TEXT NOT NULL, RootfsImageName TEXT NOT NULL,
UseImageConfig INTEGER NOT NULL, UseImageConfig INTEGER NOT NULL,
User TEXT NOT NULL,
CHECK (Stdin IN (0, 1)), CHECK (Stdin IN (0, 1)),
CHECK (CreateNetNS IN (0, 1)), CHECK (CreateNetNS IN (0, 1)),
CHECK (UseImageConfig IN (0, 1)), CHECK (UseImageConfig IN (0, 1)),
@ -290,6 +291,7 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
rootfsImageID string rootfsImageID string
rootfsImageName string rootfsImageName string
useImageConfig int useImageConfig int
user string
state int state int
configPath string configPath string
runDir string runDir string
@ -320,6 +322,7 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
&rootfsImageID, &rootfsImageID,
&rootfsImageName, &rootfsImageName,
&useImageConfig, &useImageConfig,
&user,
&state, &state,
&configPath, &configPath,
&runDir, &runDir,
@ -355,6 +358,7 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
ctr.config.Stdin = boolFromSQL(stdin) ctr.config.Stdin = boolFromSQL(stdin)
ctr.config.StopSignal = stopSignal ctr.config.StopSignal = stopSignal
ctr.config.StopTimeout = stopTimeout ctr.config.StopTimeout = stopTimeout
ctr.config.User = user
ctr.state.State = ContainerState(state) ctr.state.State = ContainerState(state)
ctr.state.ConfigPath = configPath ctr.state.ConfigPath = configPath