Skip to content

Commit

Permalink
refactor struts.RequestedDevice to have its own Equals
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin committed Apr 11, 2019
1 parent 49e2e6c commit 6897825
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,34 @@ type RequestedDevice struct {
Affinities []*Affinity
}

func (r *RequestedDevice) Equals(o *RequestedDevice) bool {
if r.Name == o.Name &&
r.Count == o.Count {

// r.Constraints == o.Constraints, order sensitive
if len(r.Constraints) != len(o.Constraints) {
return false
}
for i, c := range r.Constraints {
if !c.Equal(o.Constraints[i]) {
return false
}
}

// r.Affinities == o.Affinities, order sensitive
if len(r.Affinities) != len(o.Affinities) {
return false
}
for i, a := range r.Affinities {
if !a.Equal(o.Affinities[i]) {
return false
}
}
return true
}
return false
}

func (r *RequestedDevice) Copy() *RequestedDevice {
if r == nil {
return nil
Expand Down

0 comments on commit 6897825

Please sign in to comment.