func()

in fast-build-update-tool/internal/gamelift/get_instances.go [32:61]


func (g *GameLiftClient) GetInstances(ctx context.Context, fleetId string, allowedInstanceIds []string) ([]*Instance, error) {
	// First we need to fetch locations, as there may be instances outside of the home region
	locations, err := g.getLocations(ctx, fleetId, make([]string, 0, 1), nil)
	if err != nil {
		return make([]*Instance, 0), err
	}

	// Fetch each instance in each location and add it to results
	result := make([]*Instance, 0, 1)

	if len(locations) > 0 {
		// If locations were returned, fetch an instance in each location
		for _, location := range locations {
			result, err = g.getInstancesInternal(ctx, fleetId, location, result, nil)
			if err != nil {
				return make([]*Instance, 0), err
			}
		}

	} else {
		// If no locations were returned (no multi-location support), search for instances in the fleet without the location parameter
		result, err = g.getInstancesInternal(ctx, fleetId, "", result, nil)
		if err != nil {
			return make([]*Instance, 0), err
		}
	}

	// Return the filtered slice of any instances we found
	return g.filterInstances(result, allowedInstanceIds)
}