max index for any resource, if context is unspecified

This commit is contained in:
Chelsea Holland Komlo 2017-08-07 15:07:18 +00:00
parent f110fa5c0d
commit cd0698a87b
1 changed files with 9 additions and 12 deletions

View File

@ -114,19 +114,16 @@ func (r *Resources) List(args *structs.ResourceListRequest,
}
// Set the index for the context. If the context has been specified, it
// is the only non-empty match set, and the index is set for it.
// If the context was not specified, we set the index to be the max index
// from available matches.
// will be used as the index of the response. Otherwise, the
// maximum index from all resources will be used.
reply.Index = 0
for k, v := range reply.Matches {
if len(v) != 0 { // make sure matches exist for this context
index, err := state.Index(k)
if err != nil {
return err
}
if index > reply.Index {
reply.Index = index
}
for _, e := range contexts {
index, err := state.Index(e)
if err != nil {
return err
}
if index > reply.Index {
reply.Index = index
}
}