exoscale: use StringSlice to specify security groups

This mean that the option has to be repeated to specify multiple
security groups.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
This commit is contained in:
Vincent Bernat
2015-06-06 14:42:03 +02:00
parent 5ba232227e
commit 4ec3f206b4
7 changed files with 26 additions and 5 deletions

View File

@@ -35,6 +35,10 @@ func (d DriverOptionsMock) String(key string) string {
return d.Data[key].(string)
}
func (d DriverOptionsMock) StringSlice(key string) []string {
return d.Data[key].([]string)
}
func (d DriverOptionsMock) Int(key string) int {
return d.Data[key].(int)
}

View File

@@ -164,6 +164,7 @@ func GetDriverNames() []string {
type DriverOptions interface {
String(key string) string
StringSlice(key string) []string
Int(key string) int
Bool(key string) bool
}

View File

@@ -84,10 +84,10 @@ func GetCreateFlags() []cli.Flag {
Value: "ubuntu-14.04",
Usage: "exoscale image template",
},
cli.StringFlag{
cli.StringSliceFlag{
EnvVar: "EXOSCALE_SECURITY_GROUP",
Name: "exoscale-security-group",
Value: "docker-machine",
Value: &cli.StringSlice{},
Usage: "exoscale security group",
},
cli.StringFlag{
@@ -142,8 +142,9 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.InstanceProfile = flags.String("exoscale-instance-profile")
d.DiskSize = flags.Int("exoscale-disk-size")
d.Image = flags.String("exoscale-image")
if flags.String("exoscale-security-group") != "" {
d.SecurityGroups = strings.Split(flags.String("exoscale-security-group"), ",")
d.SecurityGroups = flags.StringSlice("exoscale-security-group")
if len(d.SecurityGroups) == 0 {
d.SecurityGroups = []string{"docker-machine"}
}
d.AvailabilityZone = flags.String("exoscale-availability-zone")
d.SwarmMaster = flags.Bool("swarm-master")

View File

@@ -26,6 +26,13 @@ func (d DriverOptionsMock) String(key string) string {
return ""
}
func (d DriverOptionsMock) StringSlice(key string) []string {
if value, ok := d.Data[key]; ok {
return value.([]string)
}
return []string{}
}
func (d DriverOptionsMock) Int(key string) int {
if value, ok := d.Data[key]; ok {
return value.(int)