-
Notifications
You must be signed in to change notification settings - Fork 1
/
do.go
47 lines (41 loc) · 1.05 KB
/
do.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"context"
"fmt"
"github.com/digitalocean/godo"
"github.com/jmcvetta/randutil"
)
func doRegions(client *godo.Client) ([]string, error) {
slugs := []string{}
regions, _, err := client.Regions.List(context.Background(), &godo.ListOptions{})
if err != nil {
return slugs, err
}
for _, r := range regions {
slugs = append(slugs, r.Slug)
}
return slugs, nil
}
func newDropLetMultiCreateRequest(prefix, region, keyID string, count int) *godo.DropletMultiCreateRequest {
names := []string{}
for i := 0; i < count; i++ {
name, _ := randutil.AlphaString(8)
names = append(names, fmt.Sprintf("%s-%s", prefix, name))
}
return &godo.DropletMultiCreateRequest{
Names: names,
Region: region,
Size: "512mb",
Image: godo.DropletCreateImage{
// Slug: "ubuntu-14-04-x64",
// Slug: "ubuntu-20-04-x64", // requires 'snap install nmap'
Slug: "debian-10-x64",
},
SSHKeys: []godo.DropletCreateSSHKey{
{Fingerprint: keyID},
},
Backups: false,
IPv6: false,
PrivateNetworking: false,
}
}