Skip to content

Commit

Permalink
Small fixes to type names
Browse files Browse the repository at this point in the history
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
  • Loading branch information
crosbymichael committed Jan 18, 2014
1 parent 889b4b1 commit ca8dd73
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion execdriver/chroot/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
)

func init() {
execdriver.RegisterDockerInitFct(DriverName, func(args *execdriver.DockerInitArgs) error {
execdriver.RegisterInitFunc(DriverName, func(args *execdriver.InitArgs) error {
if err := mount.ForceMount("proc", "proc", "proc", ""); err != nil {
return err
}
Expand Down
23 changes: 12 additions & 11 deletions execdriver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ var (
ErrDriverNotFound = errors.New("The requested docker init has not been found")
)

var dockerInitFcts map[string]DockerInitFct
var dockerInitFcts map[string]InitFunc

type (
StartCallback func(*Process)
DockerInitFct func(i *DockerInitArgs) error
InitFunc func(i *InitArgs) error
)

func RegisterDockerInitFct(name string, fct DockerInitFct) error {
func RegisterInitFunc(name string, fct InitFunc) error {
if dockerInitFcts == nil {
dockerInitFcts = make(map[string]DockerInitFct)
dockerInitFcts = make(map[string]InitFunc)
}
if _, ok := dockerInitFcts[name]; ok {
return ErrDriverAlreadyRegistered
Expand All @@ -31,15 +31,16 @@ func RegisterDockerInitFct(name string, fct DockerInitFct) error {
return nil
}

func GetDockerInitFct(name string) (DockerInitFct, error) {
func GetInitFunc(name string) (InitFunc, error) {
fct, ok := dockerInitFcts[name]
if !ok {
return nil, ErrDriverNotFound
}
return fct, nil
}

type DockerInitArgs struct {
// Args provided to the init function for a driver
type InitArgs struct {
User string
Gateway string
Ip string
Expand All @@ -51,19 +52,19 @@ type DockerInitArgs struct {
Driver string
}

// Driver specific information based on
// processes registered with the driver
type Info interface {
IsRunning() bool
}

type Driver interface {
Run(c *Process, startCallback StartCallback) (int, error) // Run executes the process and blocks until the process exits and returns the exit code
Kill(c *Process, sig int) error
// TODO: @crosbymichael @creack wait should probably return the exit code
Wait(id string) error // Wait on an out of process...process - lxc ghosts
Version() string
Name() string

Info(id string) Info // "temporary" hack (until we move state from core to plugins)
Version() string // Driver version number
Name() string // Driver name
Info(id string) Info // "temporary" hack (until we move state from core to plugins)
}

// Network settings of the container
Expand Down
2 changes: 1 addition & 1 deletion execdriver/lxc/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const DriverName = "lxc"

func init() {
execdriver.RegisterDockerInitFct(DriverName, func(args *execdriver.DockerInitArgs) error {
execdriver.RegisterInitFunc(DriverName, func(args *execdriver.InitArgs) error {
if err := setupHostname(args); err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions execdriver/lxc/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"syscall"
)

func setupHostname(args *execdriver.DockerInitArgs) error {
func setupHostname(args *execdriver.InitArgs) error {
hostname := getEnv(args, "HOSTNAME")
if hostname == "" {
return nil
Expand All @@ -22,7 +22,7 @@ func setupHostname(args *execdriver.DockerInitArgs) error {
}

// Setup networking
func setupNetworking(args *execdriver.DockerInitArgs) error {
func setupNetworking(args *execdriver.InitArgs) error {
if args.Ip != "" {
// eth0
iface, err := net.InterfaceByName("eth0")
Expand Down Expand Up @@ -67,7 +67,7 @@ func setupNetworking(args *execdriver.DockerInitArgs) error {
}

// Setup working directory
func setupWorkingDirectory(args *execdriver.DockerInitArgs) error {
func setupWorkingDirectory(args *execdriver.InitArgs) error {
if args.WorkDir == "" {
return nil
}
Expand All @@ -78,7 +78,7 @@ func setupWorkingDirectory(args *execdriver.DockerInitArgs) error {
}

// Takes care of dropping privileges to the desired user
func changeUser(args *execdriver.DockerInitArgs) error {
func changeUser(args *execdriver.InitArgs) error {
if args.User == "" {
return nil
}
Expand Down Expand Up @@ -106,7 +106,7 @@ func changeUser(args *execdriver.DockerInitArgs) error {
return nil
}

func setupCapabilities(args *execdriver.DockerInitArgs) error {
func setupCapabilities(args *execdriver.InitArgs) error {

if args.Privileged {
return nil
Expand Down Expand Up @@ -142,7 +142,7 @@ func setupCapabilities(args *execdriver.DockerInitArgs) error {
return nil
}

func getEnv(args *execdriver.DockerInitArgs, key string) string {
func getEnv(args *execdriver.InitArgs, key string) string {
for _, kv := range args.Env {
parts := strings.SplitN(kv, "=", 2)
if parts[0] == key && len(parts) == 2 {
Expand Down
8 changes: 4 additions & 4 deletions sysinit/sysinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// Clear environment pollution introduced by lxc-start
func setupEnv(args *execdriver.DockerInitArgs) {
func setupEnv(args *execdriver.InitArgs) {
os.Clearenv()
for _, kv := range args.Env {
parts := strings.SplitN(kv, "=", 2)
Expand All @@ -23,9 +23,9 @@ func setupEnv(args *execdriver.DockerInitArgs) {
}
}

func executeProgram(args *execdriver.DockerInitArgs) error {
func executeProgram(args *execdriver.InitArgs) error {
setupEnv(args)
dockerInitFct, err := execdriver.GetDockerInitFct(args.Driver)
dockerInitFct, err := execdriver.GetInitFunc(args.Driver)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func SysInit() {
// Propagate the plugin-specific container env variable
env = append(env, "container="+os.Getenv("container"))

args := &execdriver.DockerInitArgs{
args := &execdriver.InitArgs{
User: *user,
Gateway: *gateway,
Ip: *ip,
Expand Down

0 comments on commit ca8dd73

Please sign in to comment.