Merge pull request #4390 from jrasell/f_gh_4381

Add 'nomad.advertise.address' to client meta via NomadFingerPrint
This commit is contained in:
Preetha 2018-06-20 15:58:09 -05:00 committed by GitHub
commit 77cbbf7111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -19,6 +19,7 @@ func NewNomadFingerprint(logger *log.Logger) Fingerprint {
} }
func (f *NomadFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error { func (f *NomadFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
resp.AddAttribute("nomad.advertise.address", req.Node.HTTPAddr)
resp.AddAttribute("nomad.version", req.Config.Version.VersionNumber()) resp.AddAttribute("nomad.version", req.Config.Version.VersionNumber())
resp.AddAttribute("nomad.revision", req.Config.Version.Revision) resp.AddAttribute("nomad.revision", req.Config.Version.Revision)
resp.Detected = true resp.Detected = true

View File

@ -12,17 +12,20 @@ import (
func TestNomadFingerprint(t *testing.T) { func TestNomadFingerprint(t *testing.T) {
f := NewNomadFingerprint(testlog.Logger(t)) f := NewNomadFingerprint(testlog.Logger(t))
node := &structs.Node{
Attributes: make(map[string]string),
}
v := "foo" v := "foo"
r := "123" r := "123"
h := "8.8.8.8:4646"
c := &config.Config{ c := &config.Config{
Version: &version.VersionInfo{ Version: &version.VersionInfo{
Revision: r, Revision: r,
Version: v, Version: v,
}, },
} }
node := &structs.Node{
Attributes: make(map[string]string),
HTTPAddr: h,
}
request := &cstructs.FingerprintRequest{Config: c, Node: node} request := &cstructs.FingerprintRequest{Config: c, Node: node}
var response cstructs.FingerprintResponse var response cstructs.FingerprintResponse
@ -46,4 +49,8 @@ func TestNomadFingerprint(t *testing.T) {
if response.Attributes["nomad.revision"] != r { if response.Attributes["nomad.revision"] != r {
t.Fatalf("incorrect revision") t.Fatalf("incorrect revision")
} }
if response.Attributes["nomad.advertise.address"] != h {
t.Fatalf("incorrect advertise address")
}
} }