Skip to content
Permalink
Browse files
Fix a bug in the listAffinityGroup call (#61)
It reports the number of VirtualMachines in the groups as being the number of groups found.
  • Loading branch information
Sander van Harmelen committed Aug 31, 2016
1 parent 6ac2a35 commit b33e8849d135b99cb8236237524d10b41f597cb3
Showing 2 changed files with 20 additions and 0 deletions.
@@ -444,6 +444,10 @@ func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFun
return "", -1, err
}

// This is needed because of a bug with the listAffinityGroup call. It reports the
// number of VirtualMachines in the groups as being the number of groups found.
l.Count = len(l.AffinityGroups)

if l.Count == 0 {
return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
}
@@ -499,6 +503,10 @@ func (s *AffinityGroupService) GetAffinityGroupByID(id string, opts ...OptionFun
return nil, -1, err
}

// This is needed because of a bug with the listAffinityGroup call. It reports the
// number of VirtualMachines in the groups as being the number of groups found.
l.Count = len(l.AffinityGroups)

if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
}
@@ -815,6 +815,12 @@ func (s *service) generateHelperFuncs(a *API) {
pn(" return \"\", -1, err")
pn(" }")
pn("")
if ln == "AffinityGroups" {
pn(" // This is needed because of a bug with the listAffinityGroup call. It reports the")
pn(" // number of VirtualMachines in the groups as being the number of groups found.")
pn(" l.Count = len(l.%s)", ln)
pn("")
}
pn(" if l.Count == 0 {")
pn(" return \"\", l.Count, fmt.Errorf(\"No match found for %%s: %%+v\", %s, l)", v)
pn(" }")
@@ -929,6 +935,12 @@ func (s *service) generateHelperFuncs(a *API) {
pn(" return nil, -1, err")
pn(" }")
pn("")
if ln == "AffinityGroups" {
pn(" // This is needed because of a bug with the listAffinityGroup call. It reports the")
pn(" // number of VirtualMachines in the groups as being the number of groups found.")
pn(" l.Count = len(l.%s)", ln)
pn("")
}
pn(" if l.Count == 0 {")
pn(" return nil, l.Count, fmt.Errorf(\"No match found for %%s: %%+v\", id, l)")
pn(" }")

0 comments on commit b33e884

Please sign in to comment.