Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions linux_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package libcontainer

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"regexp"

"github.com/Sirupsen/logrus"
)
Expand All @@ -15,6 +17,10 @@ const (
stateFilename = "state.json"
)

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

// New returns a linux based container factory based in the root directory.
func New(root string, logger *logrus.Logger) (Factory, error) {
if err := os.MkdirAll(root, 0700); err != nil {
Expand All @@ -37,6 +43,10 @@ type linuxFactory struct {
}

func (l *linuxFactory) Create(id string, config *Config) (Container, error) {
if !idRegex.MatchString(id) {
return nil, newGenericError(fmt.Errorf("Invalid id format: %s ", id), InvalidIdFormat)
}

panic("not implemented")
}

Expand Down