github.com/smithx10/nomad@v0.9.1-rc1/client/fingerprint/structs.go (about) 1 package fingerprint 2 3 import ( 4 "github.com/hashicorp/nomad/client/config" 5 "github.com/hashicorp/nomad/nomad/structs" 6 ) 7 8 // FingerprintRequest is a request which a fingerprinter accepts to fingerprint 9 // the node 10 type FingerprintRequest struct { 11 Config *config.Config 12 Node *structs.Node 13 } 14 15 // FingerprintResponse is the response which a fingerprinter annotates with the 16 // results of the fingerprint method 17 type FingerprintResponse struct { 18 Attributes map[string]string 19 Links map[string]string 20 Resources *structs.Resources // COMPAT(0.10): Remove in 0.10 21 NodeResources *structs.NodeResources 22 23 // Detected is a boolean indicating whether the fingerprinter detected 24 // if the resource was available 25 Detected bool 26 } 27 28 // AddAttribute adds the name and value for a node attribute to the fingerprint 29 // response 30 func (f *FingerprintResponse) AddAttribute(name, value string) { 31 // initialize Attributes if it has not been already 32 if f.Attributes == nil { 33 f.Attributes = make(map[string]string, 0) 34 } 35 36 f.Attributes[name] = value 37 } 38 39 // RemoveAttribute sets the given attribute to empty, which will later remove 40 // it entirely from the node 41 func (f *FingerprintResponse) RemoveAttribute(name string) { 42 // initialize Attributes if it has not been already 43 if f.Attributes == nil { 44 f.Attributes = make(map[string]string, 0) 45 } 46 47 f.Attributes[name] = "" 48 } 49 50 // AddLink adds a link entry to the fingerprint response 51 func (f *FingerprintResponse) AddLink(name, value string) { 52 // initialize Links if it has not been already 53 if f.Links == nil { 54 f.Links = make(map[string]string, 0) 55 } 56 57 f.Links[name] = value 58 } 59 60 // RemoveLink removes a link entry from the fingerprint response. This will 61 // later remove it entirely from the node 62 func (f *FingerprintResponse) RemoveLink(name string) { 63 // initialize Links if it has not been already 64 if f.Links == nil { 65 f.Links = make(map[string]string, 0) 66 } 67 68 f.Links[name] = "" 69 }