func()

in fast-build-update-tool/internal/gamelift/get_instances.go [63:92]


func (g *GameLiftClient) getLocations(ctx context.Context, fleetId string, locations []string, nextToken *string) ([]string, error) {
	locationAttributesOutput, err := g.gamelift.DescribeFleetLocationAttributes(ctx, &gamelift.DescribeFleetLocationAttributesInput{
		FleetId:   aws.String(fleetId),
		NextToken: nextToken,
	})

	// If the fleet does not have multi-location support, return an empty slice
	var unsupportedRegion *types.UnsupportedRegionException
	if errors.As(err, &unsupportedRegion) {
		return []string{}, nil
	}

	if err != nil {
		return locations, fmt.Errorf("error checking locations for fleet: %w", err)
	}

	for _, locationAttributes := range locationAttributesOutput.LocationAttributes {
		// Filter out anything that is not active
		if strings.EqualFold(string(locationAttributes.LocationState.Status), string(types.FleetStatusActive)) {
			locations = append(locations, *locationAttributes.LocationState.Location)
		}
	}

	// If the results are paginated, fetch the next page
	if locationAttributesOutput.NextToken != nil {
		return g.getLocations(ctx, fleetId, locations, locationAttributesOutput.NextToken)
	}

	return locations, nil
}