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{
|
cli.StringFlag{
|
||||||
EnvVar: "SOFTLAYER_HOSTNAME",
|
EnvVar: "SOFTLAYER_HOSTNAME",
|
||||||
Name: "softlayer-hostname",
|
Name: "softlayer-hostname",
|
||||||
Usage: "hostname for the machine",
|
Usage: "hostname for the machine - defaults to machine name",
|
||||||
Value: "docker",
|
Value: "",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
EnvVar: "SOFTLAYER_DOMAIN",
|
EnvVar: "SOFTLAYER_DOMAIN",
|
||||||
|
@ -200,9 +200,6 @@ func GetCreateFlags() []cli.Flag {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateDeviceConfig(c *deviceConfig) error {
|
func validateDeviceConfig(c *deviceConfig) error {
|
||||||
if c.Hostname == "" {
|
|
||||||
return fmt.Errorf("Missing required setting - --softlayer-hostname")
|
|
||||||
}
|
|
||||||
if c.Domain == "" {
|
if c.Domain == "" {
|
||||||
return fmt.Errorf("Missing required setting - --softlayer-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"),
|
PublicVLAN: flags.Int("softlayer-public-vlan-id"),
|
||||||
PrivateVLAN: flags.Int("softlayer-private-vlan-id"),
|
PrivateVLAN: flags.Int("softlayer-private-vlan-id"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.deviceConfig.Hostname == "" {
|
||||||
|
d.deviceConfig.Hostname = d.GetMachineName()
|
||||||
|
}
|
||||||
|
|
||||||
return validateDeviceConfig(d.deviceConfig)
|
return validateDeviceConfig(d.deviceConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -81,10 +83,16 @@ func getTestDriver() (*Driver, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetConfigFromFlagsSetsImage(t *testing.T) {
|
func TestSetConfigFromFlagsSetsImage(t *testing.T) {
|
||||||
d, _ := getTestDriver()
|
d, err := getTestDriver()
|
||||||
|
|
||||||
img := d.deviceConfig.Image
|
if assert.NoError(t, err) {
|
||||||
if img != "MY_TEST_IMAGE" {
|
assert.Equal(t, "MY_TEST_IMAGE", d.deviceConfig.Image)
|
||||||
t.Fatalf("expected 'MY_TEST_IMAGE'; received %s", img)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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