Implement CreateContainer
Signed-off-by: Haiyan Meng <hmeng@redhat.com>
This commit is contained in:
parent
e3a34aa26d
commit
c2ee13d187
8 changed files with 567 additions and 12 deletions
51
oci/oci.go
51
oci/oci.go
|
@ -1,6 +1,7 @@
|
|||
package oci
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
@ -58,3 +59,53 @@ func getOCIVersion(name string, args ...string) (string, error) {
|
|||
v := firstLine[strings.LastIndex(firstLine, " ")+1:]
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// CreateContainer creates a container.
|
||||
func (r *Runtime) CreateContainer(c *Container) error {
|
||||
return utils.ExecCmdWithStdStreams(os.Stdin, os.Stdout, os.Stderr, r.path, "create", "--bundle", c.bundlePath, c.name)
|
||||
}
|
||||
|
||||
// Container respresents a runtime container.
|
||||
type Container struct {
|
||||
name string
|
||||
bundlePath string
|
||||
logPath string
|
||||
labels map[string]string
|
||||
sandbox string
|
||||
}
|
||||
|
||||
func NewContainer(name string, bundlePath string, logPath string, labels map[string]string, sandbox string) (*Container, error) {
|
||||
c := &Container{
|
||||
name: name,
|
||||
bundlePath: bundlePath,
|
||||
logPath: logPath,
|
||||
labels: labels,
|
||||
sandbox: sandbox,
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Name returns the name of the container.
|
||||
func (c *Container) Name() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
// BundlePath returns the bundlePath of the container.
|
||||
func (c *Container) BundlePath() string {
|
||||
return c.bundlePath
|
||||
}
|
||||
|
||||
// LogPath returns the log path of the container.
|
||||
func (c *Container) LogPath() string {
|
||||
return c.logPath
|
||||
}
|
||||
|
||||
// Labels returns the labels of the container.
|
||||
func (c *Container) Labels() map[string]string {
|
||||
return c.labels
|
||||
}
|
||||
|
||||
// Sandbox returns the sandbox name of the container.
|
||||
func (c *Container) Sandbox() string {
|
||||
return c.sandbox
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue