Add FetchReservations to GCE Autoscaling client
This commit is contained in:
parent
ad86bdd641
commit
b6c887c8b7
|
|
@ -77,6 +77,7 @@ type AutoscalingGceClient interface {
|
|||
FetchMigsWithName(zone string, filter *regexp.Regexp) ([]string, error)
|
||||
FetchZones(region string) ([]string, error)
|
||||
FetchAvailableCpuPlatforms() (map[string][]string, error)
|
||||
FetchReservations() ([]*gce.Reservation, error)
|
||||
|
||||
// modifying resources
|
||||
ResizeMig(GceRef, int64) error
|
||||
|
|
@ -508,3 +509,15 @@ func (client *autoscalingGceClientV1) FetchMigsWithName(zone string, name *regex
|
|||
}
|
||||
return links, nil
|
||||
}
|
||||
|
||||
func (client *autoscalingGceClientV1) FetchReservations() ([]*gce.Reservation, error) {
|
||||
reservations := make([]*gce.Reservation, 0)
|
||||
call := client.gceService.Reservations.AggregatedList(client.projectId)
|
||||
err := call.Pages(context.TODO(), func(ls *gce.ReservationAggregatedList) error {
|
||||
for _, items := range ls.Items {
|
||||
reservations = append(reservations, items.Reservations...)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return reservations, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,10 @@ func (client *mockAutoscalingGceClient) FetchAvailableCpuPlatforms() (map[string
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (client *mockAutoscalingGceClient) FetchReservations() ([]*gce.Reservation, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (client *mockAutoscalingGceClient) ResizeMig(_ GceRef, _ int64) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue