Browse Source

digitalocean_sd: Expose vpc for use in relabelling.

Signed-off-by: Andrew Starr-Bochicchio <a.starr.b@gmail.com>
pull/8642/head
Andrew Starr-Bochicchio 4 years ago
parent
commit
0858657516
  1. 2
      discovery/digitalocean/digitalocean.go
  2. 4
      discovery/digitalocean/digitalocean_test.go
  3. 6
      discovery/digitalocean/mock_test.go

2
discovery/digitalocean/digitalocean.go

@ -47,6 +47,7 @@ const (
doLabelStatus = doLabel + "status" doLabelStatus = doLabel + "status"
doLabelFeatures = doLabel + "features" doLabelFeatures = doLabel + "features"
doLabelTags = doLabel + "tags" doLabelTags = doLabel + "tags"
doLabelVPC = doLabel + "vpc"
separator = "," separator = ","
) )
@ -170,6 +171,7 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
doLabelRegion: model.LabelValue(droplet.Region.Slug), doLabelRegion: model.LabelValue(droplet.Region.Slug),
doLabelSize: model.LabelValue(droplet.SizeSlug), doLabelSize: model.LabelValue(droplet.SizeSlug),
doLabelStatus: model.LabelValue(droplet.Status), doLabelStatus: model.LabelValue(droplet.Status),
doLabelVPC: model.LabelValue(droplet.VPCUUID),
} }
addr := net.JoinHostPort(publicIPv4, strconv.FormatUint(uint64(d.port), 10)) addr := net.JoinHostPort(publicIPv4, strconv.FormatUint(uint64(d.port), 10))

4
discovery/digitalocean/digitalocean_test.go

@ -76,6 +76,7 @@ func TestDigitalOceanSDRefresh(t *testing.T) {
"__meta_digitalocean_region": model.LabelValue("nyc3"), "__meta_digitalocean_region": model.LabelValue("nyc3"),
"__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"), "__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"),
"__meta_digitalocean_status": model.LabelValue("active"), "__meta_digitalocean_status": model.LabelValue("active"),
"__meta_digitalocean_vpc": model.LabelValue("f9b0769c-e118-42fb-a0c4-fed15ef69662"),
"__meta_digitalocean_features": model.LabelValue(",backups,ipv6,virtio,"), "__meta_digitalocean_features": model.LabelValue(",backups,ipv6,virtio,"),
}, },
{ {
@ -90,6 +91,7 @@ func TestDigitalOceanSDRefresh(t *testing.T) {
"__meta_digitalocean_region": model.LabelValue("nyc3"), "__meta_digitalocean_region": model.LabelValue("nyc3"),
"__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"), "__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"),
"__meta_digitalocean_status": model.LabelValue("active"), "__meta_digitalocean_status": model.LabelValue("active"),
"__meta_digitalocean_vpc": model.LabelValue("f9b0769c-e118-42fb-a0c4-fed15ef69662"),
"__meta_digitalocean_tags": model.LabelValue(",monitor,"), "__meta_digitalocean_tags": model.LabelValue(",monitor,"),
"__meta_digitalocean_features": model.LabelValue(",virtio,"), "__meta_digitalocean_features": model.LabelValue(",virtio,"),
}, },
@ -105,6 +107,7 @@ func TestDigitalOceanSDRefresh(t *testing.T) {
"__meta_digitalocean_region": model.LabelValue("fra1"), "__meta_digitalocean_region": model.LabelValue("fra1"),
"__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"), "__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"),
"__meta_digitalocean_status": model.LabelValue("off"), "__meta_digitalocean_status": model.LabelValue("off"),
"__meta_digitalocean_vpc": model.LabelValue("953d698c-dc84-11e8-80bc-3cfdfea9fba1"),
"__meta_digitalocean_features": model.LabelValue(",ipv6,private_networking,"), "__meta_digitalocean_features": model.LabelValue(",ipv6,private_networking,"),
}, },
{ {
@ -119,6 +122,7 @@ func TestDigitalOceanSDRefresh(t *testing.T) {
"__meta_digitalocean_region": model.LabelValue("fra1"), "__meta_digitalocean_region": model.LabelValue("fra1"),
"__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"), "__meta_digitalocean_size": model.LabelValue("s-1vcpu-1gb"),
"__meta_digitalocean_status": model.LabelValue("active"), "__meta_digitalocean_status": model.LabelValue("active"),
"__meta_digitalocean_vpc": model.LabelValue("953d698c-dc84-11e8-80bc-3cfdfea9fba1"),
"__meta_digitalocean_features": model.LabelValue(",ipv6,private_networking,"), "__meta_digitalocean_features": model.LabelValue(",ipv6,private_networking,"),
}, },
} { } {

6
discovery/digitalocean/mock_test.go

@ -445,7 +445,8 @@ func (m *SDMock) HandleDropletsList() {
"m6-24vcpu-192gb" "m6-24vcpu-192gb"
] ]
}, },
"tags": [] "tags": [],
"vpc_uuid": "953d698c-dc84-11e8-80bc-3cfdfea9fba1"
}, },
{ {
"id": 176011507, "id": 176011507,
@ -624,7 +625,8 @@ func (m *SDMock) HandleDropletsList() {
"m6-24vcpu-192gb" "m6-24vcpu-192gb"
] ]
}, },
"tags": [] "tags": [],
"vpc_uuid": "953d698c-dc84-11e8-80bc-3cfdfea9fba1"
} }
], ],
"links": { "links": {

Loading…
Cancel
Save