Merge pull request #2954 from jeanlaurent/engine-url

Fix #2029 - local drivers dont run with engine-install-url
This commit is contained in:
David Gageot
2016-01-28 18:26:01 +01:00
9 changed files with 56 additions and 7 deletions

View File

@@ -6,8 +6,9 @@ import (
)
const (
DefaultSSHUser = "root"
DefaultSSHPort = 22
DefaultSSHUser = "root"
DefaultSSHPort = 22
DefaultEngineInstallURL = "https://get.docker.com"
)
// BaseDriver - Embed this struct into drivers to provide the common set
@@ -83,3 +84,8 @@ func (d *BaseDriver) SetSwarmConfigFromFlags(flags DriverOptions) {
d.SwarmHost = flags.String("swarm-host")
d.SwarmDiscovery = flags.String("swarm-discovery")
}
func EngineInstallURLFlagSet(flags DriverOptions) bool {
engineInstallURLFlag := flags.String("engine-install-url")
return engineInstallURLFlag != DefaultEngineInstallURL && engineInstallURLFlag != ""
}

View File

@@ -4,6 +4,7 @@ import (
"errors"
"testing"
"github.com/docker/machine/libmachine/mcnflag"
"github.com/stretchr/testify/assert"
)
@@ -26,3 +27,24 @@ func TestIP(t *testing.T) {
assert.Equal(t, c.expectedErr, err)
}
}
func TestEngineInstallUrlFlagEmpty(t *testing.T) {
assert.False(t, EngineInstallURLFlagSet(&CheckDriverOptions{}))
}
func createDriverOptionWithEngineInstall(url string) *CheckDriverOptions {
return &CheckDriverOptions{
FlagsValues: map[string]interface{}{"engine-install-url": url},
CreateFlags: []mcnflag.Flag{mcnflag.StringFlag{Name: "engine-install-url", Value: ""}},
}
}
func TestEngineInstallUrlFlagDefault(t *testing.T) {
options := createDriverOptionWithEngineInstall(DefaultEngineInstallURL)
assert.False(t, EngineInstallURLFlagSet(options))
}
func TestEngineInstallUrlFlagSet(t *testing.T) {
options := createDriverOptionWithEngineInstall("https://test.docker.com")
assert.True(t, EngineInstallURLFlagSet(options))
}

View File

@@ -75,7 +75,7 @@ func (api *Client) NewHost(driverName string, rawDriver []byte) (*host.Host, err
ServerKeyPath: filepath.Join(api.GetMachinesDir(), "server-key.pem"),
},
EngineOptions: &engine.Options{
InstallURL: "https://get.docker.com",
InstallURL: drivers.DefaultEngineInstallURL,
StorageDriver: "aufs",
TLSVerify: true,
},