func (do *DigitalOcean) CreateDroplets(ctx context.Context, region, size, vpc string, count int) ([]CreatedResponse, error) {
	var (
		ipv6              = true
		tags              = []string{tagName, workerTagName}
		monitoring        = true
		privateNetworking = true
	)
	var names []string
	for i := 0; i < count; i++ {
		names = append(names, workerTagName)
	}
	createRequest := &godo.DropletMultiCreateRequest{
		Names:  names,
		Region: region,
		Size:   size,
		Image: godo.DropletCreateImage{
			Slug: dockerImageName,
		},
		UserData:          createUserData(),
		Tags:              tags,
		Monitoring:        monitoring,
		IPv6:              ipv6,
		PrivateNetworking: privateNetworking,
		VPCUUID:           vpc,
	}
	droplets, _, err := do.client.Droplets.CreateMultiple(ctx, createRequest)
	if err != nil {
		return nil, err
	}
	list := []CreatedResponse{}
	for _, d := range droplets {
		list = append(list, CreatedResponse{
			ID:       d.ID,
			Provider: digitalOceanProviderName,
		})
	}
	return list, nil
}
CreateDroplets creates a new DigitalOcean droplet.
package machine
import (
	"context"
	"github.com/digitalocean/godo"
	"golang.org/x/oauth2"
)
type TokenSource struct {
	AccessToken string
}
func (t *TokenSource) Token() (*oauth2.Token, error) {
	token := &oauth2.Token{
		AccessToken: t.AccessToken,
	}
	return token, nil
}
type DigitalOcean struct {
	client *godo.Client
}
func NewDigitalOceanClient(token string) (*DigitalOcean, error) {
	tokenSource := &TokenSource{
		AccessToken: token,
	}
	oauthClient := oauth2.NewClient(context.Background(), tokenSource)
	client := godo.NewClient(oauthClient)
	return &DigitalOcean{
		client: client,
	}, nil
}
func (do *DigitalOcean) ListDropletByTag(ctx context.Context, tag string) ([]Machine, error) {
	list := []Machine{}
	opt := &godo.ListOptions{}
	for {
		droplets, resp, err := do.client.Droplets.ListByTag(ctx, tag, opt)
		if err != nil {
			return nil, err
		}
		for _, d := range droplets {
			list = append(list, Machine{
				ID:       d.ID,
				Name:     d.Name,
				Status:   d.Status,
				SizeSlug: d.SizeSlug,
				Created:  d.Created,
				Region:   d.Region.Name,
				Tags:     d.Tags,
				Provider: digitalOceanProviderName,
			})
		}
		if resp.Links == nil || resp.Links.IsLastPage() {
			break
		}
		page, err := resp.Links.CurrentPage()
		if err != nil {
			return nil, err
		}
		opt.Page = page + 1
	}
	return list, nil
}