Skip to content

Commit ee1015f

Browse files
authored
Add security groups support
1 parent 5fb0e3c commit ee1015f

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ $ docker-machine create \
3939
| ``--yandex-platform-id`` or ``$YC_PLATFORM_ID`` | ID of the hardware platform configuration | standard-v1 |
4040
| ``--yandex-preemptible`` or ``$YC_PREEMPTIBLE`` | Yandex.Cloud Instance preemptibility flag | false |
4141
| ``--yandex-sa-key-file`` or ``$YC_SA_KEY_FILE`` | Yandex.Cloud Service Account key file | |
42+
| ``--yandex-security-groups`` or ``$YC_SECURITY_GROUPS`` | Set security groups | |
4243
| ``--yandex-ssh-port`` or ``$YC_SSH_PORT`` | SSH port | 22 |
4344
| ``--yandex-ssh-user`` or ``$YC_SSH_USER`` | SSH username | yc-user |
45+
| ``--yandex-static-address`` or ``$YC_STATIC_ADDRESS`` | Set public static IPv4 address | |
4446
| ``--yandex-subnet-id`` or ``$YC_SUBNET_ID`` | Subnet ID | |
4547
| ``--yandex-token`` or ``$YC_TOKEN`` | Yandex.Cloud OAuth token or IAM token | |
4648
| ``--yandex-use-internal-ip`` or ``$YC_USE_INTERNAL_IP`` | Use the internal Instance IP to communicate | false |
4749
| ``--yandex-userdata`` or ``$YC_USERDATA`` | Path to file with cloud-init user-data | |
4850
| ``--yandex-zone`` or ``$YC_ZONE`` | Yandex.Cloud zone | ru-central1-a |
49-
| ``--yandex-static-address`` or ``$YC_STATIC_ADDRESS`` | Set public static IPv4 address | |
5051
---

driver/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func prepareInstanceCreateRequest(d *Driver, imageID string) *compute.CreateInst
112112
{
113113
SubnetId: d.SubnetID,
114114
PrimaryV4AddressSpec: &compute.PrimaryAddressSpec{},
115+
SecurityGroupIds: d.SecurityGroups,
115116
},
116117
},
117118
SchedulingPolicy: &compute.SchedulingPolicy{

driver/driver.go

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,30 @@ type Driver struct {
2828
ServiceAccountKeyFile string
2929
Token string
3030

31-
CloudID string
32-
Cores int
33-
CoreFraction int
34-
DiskSize int
35-
DiskType string
36-
FolderID string
37-
ImageFamily string
38-
ImageFolderID string
39-
ImageID string
40-
InstanceID string
41-
Labels []string
42-
Memory int
43-
Metadata map[string]string
44-
Nat bool
45-
PlatformID string
46-
Preemptible bool
47-
SSHUser string
48-
SubnetID string
49-
UseIPv6 bool
50-
UseInternalIP bool
51-
UserDataFile string
52-
Zone string
53-
StaticAddress string
31+
CloudID string
32+
Cores int
33+
CoreFraction int
34+
DiskSize int
35+
DiskType string
36+
FolderID string
37+
ImageFamily string
38+
ImageFolderID string
39+
ImageID string
40+
InstanceID string
41+
Labels []string
42+
Memory int
43+
Metadata map[string]string
44+
Nat bool
45+
PlatformID string
46+
Preemptible bool
47+
SSHUser string
48+
SubnetID string
49+
UseIPv6 bool
50+
UseInternalIP bool
51+
UserDataFile string
52+
Zone string
53+
StaticAddress string
54+
SecurityGroups []string
5455
}
5556

5657
const (
@@ -223,6 +224,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
223224
Usage: "Set static address",
224225
Value: "",
225226
},
227+
mcnflag.StringSliceFlag{
228+
EnvVar: "YC_SECURITY_GROUPS",
229+
Name: "yandex-security-groups",
230+
Usage: "Set security groups",
231+
},
226232
}
227233
}
228234

@@ -260,6 +266,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
260266
d.UserDataFile = flags.String("yandex-userdata")
261267
d.Zone = flags.String("yandex-zone")
262268
d.StaticAddress = flags.String("yandex-static-address")
269+
d.SecurityGroups = flags.StringSlice("yandex-security-groups")
263270

264271
return nil
265272
}

0 commit comments

Comments
 (0)