@@ -30,6 +30,7 @@ import (
3030 _ "github.com/docker/machine/drivers/vmwarevcloudair"
3131 _ "github.com/docker/machine/drivers/vmwarevsphere"
3232 "github.com/docker/machine/libmachine"
33+ "github.com/docker/machine/libmachine/auth"
3334 "github.com/docker/machine/libmachine/engine"
3435 "github.com/docker/machine/libmachine/swarm"
3536 "github.com/docker/machine/state"
@@ -39,26 +40,24 @@ import (
3940type machineConfig struct {
4041 machineName string
4142 machineDir string
42- caCertPath string
43- caKeyPath string
44- clientCertPath string
43+ machineUrl string
4544 clientKeyPath string
4645 serverCertPath string
46+ clientCertPath string
47+ caCertPath string
48+ caKeyPath string
4749 serverKeyPath string
48- machineUrl string
49- swarmMaster bool
50- swarmHost string
51- swarmDiscovery string
50+ AuthConfig auth.AuthOptions
51+ SwarmConfig swarm.SwarmOptions
5252}
5353
5454type hostListItem struct {
55- Name string
56- Active bool
57- DriverName string
58- State state.State
59- URL string
60- SwarmMaster bool
61- SwarmDiscovery string
55+ Name string
56+ Active bool
57+ DriverName string
58+ State state.State
59+ URL string
60+ SwarmConfig swarm.SwarmOptions
6261}
6362
6463type certPathInfo struct {
@@ -406,18 +405,26 @@ func cmdCreate(c *cli.Context) {
406405 log .Fatal (err )
407406 }
408407
409- hostOptions := & libmachine.HostOptions {
410- DriverOptions : c ,
411- EngineOptions : & engine.EngineOptions {},
412- SwarmOptions : & swarm.SwarmOptions {
408+ hostConfig := & libmachine.HostOptions {
409+ AuthConfig : & auth.AuthOptions {
410+ CaCertPath : c .GlobalString ("tls-ca-cert" ),
411+ PrivateKeyPath : c .GlobalString ("tls-ca-key" ),
412+ ClientCertPath : c .GlobalString ("tls-client-cert" ),
413+ ClientKeyPath : filepath .Join (utils .GetMachineCertDir (), "key.pem" ),
414+ ServerCertPath : filepath .Join (utils .GetMachineDir (), name , "server.pem" ),
415+ ServerKeyPath : filepath .Join (utils .GetMachineDir (), name , "server-key.pem" ),
416+ },
417+ EngineConfig : & engine.EngineOptions {},
418+ SwarmConfig : & swarm.SwarmOptions {
419+ IsSwarm : c .Bool ("swarm" ),
413420 Master : c .GlobalBool ("swarm-master" ),
414421 Discovery : c .GlobalString ("swarm-discovery" ),
415422 Address : c .GlobalString ("swarm-addr" ),
416423 Host : c .GlobalString ("swarm-host" ),
417424 },
418425 }
419426
420- host , err := mcn .Create (name , driver , hostOptions )
427+ host , err := mcn .Create (name , driver , hostConfig , c )
421428 if err != nil {
422429 log .Errorf ("Error creating machine: %s" , err )
423430 log .Warn ("You will want to check the provider to make sure the machine and associated resources were properly removed." )
@@ -456,10 +463,10 @@ func cmdConfig(c *cli.Context) {
456463 }
457464
458465 if c .Bool ("swarm" ) {
459- if ! cfg .swarmMaster {
466+ if ! cfg .SwarmConfig . Master {
460467 log .Fatalf ("%s is not a swarm master" , cfg .machineName )
461468 }
462- u , err := url .Parse (cfg .swarmHost )
469+ u , err := url .Parse (cfg .SwarmConfig . Host )
463470 if err != nil {
464471 log .Fatal (err )
465472 }
@@ -563,13 +570,14 @@ func cmdLs(c *cli.Context) {
563570 swarmInfo := make (map [string ]string )
564571
565572 for _ , host := range hostList {
573+ swarmConfig := host .HostConfig .SwarmConfig
566574 if ! quiet {
567- if host . SwarmOptions .Master {
568- swarmMasters [host . SwarmOptions .Discovery ] = host .Name
575+ if swarmConfig .Master {
576+ swarmMasters [swarmConfig .Discovery ] = host .Name
569577 }
570578
571- if host . SwarmOptions .Discovery != "" {
572- swarmInfo [host .Name ] = host . SwarmOptions .Discovery
579+ if swarmConfig .Discovery != "" {
580+ swarmInfo [host .Name ] = swarmConfig .Discovery
573581 }
574582
575583 go getHostState (* host , defaultStore , hostListItems )
@@ -596,9 +604,9 @@ func cmdLs(c *cli.Context) {
596604
597605 swarmInfo := ""
598606
599- if item .SwarmDiscovery != "" {
600- swarmInfo = swarmMasters [item .SwarmDiscovery ]
601- if item .SwarmMaster {
607+ if item .SwarmConfig . Discovery != "" {
608+ swarmInfo = swarmMasters [item .SwarmConfig . Discovery ]
609+ if item .SwarmConfig . Master {
602610 swarmInfo = fmt .Sprintf ("%s (master)" , swarmInfo )
603611 }
604612 }
@@ -674,10 +682,10 @@ func cmdEnv(c *cli.Context) {
674682
675683 dockerHost := cfg .machineUrl
676684 if c .Bool ("swarm" ) {
677- if ! cfg .swarmMaster {
685+ if ! cfg .SwarmConfig . Master {
678686 log .Fatalf ("%s is not a swarm master" , cfg .machineName )
679687 }
680- u , err := url .Parse (cfg .swarmHost )
688+ u , err := url .Parse (cfg .SwarmConfig . Host )
681689 if err != nil {
682690 log .Fatal (err )
683691 }
@@ -1032,13 +1040,12 @@ func getHostState(host libmachine.Host, store libmachine.Store, hostListItems ch
10321040 }
10331041
10341042 hostListItems <- hostListItem {
1035- Name : host .Name ,
1036- Active : isActive ,
1037- DriverName : host .Driver .DriverName (),
1038- State : currentState ,
1039- URL : url ,
1040- SwarmMaster : host .SwarmOptions .Master ,
1041- SwarmDiscovery : host .SwarmOptions .Discovery ,
1043+ Name : host .Name ,
1044+ Active : isActive ,
1045+ DriverName : host .Driver .DriverName (),
1046+ State : currentState ,
1047+ URL : url ,
1048+ SwarmConfig : * host .HostConfig .SwarmConfig ,
10421049 }
10431050}
10441051
@@ -1096,16 +1103,15 @@ func getMachineConfig(c *cli.Context) (*machineConfig, error) {
10961103 return & machineConfig {
10971104 machineName : name ,
10981105 machineDir : machineDir ,
1099- caCertPath : caCert ,
1100- caKeyPath : caKey ,
1101- clientCertPath : clientCert ,
1106+ machineUrl : machineUrl ,
11021107 clientKeyPath : clientKey ,
1108+ clientCertPath : clientCert ,
11031109 serverCertPath : serverCert ,
1110+ caKeyPath : caKey ,
1111+ caCertPath : caCert ,
11041112 serverKeyPath : serverKey ,
1105- machineUrl : machineUrl ,
1106- swarmMaster : machine .SwarmOptions .Master ,
1107- swarmHost : machine .SwarmOptions .Host ,
1108- swarmDiscovery : machine .SwarmOptions .Discovery ,
1113+ AuthConfig : * machine .HostConfig .AuthConfig ,
1114+ SwarmConfig : * machine .HostConfig .SwarmConfig ,
11091115 }, nil
11101116}
11111117
0 commit comments