b9009c419c
This change removes the addition of the advertise address to the exported task env vars and instead moves this work into the NomadFingerprint.Fingerprint which adds this value to the client attrs. This can then be used within a Nomad job like ${attr.nomad.advertise.address}.
28 lines
760 B
Go
28 lines
760 B
Go
package fingerprint
|
|
|
|
import (
|
|
"log"
|
|
|
|
cstructs "github.com/hashicorp/nomad/client/structs"
|
|
)
|
|
|
|
// NomadFingerprint is used to fingerprint the Nomad version
|
|
type NomadFingerprint struct {
|
|
StaticFingerprinter
|
|
logger *log.Logger
|
|
}
|
|
|
|
// NewNomadFingerprint is used to create a Nomad fingerprint
|
|
func NewNomadFingerprint(logger *log.Logger) Fingerprint {
|
|
f := &NomadFingerprint{logger: logger}
|
|
return f
|
|
}
|
|
|
|
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.revision", req.Config.Version.Revision)
|
|
resp.Detected = true
|
|
return nil
|
|
}
|