github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/nomad/structs/node.go (about) 1 package structs 2 3 import ( 4 "time" 5 6 "github.com/hashicorp/nomad/helper" 7 ) 8 9 // DriverInfo is the current state of a single driver. This is updated 10 // regularly as driver health changes on the node. 11 type DriverInfo struct { 12 Attributes map[string]string 13 Detected bool 14 Healthy bool 15 HealthDescription string 16 UpdateTime time.Time 17 } 18 19 func (di *DriverInfo) Copy() *DriverInfo { 20 if di == nil { 21 return nil 22 } 23 24 cdi := new(DriverInfo) 25 *cdi = *di 26 cdi.Attributes = helper.CopyMapStringString(di.Attributes) 27 return cdi 28 } 29 30 // MergeHealthCheck merges information from a health check for a drier into a 31 // node's driver info 32 func (di *DriverInfo) MergeHealthCheck(other *DriverInfo) { 33 di.Healthy = other.Healthy 34 di.HealthDescription = other.HealthDescription 35 di.UpdateTime = other.UpdateTime 36 } 37 38 // MergeFingerprint merges information from fingerprinting a node for a driver 39 // into a node's driver info for that driver. 40 func (di *DriverInfo) MergeFingerprintInfo(other *DriverInfo) { 41 di.Detected = other.Detected 42 di.Attributes = other.Attributes 43 } 44 45 // DriverInfo determines if two driver info objects are equal..As this is used 46 // in the process of health checking, we only check the fields that are 47 // computed by the health checker. In the future, this will be merged. 48 func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool { 49 if di == nil && other == nil { 50 return true 51 } 52 53 if di.Healthy != other.Healthy { 54 return false 55 } 56 57 if di.HealthDescription != other.HealthDescription { 58 return false 59 } 60 61 return true 62 }