Merge pull request #4390 from jrasell/f_gh_4381
Add 'nomad.advertise.address' to client meta via NomadFingerPrint
This commit is contained in:
commit
77cbbf7111
|
@ -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
|
||||||
|
|
|
@ -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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue