Merge pull request #8642 from andrewsomething/do-sd-vpc

digitalocean_sd: Expose vpc for use in relabeling.
This commit is contained in:
Julien Pivotto 2021-03-24 23:19:41 +01:00 committed by GitHub
commit 9dceeea5e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View file

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

View file

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

View file

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

View file

@ -444,6 +444,7 @@ The following meta labels are available on targets during [relabeling](#relabel_
* `__meta_digitalocean_status`: the status of the droplet
* `__meta_digitalocean_features`: the comma-separated list of features of the droplet
* `__meta_digitalocean_tags`: the comma-separated list of tags of the droplet
* `__meta_digitalocean_vpc`: the id of the droplet's VPC
```yaml
# Authentication information used to authenticate to the API server.