Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
More error handling and fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
  • Loading branch information
mrunalp authored and vmarmol committed Dec 5, 2014
1 parent 3f26e9a commit de57f78
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions linux_factory.go
Expand Up @@ -18,7 +18,8 @@ const (
)

var (
idRegex = regexp.MustCompile(`^[\w_]{1,1024}$`)
idRegex = regexp.MustCompile(`^[\w_]+$`)
maxIdLen = 1024
)

// New returns a linux based container factory based in the root directory.
Expand Down Expand Up @@ -47,9 +48,16 @@ func (l *linuxFactory) Create(id string, config *Config) (Container, error) {
return nil, newGenericError(fmt.Errorf("Invalid id format: %v", id), InvalidIdFormat)
}

if len(id) > maxIdLen {
return nil, newGenericError(fmt.Errorf("Invalid id format: %v", id), InvalidIdFormat)
}

containerRoot := filepath.Join(l.root, id)
if _, err := os.Stat(containerRoot); err == nil {
_, err := os.Stat(containerRoot)
if err == nil {
return nil, newGenericError(fmt.Errorf("Container with id exists: %v", id), IdInUse)
} else if !os.IsNotExist(err) {
return nil, newGenericError(err, SystemError)
}

panic("not implemented")
Expand Down

0 comments on commit de57f78

Please sign in to comment.