mirror of
https://github.com/docker/docs.git
synced 2026-11-05 00:14:17 +03:00
This work sets the machine name in the Cloud API or Hypervisor. As well as setting the hostname inside the VM. I've added the machine name to the NewDriver func to allow for identification by Cloud APIs and for the driver package. Each driver will attempt to set the hostname for the VM, except for Azure, which sets it based on the DNS name. Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
74 lines
1.4 KiB
Go
74 lines
1.4 KiB
Go
package drivers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/codegangsta/cli"
|
|
)
|
|
|
|
func TestGetCreateFlags(t *testing.T) {
|
|
Register("foo", &RegisteredDriver{
|
|
New: func(machineName string, storePath string) (Driver, error) { return nil, nil },
|
|
GetCreateFlags: func() []cli.Flag {
|
|
return []cli.Flag{
|
|
cli.StringFlag{
|
|
Name: "a",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "b",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "c",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
}
|
|
},
|
|
})
|
|
Register("bar", &RegisteredDriver{
|
|
New: func(machineName string, storePath string) (Driver, error) { return nil, nil },
|
|
GetCreateFlags: func() []cli.Flag {
|
|
return []cli.Flag{
|
|
cli.StringFlag{
|
|
Name: "d",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "e",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "f",
|
|
Value: "",
|
|
Usage: "",
|
|
EnvVar: "",
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|
|
expected := []string{"-a \t", "-b \t", "-c \t", "-d \t", "-e \t", "-f \t"}
|
|
|
|
// test a few times to catch offset issue
|
|
// if it crops up again
|
|
for i := 0; i < 5; i++ {
|
|
flags := GetCreateFlags()
|
|
for j, e := range expected {
|
|
if flags[j].String() != e {
|
|
t.Fatal("Flags are out of order")
|
|
}
|
|
}
|
|
}
|
|
}
|