kpod create and run

Add the ability to run create a container with kpod.  Also, be able to run
(create and start) a container.  If the user asks for -it, be able to
attach a terminal to the container.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude 2017-10-26 19:26:04 -05:00
parent 484a26d540
commit 7f7ccc375f
8 changed files with 1366 additions and 114 deletions

34
libpod/util.go Normal file
View file

@ -0,0 +1,34 @@
package libpod
import (
"os"
"path/filepath"
)
// WriteFile writes a provided string to a provided path
func WriteFile(content string, path string) error {
baseDir := filepath.Dir(path)
if baseDir != "" {
if _, err := os.Stat(path); err != nil {
return err
}
}
f, err := os.Create(path)
defer f.Close()
if err != nil {
return err
}
f.WriteString(content)
f.Sync()
return nil
}
// StringInSlice determines if a string is in a string slice, returns bool
func StringInSlice(s string, sl []string) bool {
for _, i := range sl {
if i == s {
return true
}
}
return false
}