mirror of https://github.com/docker/docs.git
Merge pull request #2954 from jeanlaurent/engine-url
Fix #2029 - local drivers dont run with engine-install-url
This commit is contained in:
commit
b6be1b79bc
|
@ -45,7 +45,7 @@ var (
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "engine-install-url",
|
Name: "engine-install-url",
|
||||||
Usage: "Custom URL to use for engine installation",
|
Usage: "Custom URL to use for engine installation",
|
||||||
Value: "https://get.docker.com",
|
Value: drivers.DefaultEngineInstallURL,
|
||||||
EnvVar: "MACHINE_DOCKER_INSTALL_URL",
|
EnvVar: "MACHINE_DOCKER_INSTALL_URL",
|
||||||
},
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/drivers"
|
"github.com/docker/machine/libmachine/drivers"
|
||||||
"github.com/docker/machine/libmachine/log"
|
"github.com/docker/machine/libmachine/log"
|
||||||
"github.com/docker/machine/libmachine/mcnflag"
|
"github.com/docker/machine/libmachine/mcnflag"
|
||||||
|
@ -78,6 +80,9 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
|
if drivers.EngineInstallURLFlagSet(flags) {
|
||||||
|
return errors.New("--engine-install-url cannot be used with the hyperv driver, use --hyperv-boot2docker-url instead")
|
||||||
|
}
|
||||||
d.Boot2DockerURL = flags.String("hyperv-boot2docker-url")
|
d.Boot2DockerURL = flags.String("hyperv-boot2docker-url")
|
||||||
d.VSwitch = flags.String("hyperv-virtual-switch")
|
d.VSwitch = flags.String("hyperv-virtual-switch")
|
||||||
d.DiskSize = flags.Int("hyperv-disk-size")
|
d.DiskSize = flags.Int("hyperv-disk-size")
|
||||||
|
|
|
@ -190,6 +190,9 @@ func (d *Driver) GetURL() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
|
if drivers.EngineInstallURLFlagSet(flags) {
|
||||||
|
return errors.New("--engine-install-url cannot be used with the virtualbox driver, use --virtualbox-boot2docker-url instead")
|
||||||
|
}
|
||||||
d.CPU = flags.Int("virtualbox-cpu-count")
|
d.CPU = flags.Int("virtualbox-cpu-count")
|
||||||
d.Memory = flags.Int("virtualbox-memory")
|
d.Memory = flags.Int("virtualbox-memory")
|
||||||
d.DiskSize = flags.Int("virtualbox-disk-size")
|
d.DiskSize = flags.Int("virtualbox-disk-size")
|
||||||
|
|
|
@ -18,6 +18,8 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/drivers"
|
"github.com/docker/machine/libmachine/drivers"
|
||||||
"github.com/docker/machine/libmachine/log"
|
"github.com/docker/machine/libmachine/log"
|
||||||
"github.com/docker/machine/libmachine/mcnflag"
|
"github.com/docker/machine/libmachine/mcnflag"
|
||||||
|
@ -144,6 +146,9 @@ func (d *Driver) DriverName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
|
if drivers.EngineInstallURLFlagSet(flags) {
|
||||||
|
return errors.New("--engine-install-url cannot be used with the vmwarefusion driver, use --vmwarefusion-boot2docker-url instead")
|
||||||
|
}
|
||||||
d.Memory = flags.Int("vmwarefusion-memory-size")
|
d.Memory = flags.Int("vmwarefusion-memory-size")
|
||||||
d.CPU = flags.Int("vmwarefusion-cpu-count")
|
d.CPU = flags.Int("vmwarefusion-cpu-count")
|
||||||
d.DiskSize = flags.Int("vmwarefusion-disk-size")
|
d.DiskSize = flags.Int("vmwarefusion-disk-size")
|
||||||
|
|
|
@ -21,6 +21,8 @@ import (
|
||||||
"github.com/docker/machine/libmachine/ssh"
|
"github.com/docker/machine/libmachine/ssh"
|
||||||
"github.com/docker/machine/libmachine/state"
|
"github.com/docker/machine/libmachine/state"
|
||||||
|
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/vmware/govmomi"
|
"github.com/vmware/govmomi"
|
||||||
"github.com/vmware/govmomi/find"
|
"github.com/vmware/govmomi/find"
|
||||||
"github.com/vmware/govmomi/guest"
|
"github.com/vmware/govmomi/guest"
|
||||||
|
@ -177,6 +179,9 @@ func (d *Driver) DriverName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
|
if drivers.EngineInstallURLFlagSet(flags) {
|
||||||
|
return errors.New("--engine-install-url cannot be used with the vmwarevsphere driver, use --vmwarevsphere-boot2docker-url instead")
|
||||||
|
}
|
||||||
d.SSHUser = "docker"
|
d.SSHUser = "docker"
|
||||||
d.SSHPort = 22
|
d.SSHPort = 22
|
||||||
d.CPU = flags.Int("vmwarevsphere-cpu-count")
|
d.CPU = flags.Int("vmwarevsphere-cpu-count")
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
const (
|
const (
|
||||||
DefaultSSHUser = "root"
|
DefaultSSHUser = "root"
|
||||||
DefaultSSHPort = 22
|
DefaultSSHPort = 22
|
||||||
|
DefaultEngineInstallURL = "https://get.docker.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BaseDriver - Embed this struct into drivers to provide the common set
|
// 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.SwarmHost = flags.String("swarm-host")
|
||||||
d.SwarmDiscovery = flags.String("swarm-discovery")
|
d.SwarmDiscovery = flags.String("swarm-discovery")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func EngineInstallURLFlagSet(flags DriverOptions) bool {
|
||||||
|
engineInstallURLFlag := flags.String("engine-install-url")
|
||||||
|
return engineInstallURLFlag != DefaultEngineInstallURL && engineInstallURLFlag != ""
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/machine/libmachine/mcnflag"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,3 +27,24 @@ func TestIP(t *testing.T) {
|
||||||
assert.Equal(t, c.expectedErr, err)
|
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))
|
||||||
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ func (api *Client) NewHost(driverName string, rawDriver []byte) (*host.Host, err
|
||||||
ServerKeyPath: filepath.Join(api.GetMachinesDir(), "server-key.pem"),
|
ServerKeyPath: filepath.Join(api.GetMachinesDir(), "server-key.pem"),
|
||||||
},
|
},
|
||||||
EngineOptions: &engine.Options{
|
EngineOptions: &engine.Options{
|
||||||
InstallURL: "https://get.docker.com",
|
InstallURL: drivers.DefaultEngineInstallURL,
|
||||||
StorageDriver: "aufs",
|
StorageDriver: "aufs",
|
||||||
TLSVerify: true,
|
TLSVerify: true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,9 +6,12 @@ only_if_env DRIVER virtualbox
|
||||||
|
|
||||||
use_disposable_machine
|
use_disposable_machine
|
||||||
|
|
||||||
export BAD_URL="http://dev.null:9111/bad.iso"
|
|
||||||
|
|
||||||
@test "$DRIVER: Should not allow machine creation with bad ISO" {
|
@test "$DRIVER: Should not allow machine creation with bad ISO" {
|
||||||
run machine create -d virtualbox --virtualbox-boot2docker-url $BAD_URL $NAME
|
run machine create -d virtualbox --virtualbox-boot2docker-url http://dev.null:9111/bad.iso $NAME
|
||||||
[[ ${status} -eq 1 ]]
|
[[ ${status} -eq 1 ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "$DRIVER: Should not allow machine creation with engine-install-url" {
|
||||||
|
run machine create --engine-install-url https://test.docker.com -d virtualbox $NAME
|
||||||
|
[[ ${output} == *"--engine-install-url cannot be used"* ]]
|
||||||
|
}
|
Loading…
Reference in New Issue