Further refactoring

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2016-08-01 16:05:37 -07:00
parent 0bb2fb04d9
commit c13dbaf6ab
3 changed files with 22 additions and 14 deletions

View file

@ -10,23 +10,37 @@ const (
// Server implements the RuntimeService and ImageService
type Server struct {
runtime *oci.Runtime
sandboxes []*sandbox
runtime *oci.Runtime
sandboxDir string
state *serverState
}
// New creates a new Server with options provided
func New(runtimePath, sandboxDir, containerDir string) (*Server, error) {
r, err := oci.New(runtimePath, sandboxDir, containerDir)
r, err := oci.New(runtimePath, containerDir)
if err != nil {
return nil, err
}
sandboxes := make(map[string]*sandbox)
return &Server{
runtime: r,
runtime: r,
sandboxDir: sandboxDir,
state: &serverState{
sandboxes: sandboxes,
},
}, nil
}
type serverState struct {
sandboxes map[string]*sandbox
}
type sandbox struct {
name string
logDir string
labels map[string]string
}
func (s *Server) addSandbox(sb *sandbox) {
s.state.sandboxes[sb.name] = sb
}