| ... | ... |
@@ -394,9 +394,9 @@ func (container *Container) Inject(file io.Reader, pth string) error {
|
| 394 | 394 |
if _, err := os.Stat(path.Join(container.rwPath(), pth)); err == nil {
|
| 395 | 395 |
// Since err is nil, the path could be stat'd and it exists |
| 396 | 396 |
return fmt.Errorf("%s exists", pth)
|
| 397 |
- } else if ! os.IsNotExist(err) {
|
|
| 397 |
+ } else if !os.IsNotExist(err) {
|
|
| 398 | 398 |
// Expect err might be that the file doesn't exist, so |
| 399 |
- // if it's some other error, return that. |
|
| 399 |
+ // if it's some other error, return that. |
|
| 400 | 400 |
|
| 401 | 401 |
return err |
| 402 | 402 |
} |
| ... | ... |
@@ -1086,7 +1086,7 @@ func (container *Container) allocateNetwork() error {
|
| 1086 | 1086 |
Gateway: manager.bridgeNetwork.IP, |
| 1087 | 1087 |
manager: manager, |
| 1088 | 1088 |
} |
| 1089 |
- if iface !=nil && iface.IPNet.IP != nil {
|
|
| 1089 |
+ if iface != nil && iface.IPNet.IP != nil {
|
|
| 1090 | 1090 |
ipNum := ipToInt(iface.IPNet.IP) |
| 1091 | 1091 |
manager.ipAllocator.inUse[ipNum] = struct{}{}
|
| 1092 | 1092 |
} else {
|
| ... | ... |
@@ -2,13 +2,12 @@ package engine |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
- "os" |
|
| 5 |
+ "github.com/dotcloud/docker/utils" |
|
| 6 | 6 |
"log" |
| 7 |
+ "os" |
|
| 7 | 8 |
"runtime" |
| 8 |
- "github.com/dotcloud/docker/utils" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 |
- |
|
| 12 | 11 |
type Handler func(*Job) string |
| 13 | 12 |
|
| 14 | 13 |
var globalHandlers map[string]Handler |
| ... | ... |
@@ -25,8 +24,8 @@ func Register(name string, handler Handler) error {
|
| 25 | 25 |
// It acts as a store for *containers*, and allows manipulation of these |
| 26 | 26 |
// containers by executing *jobs*. |
| 27 | 27 |
type Engine struct {
|
| 28 |
- root string |
|
| 29 |
- handlers map[string]Handler |
|
| 28 |
+ root string |
|
| 29 |
+ handlers map[string]Handler |
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
// New initializes a new engine managing the directory specified at `root`. |
| ... | ... |
@@ -56,8 +55,8 @@ func New(root string) (*Engine, error) {
|
| 56 | 56 |
return nil, err |
| 57 | 57 |
} |
| 58 | 58 |
eng := &Engine{
|
| 59 |
- root: root, |
|
| 60 |
- handlers: globalHandlers, |
|
| 59 |
+ root: root, |
|
| 60 |
+ handlers: globalHandlers, |
|
| 61 | 61 |
} |
| 62 | 62 |
return eng, nil |
| 63 | 63 |
} |
| ... | ... |
@@ -66,12 +65,12 @@ func New(root string) (*Engine, error) {
|
| 66 | 66 |
// This function mimics `Command` from the standard os/exec package. |
| 67 | 67 |
func (eng *Engine) Job(name string, args ...string) *Job {
|
| 68 | 68 |
job := &Job{
|
| 69 |
- eng: eng, |
|
| 70 |
- Name: name, |
|
| 71 |
- Args: args, |
|
| 72 |
- Stdin: os.Stdin, |
|
| 73 |
- Stdout: os.Stdout, |
|
| 74 |
- Stderr: os.Stderr, |
|
| 69 |
+ eng: eng, |
|
| 70 |
+ Name: name, |
|
| 71 |
+ Args: args, |
|
| 72 |
+ Stdin: os.Stdin, |
|
| 73 |
+ Stdout: os.Stdout, |
|
| 74 |
+ Stderr: os.Stderr, |
|
| 75 | 75 |
} |
| 76 | 76 |
handler, exists := eng.handlers[name] |
| 77 | 77 |
if exists {
|
| ... | ... |
@@ -79,4 +78,3 @@ func (eng *Engine) Job(name string, args ...string) *Job {
|
| 79 | 79 |
} |
| 80 | 80 |
return job |
| 81 | 81 |
} |
| 82 |
- |
| ... | ... |
@@ -1,18 +1,18 @@ |
| 1 | 1 |
package engine |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "testing" |
|
| 5 |
- "runtime" |
|
| 6 |
- "strings" |
|
| 7 | 4 |
"fmt" |
| 8 |
- "io/ioutil" |
|
| 9 | 5 |
"github.com/dotcloud/docker/utils" |
| 6 |
+ "io/ioutil" |
|
| 7 |
+ "runtime" |
|
| 8 |
+ "strings" |
|
| 9 |
+ "testing" |
|
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 | 12 |
var globalTestID string |
| 13 | 13 |
|
| 14 | 14 |
func init() {
|
| 15 |
- Register("dummy", func(job *Job) string { return ""; })
|
|
| 15 |
+ Register("dummy", func(job *Job) string { return "" })
|
|
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 | 18 |
func mkEngine(t *testing.T) *Engine {
|
| ... | ... |
@@ -1,11 +1,11 @@ |
| 1 | 1 |
package engine |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "io" |
|
| 5 |
- "strings" |
|
| 6 |
- "fmt" |
|
| 7 | 4 |
"encoding/json" |
| 5 |
+ "fmt" |
|
| 8 | 6 |
"github.com/dotcloud/docker/utils" |
| 7 |
+ "io" |
|
| 8 |
+ "strings" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
// A job is the fundamental unit of work in the docker engine. |
| ... | ... |
@@ -20,17 +20,17 @@ import ( |
| 20 | 20 |
// One slight variation is that jobs report their status as a string. The |
| 21 | 21 |
// string "0" indicates success, and any other strings indicates an error. |
| 22 | 22 |
// This allows for richer error reporting. |
| 23 |
-// |
|
| 23 |
+// |
|
| 24 | 24 |
type Job struct {
|
| 25 |
- eng *Engine |
|
| 26 |
- Name string |
|
| 27 |
- Args []string |
|
| 28 |
- env []string |
|
| 29 |
- Stdin io.ReadCloser |
|
| 30 |
- Stdout io.WriteCloser |
|
| 31 |
- Stderr io.WriteCloser |
|
| 32 |
- handler func(*Job) string |
|
| 33 |
- status string |
|
| 25 |
+ eng *Engine |
|
| 26 |
+ Name string |
|
| 27 |
+ Args []string |
|
| 28 |
+ env []string |
|
| 29 |
+ Stdin io.ReadCloser |
|
| 30 |
+ Stdout io.WriteCloser |
|
| 31 |
+ Stderr io.WriteCloser |
|
| 32 |
+ handler func(*Job) string |
|
| 33 |
+ status string |
|
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
// Run executes the job and blocks until the job completes. |
| ... | ... |
@@ -57,21 +57,21 @@ func (job *Job) String() string {
|
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 | 59 |
func (job *Job) Getenv(key string) (value string) {
|
| 60 |
- for _, kv := range job.env {
|
|
| 61 |
- if strings.Index(kv, "=") == -1 {
|
|
| 62 |
- continue |
|
| 63 |
- } |
|
| 64 |
- parts := strings.SplitN(kv, "=", 2) |
|
| 65 |
- if parts[0] != key {
|
|
| 66 |
- continue |
|
| 67 |
- } |
|
| 68 |
- if len(parts) < 2 {
|
|
| 69 |
- value = "" |
|
| 70 |
- } else {
|
|
| 71 |
- value = parts[1] |
|
| 72 |
- } |
|
| 73 |
- } |
|
| 74 |
- return |
|
| 60 |
+ for _, kv := range job.env {
|
|
| 61 |
+ if strings.Index(kv, "=") == -1 {
|
|
| 62 |
+ continue |
|
| 63 |
+ } |
|
| 64 |
+ parts := strings.SplitN(kv, "=", 2) |
|
| 65 |
+ if parts[0] != key {
|
|
| 66 |
+ continue |
|
| 67 |
+ } |
|
| 68 |
+ if len(parts) < 2 {
|
|
| 69 |
+ value = "" |
|
| 70 |
+ } else {
|
|
| 71 |
+ value = parts[1] |
|
| 72 |
+ } |
|
| 73 |
+ } |
|
| 74 |
+ return |
|
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 | 77 |
func (job *Job) GetenvBool(key string) (value bool) {
|
| ... | ... |
@@ -109,5 +109,5 @@ func (job *Job) SetenvList(key string, value []string) error {
|
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 | 111 |
func (job *Job) Setenv(key, value string) {
|
| 112 |
- job.env = append(job.env, key + "=" + value) |
|
| 112 |
+ job.env = append(job.env, key+"="+value) |
|
| 113 | 113 |
} |
| ... | ... |
@@ -12,7 +12,7 @@ type NameChecker interface {
|
| 12 | 12 |
|
| 13 | 13 |
var ( |
| 14 | 14 |
colors = [...]string{"white", "silver", "gray", "black", "blue", "green", "cyan", "yellow", "gold", "orange", "brown", "red", "violet", "pink", "magenta", "purple", "maroon", "crimson", "plum", "fuchsia", "lavender", "slate", "navy", "azure", "aqua", "olive", "teal", "lime", "beige", "tan", "sienna"}
|
| 15 |
- animals = [...]string{"ant", "bear", "bird", "cat", "chicken", "cow", "deer", "dog", "donkey", "duck", "fish", "fox", "frog", "horse", "kangaroo", "koala", "lemur", "lion", "lizard", "monkey", "octopus", "pig", "shark", "sheep", "sloth", "spider", "squirrel", "tiger", "toad", "weasel", "whale", "wolf"}
|
|
| 15 |
+ animals = [...]string{"ant", "bear", "bird", "cat", "chicken", "cow", "deer", "dog", "donkey", "duck", "fish", "fox", "frog", "horse", "kangaroo", "koala", "lemur", "lion", "lizard", "monkey", "octopus", "pig", "shark", "sheep", "sloth", "spider", "squirrel", "tiger", "toad", "weasel", "whale", "wolf"}
|
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
func GenerateRandomName(checker NameChecker) (string, error) {
|
| ... | ... |
@@ -9,7 +9,6 @@ func NetworkGetRoutes() ([]*net.IPNet, error) {
|
| 9 | 9 |
return nil, fmt.Errorf("Not implemented")
|
| 10 | 10 |
} |
| 11 | 11 |
|
| 12 |
- |
|
| 13 | 12 |
func NetworkLinkAdd(name string, linkType string) error {
|
| 14 | 13 |
return fmt.Errorf("Not implemented")
|
| 15 | 14 |
} |
| ... | ... |
@@ -18,7 +17,6 @@ func NetworkLinkUp(iface *net.Interface) error {
|
| 18 | 18 |
return fmt.Errorf("Not implemented")
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
- |
|
| 22 | 21 |
func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error {
|
| 23 | 22 |
return fmt.Errorf("Not implemented")
|
| 24 | 23 |
} |
| ... | ... |
@@ -15,8 +15,8 @@ import ( |
| 15 | 15 |
"os" |
| 16 | 16 |
"os/exec" |
| 17 | 17 |
"path/filepath" |
| 18 |
- "runtime" |
|
| 19 | 18 |
"regexp" |
| 19 |
+ "runtime" |
|
| 20 | 20 |
"strconv" |
| 21 | 21 |
"strings" |
| 22 | 22 |
"sync" |
| ... | ... |
@@ -904,7 +904,7 @@ func StripComments(input []byte, commentMarker []byte) []byte {
|
| 904 | 904 |
return output |
| 905 | 905 |
} |
| 906 | 906 |
|
| 907 |
-// GetNameserversAsCIDR returns nameservers (if any) listed in |
|
| 907 |
+// GetNameserversAsCIDR returns nameservers (if any) listed in |
|
| 908 | 908 |
// /etc/resolv.conf as CIDR blocks (e.g., "1.2.3.4/32") |
| 909 | 909 |
// This function's output is intended for net.ParseCIDR |
| 910 | 910 |
func GetNameserversAsCIDR(resolvConf []byte) []string {
|
| ... | ... |
@@ -453,20 +453,20 @@ search example.com`: {"1.2.3.4/32", "4.3.2.1/32"},
|
| 453 | 453 |
`search example.com`: {},
|
| 454 | 454 |
`nameserver 1.2.3.4 |
| 455 | 455 |
search example.com |
| 456 |
-nameserver 4.3.2.1`: []string{"1.2.3.4/32", "4.3.2.1/32"},
|
|
| 457 |
- ``: []string{},
|
|
| 458 |
- ` nameserver 1.2.3.4 `: []string{"1.2.3.4/32"},
|
|
| 459 |
- `search example.com |
|
| 456 |
+nameserver 4.3.2.1`: {"1.2.3.4/32", "4.3.2.1/32"},
|
|
| 457 |
+ ``: {},
|
|
| 458 |
+ ` nameserver 1.2.3.4 `: {"1.2.3.4/32"},
|
|
| 459 |
+ `search example.com |
|
| 460 | 460 |
nameserver 1.2.3.4 |
| 461 |
-#nameserver 4.3.2.1`: []string{"1.2.3.4/32"},
|
|
| 462 |
- `search example.com |
|
| 463 |
-nameserver 1.2.3.4 # not 4.3.2.1`: []string{"1.2.3.4/32"},
|
|
| 464 |
- } {
|
|
| 465 |
- test := GetNameserversAsCIDR([]byte(resolv)) |
|
| 466 |
- if !StrSlicesEqual(test, result) {
|
|
| 467 |
- t.Fatalf("Wrong nameserver string {%s} should be %v. Input: %s", test, result, resolv)
|
|
| 468 |
- } |
|
| 469 |
- } |
|
| 461 |
+#nameserver 4.3.2.1`: {"1.2.3.4/32"},
|
|
| 462 |
+ `search example.com |
|
| 463 |
+nameserver 1.2.3.4 # not 4.3.2.1`: {"1.2.3.4/32"},
|
|
| 464 |
+ } {
|
|
| 465 |
+ test := GetNameserversAsCIDR([]byte(resolv)) |
|
| 466 |
+ if !StrSlicesEqual(test, result) {
|
|
| 467 |
+ t.Fatalf("Wrong nameserver string {%s} should be %v. Input: %s", test, result, resolv)
|
|
| 468 |
+ } |
|
| 469 |
+ } |
|
| 470 | 470 |
} |
| 471 | 471 |
|
| 472 | 472 |
func StrSlicesEqual(a, b []string) bool {
|