mirror of https://github.com/docker/docs.git
Defaulting SoftLayer hostname to machine name
Signed-off-by: Dave Henderson <Dave.Henderson@ca.ibm.com>
This commit is contained in:
parent
15e022219f
commit
fe4652b21d
|
@ -148,8 +148,8 @@ func GetCreateFlags() []cli.Flag {
|
|||
cli.StringFlag{
|
||||
EnvVar: "SOFTLAYER_HOSTNAME",
|
||||
Name: "softlayer-hostname",
|
||||
Usage: "hostname for the machine",
|
||||
Value: "docker",
|
||||
Usage: "hostname for the machine - defaults to machine name",
|
||||
Value: "",
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "SOFTLAYER_DOMAIN",
|
||||
|
@ -200,9 +200,6 @@ func GetCreateFlags() []cli.Flag {
|
|||
}
|
||||
|
||||
func validateDeviceConfig(c *deviceConfig) error {
|
||||
if c.Hostname == "" {
|
||||
return fmt.Errorf("Missing required setting - --softlayer-hostname")
|
||||
}
|
||||
if c.Domain == "" {
|
||||
return fmt.Errorf("Missing required setting - --softlayer-domain")
|
||||
}
|
||||
|
@ -275,6 +272,11 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
PublicVLAN: flags.Int("softlayer-public-vlan-id"),
|
||||
PrivateVLAN: flags.Int("softlayer-private-vlan-id"),
|
||||
}
|
||||
|
||||
if d.deviceConfig.Hostname == "" {
|
||||
d.deviceConfig.Hostname = d.GetMachineName()
|
||||
}
|
||||
|
||||
return validateDeviceConfig(d.deviceConfig)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -81,10 +83,16 @@ func getTestDriver() (*Driver, error) {
|
|||
}
|
||||
|
||||
func TestSetConfigFromFlagsSetsImage(t *testing.T) {
|
||||
d, _ := getTestDriver()
|
||||
d, err := getTestDriver()
|
||||
|
||||
img := d.deviceConfig.Image
|
||||
if img != "MY_TEST_IMAGE" {
|
||||
t.Fatalf("expected 'MY_TEST_IMAGE'; received %s", img)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, "MY_TEST_IMAGE", d.deviceConfig.Image)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHostnameDefaultsToMachineName(t *testing.T) {
|
||||
d, err := getTestDriver()
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, machineTestName, d.deviceConfig.Hostname)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue