Browse code

Move remote API config out of daemon/

Signed-off-by: Solomon Hykes <solomon@docker.com>

Solomon Hykes authored on 2014/08/12 07:30:01
Showing 10 changed files
... ...
@@ -505,9 +505,6 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
505 505
 		if initPath := remoteInfo.Get("InitPath"); initPath != "" {
506 506
 			fmt.Fprintf(cli.out, "Init Path: %s\n", initPath)
507 507
 		}
508
-		if len(remoteInfo.GetList("Sockets")) != 0 {
509
-			fmt.Fprintf(cli.out, "Sockets: %v\n", remoteInfo.GetList("Sockets"))
510
-		}
511 508
 	}
512 509
 
513 510
 	if len(remoteInfo.GetList("IndexServerAddress")) != 0 {
... ...
@@ -36,7 +36,6 @@ type Config struct {
36 36
 	DisableNetwork              bool
37 37
 	EnableSelinuxSupport        bool
38 38
 	Context                     map[string][]string
39
-	Sockets                     []string
40 39
 }
41 40
 
42 41
 // InstallFlags adds command-line options to the top-level flag parser for
... ...
@@ -59,7 +58,6 @@ func (config *Config) InstallFlags() {
59 59
 	opts.IPVar(&config.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP address to use when binding container ports")
60 60
 	opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options")
61 61
 	// FIXME: why the inconsistency between "hosts" and "sockets"?
62
-	opts.HostListVar(&config.Sockets, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
63 62
 	opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
64 63
 	opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
65 64
 }
... ...
@@ -98,7 +98,6 @@ type Daemon struct {
98 98
 	containerGraph *graphdb.Database
99 99
 	driver         graphdriver.Driver
100 100
 	execDriver     execdriver.Driver
101
-	Sockets        []string
102 101
 }
103 102
 
104 103
 // Install installs daemon capabilities to eng.
... ...
@@ -851,7 +850,6 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
851 851
 		sysInitPath:    sysInitPath,
852 852
 		execDriver:     ed,
853 853
 		eng:            eng,
854
-		Sockets:        config.Sockets,
855 854
 	}
856 855
 	if err := daemon.checkLocaldns(); err != nil {
857 856
 		return nil, err
... ...
@@ -66,7 +66,6 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
66 66
 	v.Set("IndexServerAddress", registry.IndexServerAddress())
67 67
 	v.Set("InitSha1", dockerversion.INITSHA1)
68 68
 	v.Set("InitPath", initPath)
69
-	v.SetList("Sockets", daemon.Sockets)
70 69
 	if _, err := v.WriteTo(job.Stdout); err != nil {
71 70
 		return job.Error(err)
72 71
 	}
... ...
@@ -63,8 +63,7 @@ func mainDaemon() {
63 63
 	)
64 64
 
65 65
 	// Serve api
66
-	// FIXME: 'Sockets' should not be part of daemon.Config
67
-	job := eng.Job("serveapi", daemonCfg.Sockets...)
66
+	job := eng.Job("serveapi", flHosts...)
68 67
 	job.SetenvBool("Logging", true)
69 68
 	job.SetenvBool("EnableCors", *flEnableCors)
70 69
 	job.Setenv("Version", dockerversion.VERSION)
... ...
@@ -38,7 +38,7 @@ func main() {
38 38
 		os.Setenv("DEBUG", "1")
39 39
 	}
40 40
 
41
-	if len(daemonCfg.Sockets) == 0 {
41
+	if len(flHosts) == 0 {
42 42
 		defaultHost := os.Getenv("DOCKER_HOST")
43 43
 		if defaultHost == "" || *flDaemon {
44 44
 			// If we do not have a host, default to unix socket
... ...
@@ -47,7 +47,7 @@ func main() {
47 47
 		if _, err := api.ValidateHost(defaultHost); err != nil {
48 48
 			log.Fatal(err)
49 49
 		}
50
-		daemonCfg.Sockets = append(daemonCfg.Sockets, defaultHost)
50
+		flHosts = append(flHosts, defaultHost)
51 51
 	}
52 52
 
53 53
 	if *flDaemon {
... ...
@@ -55,10 +55,10 @@ func main() {
55 55
 		return
56 56
 	}
57 57
 
58
-	if len(daemonCfg.Sockets) > 1 {
58
+	if len(flHosts) > 1 {
59 59
 		log.Fatal("Please specify only one -H")
60 60
 	}
61
-	protoAddrParts := strings.SplitN(daemonCfg.Sockets[0], "://", 2)
61
+	protoAddrParts := strings.SplitN(flHosts[0], "://", 2)
62 62
 
63 63
 	var (
64 64
 		cli       *client.DockerCli
... ...
@@ -4,6 +4,7 @@ import (
4 4
 	"os"
5 5
 	"path/filepath"
6 6
 
7
+	"github.com/docker/docker/opts"
7 8
 	flag "github.com/docker/docker/pkg/mflag"
8 9
 )
9 10
 
... ...
@@ -27,13 +28,15 @@ var (
27 27
 	flTlsVerify   = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
28 28
 
29 29
 	// these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
30
-	flCa   *string
31
-	flCert *string
32
-	flKey  *string
30
+	flCa    *string
31
+	flCert  *string
32
+	flKey   *string
33
+	flHosts []string
33 34
 )
34 35
 
35 36
 func init() {
36 37
 	flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerCertPath, defaultCaFile), "Trust only remotes providing a certificate signed by the CA given here")
37 38
 	flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerCertPath, defaultCertFile), "Path to TLS certificate file")
38 39
 	flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerCertPath, defaultKeyFile), "Path to TLS key file")
40
+	opts.HostListVar(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
39 41
 }
... ...
@@ -1170,7 +1170,6 @@ Display system-wide information
1170 1170
              "NGoroutines":21,
1171 1171
              "NEventsListener":0,
1172 1172
              "InitPath":"/usr/bin/docker",
1173
-             "Sockets":["unix:///var/run/docker.sock"],
1174 1173
              "IndexServerAddress":["https://index.docker.io/v1/"],
1175 1174
              "MemoryLimit":true,
1176 1175
              "SwapLimit":false,
... ...
@@ -1174,7 +1174,6 @@ Display system-wide information
1174 1174
              "NGoroutines":21,
1175 1175
              "NEventsListener":0,
1176 1176
              "InitPath":"/usr/bin/docker",
1177
-             "Sockets":["unix:///var/run/docker.sock"],
1178 1177
              "IndexServerAddress":["https://index.docker.io/v1/"],
1179 1178
              "MemoryLimit":true,
1180 1179
              "SwapLimit":false,
... ...
@@ -616,7 +616,6 @@ For example:
616 616
     Goroutines: 9
617 617
     EventsListeners: 0
618 618
     Init Path: /usr/bin/docker
619
-    Sockets: [unix:///var/run/docker.sock]
620 619
     Username: svendowideit
621 620
     Registry: [https://index.docker.io/v1/]
622 621