func()

in pkg/cloud_provider/lustre/lustre.go [172:195]


func (sm *lustreServiceManager) ListInstance(ctx context.Context, filter *ListFilter) ([]*ServiceInstance, error) {
	req := &lustrepb.ListInstancesRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", filter.Project, filter.Location),
	}
	var instances []*ServiceInstance
	it := sm.lustreClient.ListInstances(ctx, req)
	for {
		resp, err := it.Next()
		if errors.Is(err, iterator.Done) {
			break
		}
		if err != nil {
			return nil, fmt.Errorf("ListInstances failed for request %v: %w", req, err)
		}
		serviceInstance, err := cloudInstanceToServiceInstance(resp)
		if err != nil {
			return nil, err
		}
		instances = append(instances, serviceInstance)
	}
	klog.Infof("Listed %d instances for project %s in zone %s", len(instances), filter.Project, filter.Location)

	return instances, nil
}