From acc0df9ec6bdd257a7f30b94ab05c599c5623e92 Mon Sep 17 00:00:00 2001 From: Calvin Leung Huang <1883212+calvn@users.noreply.github.com> Date: Tue, 3 Aug 2021 09:31:01 -0700 Subject: [PATCH] serviceregistration: add external-source meta value (#12163) * serviceregistration: add external-source meta value * add changelog file --- changelog/12163.txt | 3 +++ serviceregistration/consul/consul_service_registration.go | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 changelog/12163.txt diff --git a/changelog/12163.txt b/changelog/12163.txt new file mode 100644 index 0000000000000..10af9d03849d7 --- /dev/null +++ b/changelog/12163.txt @@ -0,0 +1,3 @@ +```release-note:improvement +serviceregistration: add `external-source: "vault"` metadata value for Consul registration. +``` \ No newline at end of file diff --git a/serviceregistration/consul/consul_service_registration.go b/serviceregistration/consul/consul_service_registration.go index cd71515db19d9..096e2936a43bb 100644 --- a/serviceregistration/consul/consul_service_registration.go +++ b/serviceregistration/consul/consul_service_registration.go @@ -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])$`) @@ -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