From 764f02ca11880da1f6febf9da79e2c520dafa587 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 1 Aug 2016 15:08:21 -0700 Subject: [PATCH] Add container dir to oci Signed-off-by: Mrunal Patel --- cmd/server/main.go | 8 +++++++- oci/oci.go | 14 ++++++++++---- server/server.go | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 73bfd5c0..c774dfee 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -31,6 +31,11 @@ func main() { Value: "/usr/bin/runc", Usage: "OCI runtime path", }, + cli.StringFlag{ + Name: "containerdir", + Value: "/var/lib/ocid/containers", + Usage: "ocid container dir", + }, } app.Action = func(c *cli.Context) error { @@ -47,8 +52,9 @@ func main() { s := grpc.NewServer() + containerDir := c.String("containerdir") sandboxDir := c.String("sandboxdir") - service, err := server.New(c.String("runtime"), sandboxDir) + service, err := server.New(c.String("runtime"), sandboxDir, containerDir) if err != nil { log.Fatal(err) } diff --git a/oci/oci.go b/oci/oci.go index 35ebcbf1..5d8c9bca 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -8,11 +8,12 @@ import ( ) // 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{ - name: filepath.Base(runtimePath), - path: runtimePath, - sandboxDir: sandboxDir, + name: filepath.Base(runtimePath), + path: runtimePath, + sandboxDir: sandboxDir, + containerDir: containerDir, } return r, nil } @@ -39,6 +40,11 @@ func (r *Runtime) SandboxDir() string { 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 func (r *Runtime) Version() (string, error) { runtimeVersion, err := getOCIVersion(r.path, "-v") diff --git a/server/server.go b/server/server.go index 7de4e010..4b6028e8 100644 --- a/server/server.go +++ b/server/server.go @@ -15,8 +15,8 @@ type Server struct { } // New creates a new Server with options provided -func New(runtimePath, sandboxDir string) (*Server, error) { - r, err := oci.New(runtimePath, sandboxDir) +func New(runtimePath, sandboxDir, containerDir string) (*Server, error) { + r, err := oci.New(runtimePath, sandboxDir, containerDir) if err != nil { return nil, err }