Add container dir to oci
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
ac1340488d
commit
764f02ca11
3 changed files with 19 additions and 7 deletions
|
@ -31,6 +31,11 @@ func main() {
|
||||||
Value: "/usr/bin/runc",
|
Value: "/usr/bin/runc",
|
||||||
Usage: "OCI runtime path",
|
Usage: "OCI runtime path",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "containerdir",
|
||||||
|
Value: "/var/lib/ocid/containers",
|
||||||
|
Usage: "ocid container dir",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(c *cli.Context) error {
|
app.Action = func(c *cli.Context) error {
|
||||||
|
@ -47,8 +52,9 @@ func main() {
|
||||||
|
|
||||||
s := grpc.NewServer()
|
s := grpc.NewServer()
|
||||||
|
|
||||||
|
containerDir := c.String("containerdir")
|
||||||
sandboxDir := c.String("sandboxdir")
|
sandboxDir := c.String("sandboxdir")
|
||||||
service, err := server.New(c.String("runtime"), sandboxDir)
|
service, err := server.New(c.String("runtime"), sandboxDir, containerDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
14
oci/oci.go
14
oci/oci.go
|
@ -8,11 +8,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates a new Runtime with options provided
|
// New creates a new Runtime with options provided
|
||||||
func New(runtimePath string, sandboxDir string) (*Runtime, error) {
|
func New(runtimePath string, sandboxDir string, containerDir string) (*Runtime, error) {
|
||||||
r := &Runtime{
|
r := &Runtime{
|
||||||
name: filepath.Base(runtimePath),
|
name: filepath.Base(runtimePath),
|
||||||
path: runtimePath,
|
path: runtimePath,
|
||||||
sandboxDir: sandboxDir,
|
sandboxDir: sandboxDir,
|
||||||
|
containerDir: containerDir,
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
@ -39,6 +40,11 @@ func (r *Runtime) SandboxDir() string {
|
||||||
return r.sandboxDir
|
return r.sandboxDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerDir returns the path to the base directory for storing container configurations
|
||||||
|
func (r *Runtime) ContainerDir() string {
|
||||||
|
return r.containerDir
|
||||||
|
}
|
||||||
|
|
||||||
// Version returns the version of the OCI Runtime
|
// Version returns the version of the OCI Runtime
|
||||||
func (r *Runtime) Version() (string, error) {
|
func (r *Runtime) Version() (string, error) {
|
||||||
runtimeVersion, err := getOCIVersion(r.path, "-v")
|
runtimeVersion, err := getOCIVersion(r.path, "-v")
|
||||||
|
|
|
@ -15,8 +15,8 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Server with options provided
|
// New creates a new Server with options provided
|
||||||
func New(runtimePath, sandboxDir string) (*Server, error) {
|
func New(runtimePath, sandboxDir, containerDir string) (*Server, error) {
|
||||||
r, err := oci.New(runtimePath, sandboxDir)
|
r, err := oci.New(runtimePath, sandboxDir, containerDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue