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:
parent
484a26d540
commit
7f7ccc375f
8 changed files with 1366 additions and 114 deletions
34
libpod/util.go
Normal file
34
libpod/util.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue