Skip to content

Commit

Permalink
serviceregistration: add external-source meta value (#12163)
Browse files Browse the repository at this point in the history
* serviceregistration: add external-source meta value

* add changelog file
  • Loading branch information
calvn committed Aug 3, 2021
1 parent 7f2cfd0 commit acc0df9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/12163.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
serviceregistration: add `external-source: "vault"` metadata value for Consul registration.
```
7 changes: 7 additions & 0 deletions serviceregistration/consul/consul_service_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const (
// reconcileTimeout is how often Vault should query Consul to detect
// and fix any state drift.
reconcileTimeout = 60 * time.Second

// metaExternalSource is a metadata value for external-source that can be
// used by the Consul UI.
metaExternalSource = "vault"
)

var hostnameRegex = regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`)
Expand Down Expand Up @@ -503,6 +507,9 @@ func (c *serviceRegistration) reconcileConsul(registeredServiceID string) (servi
Port: int(c.redirectPort),
Address: serviceAddress,
EnableTagOverride: false,
Meta: map[string]string{
"external-source": metaExternalSource,
},
}

checkStatus := api.HealthCritical
Expand Down

0 comments on commit acc0df9

Please sign in to comment.