Add monitoring flag for Digital Ocean droplets

Digital Ocean now has the functionality for more extensive monitoring of droplets, which includes the ability to set alerts for droplets. These new features only work if a monitoring script is run on the droplet upon startup, fortunately the Digital Ocean API allows for a flag to be passed through (similar to how `private networking` is switched on) that pre-installs the monitoring script allowing the more in-depth monitoring. I have simply added this flag to `docker-machine`.

Signed-off-by: Steven Cooney <dev@stevenjamescooney.com>
This commit is contained in:
Steven Cooney
2018-02-02 20:39:23 +00:00
parent d9615a5111
commit cee1891753

View File

@@ -35,6 +35,7 @@ type Driver struct {
Backups bool
PrivateNetworking bool
UserDataFile string
Monitoring bool
Tags string
}
@@ -115,6 +116,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: "digitalocean-userdata",
Usage: "path to file with cloud-init user-data",
},
mcnflag.BoolFlag{
EnvVar: "DIGITALOCEAN_MONITORING",
Name: "digitalocean-monitoring",
Usage: "enable monitoring for droplet",
},
mcnflag.StringFlag{
EnvVar: "DIGITALOCEAN_TAGS",
Name: "digitalocean-tags",
@@ -157,6 +163,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHPort = flags.Int("digitalocean-ssh-port")
d.SSHKeyFingerprint = flags.String("digitalocean-ssh-key-fingerprint")
d.SSHKey = flags.String("digitalocean-ssh-key-path")
d.Monitoring = flags.Bool("digitalocean-monitoring")
d.Tags = flags.String("digitalocean-tags")
d.SetSwarmConfigFromFlags(flags)
@@ -232,6 +239,7 @@ func (d *Driver) Create() error {
Backups: d.Backups,
UserData: userdata,
SSHKeys: []godo.DropletCreateSSHKey{{ID: d.SSHKeyID}},
Monitoring: d.Monitoring,
Tags: d.getTags(),
}