in fast-build-update-tool/internal/gamelift/get_instances.go [139:160]
func (g *GameLiftClient) filterInstances(instances []*Instance, allowedInstanceIds []string) ([]*Instance, error) {
// Nothing to filter, break early
if len(allowedInstanceIds) == 0 {
return instances, nil
}
// Loop through allow list, and add any matches to the result
result := make([]*Instance, 0, len(allowedInstanceIds))
for _, instance := range instances {
for _, allowedInstanceId := range allowedInstanceIds {
if instance.InstanceId == allowedInstanceId {
result = append(result, instance)
}
}
}
if len(result) != len(allowedInstanceIds) {
return result, fmt.Errorf("one or more instance ids not found in fleet: %s", strings.Join(allowedInstanceIds, ","))
}
return result, nil
}