Skip to content

Commit 02e4504

Browse files
WolfegGennadySpb
andauthored
added service account inside vm (#17)
* added service account inside vm * Update yandex-sa-id usage text Co-authored-by: GennadySpb <lipenkov@gmail.com> * added yandex-sa-id to readme Co-authored-by: GennadySpb <lipenkov@gmail.com>
1 parent 7666ace commit 02e4504

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ $ docker-machine create \
4949
- `--yandex-platform-id`: ID of the hardware platform configuration
5050
- `--yandex-preemptible`: Yandex.Cloud Instance preemptibility flag
5151
- `--yandex-sa-key-file`: Yandex.Cloud Service Account key file
52+
- `--yandex-sa-id`: Service account ID to attach to the instance
5253
- `--yandex-security-groups`: Set security groups
5354
- `--yandex-ssh-port`: SSH port
5455
- `--yandex-ssh-user`: SSH username
@@ -79,6 +80,7 @@ $ docker-machine create \
7980
| `--yandex-platform-id` | YC_PLATFORM_ID | standard-v1 |
8081
| `--yandex-preemptible` | YC_PREEMPTIBLE | false |
8182
| `--yandex-sa-key-file` | YC_SA_KEY_FILE | |
83+
| `--yandex-sa-id` | YC_SA_ID | |
8284
| `--yandex-security-groups` | YC_SECURITY_GROUPS | |
8385
| `--yandex-ssh-port` | YC_SSH_PORT | 22 |
8486
| `--yandex-ssh-user` | YC_SSH_USER | yc-user |

driver/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ func prepareInstanceCreateRequest(d *Driver, imageID string) *compute.CreateInst
118118
SchedulingPolicy: &compute.SchedulingPolicy{
119119
Preemptible: d.Preemptible,
120120
},
121-
Metadata: d.Metadata,
121+
ServiceAccountId: d.ServiceAccountID,
122+
Metadata: d.Metadata,
122123
}
123124

124125
if d.Nat {

driver/driver.go

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,31 @@ 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
54-
SecurityGroups []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
55+
ServiceAccountID string
5556
}
5657

5758
const (
@@ -229,6 +230,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
229230
Name: "yandex-security-groups",
230231
Usage: "Set security groups",
231232
},
233+
mcnflag.StringFlag{
234+
EnvVar: "YC_SA_ID",
235+
Name: "yandex-sa-id",
236+
Usage: "Service account ID to attach to the instance",
237+
},
232238
}
233239
}
234240

@@ -267,6 +273,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
267273
d.Zone = flags.String("yandex-zone")
268274
d.StaticAddress = flags.String("yandex-static-address")
269275
d.SecurityGroups = flags.StringSlice("yandex-security-groups")
276+
d.ServiceAccountID = flags.String("yandex-sa-id")
270277

271278
return nil
272279
}

0 commit comments

Comments
 (0)