// Returns a list, or partial list, of repositories in the registry.
// Because it's a quite expensive operation, it should only be used when building up
// an initial set of repositories.
183731
func (reg *registry) Repositories(ctx context.Context, repos []string, last string) (n int, err error) {
	var finishedWalk bool
	var foundRepos []string

	if len(repos) == 0 {
		return 0, errors.New("no space in slice")
	}

	root, err := pathFor(repositoriesRootPathSpec{})
	if err != nil {
		return 0, err
	}

	err = reg.blobStore.driver.Walk(ctx, root, func(fileInfo driver.FileInfo) error {
		err := handleRepository(fileInfo, root, last, func(repoPath string) error {
			foundRepos = append(foundRepos, repoPath)
			return nil
		})
		if err != nil {
			return err
		}

		// if we've filled our array, no need to walk any further
		if len(foundRepos) == len(repos) {
			finishedWalk = true
			return driver.ErrSkipDir
		}

		return nil
	})

	n = copy(repos, foundRepos)

	if err != nil {
		return n, err
	} else if !finishedWalk {
		// We didn't fill buffer. No more records are available.
		return n, io.EOF
	}

	return n, err
}
589217
func (c *Manager) GetLibraries(ctx context.Context) ([]Library, error) {
	ids, err := c.ListLibraries(ctx)
	if err != nil {
		return nil, fmt.Errorf("get libraries failed for: %s", err)
	}

	var libraries []Library
	for _, id := range ids {
		library, err := c.GetLibraryByID(ctx, id)
		if err != nil {
			return nil, fmt.Errorf("get library %s failed for %s", id, err)
		}

		libraries = append(libraries, *library)

	}
	return libraries, nil
}
1160496
func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo string, opt *ListCollaboratorsOptions) ([]*User, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo)
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	req.Header.Set("Accept", mediaTypeNestedTeamsPreview)

	var users []*User
	resp, err := s.client.Do(ctx, req, &users)
	if err != nil {
		return nil, resp, err
	}

	return users, resp, nil
}
784326
func (s *RepositoriesService) ListPagesBuilds(ctx context.Context, owner, repo string, opt *ListOptions) ([]*PagesBuild, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo)
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var pages []*PagesBuild
	resp, err := s.client.Do(ctx, req, &pages)
	if err != nil {
		return nil, resp, err
	}

	return pages, resp, nil
}
1034457
func (md *MDServerDisk) GetKeyBundles(ctx context.Context,
	tlfID tlf.ID, wkbID kbfsmd.TLFWriterKeyBundleID, rkbID kbfsmd.TLFReaderKeyBundleID) (
	*kbfsmd.TLFWriterKeyBundleV3, *kbfsmd.TLFReaderKeyBundleV3, error) {
	if err := checkContext(ctx); err != nil {
		return nil, nil, err
	}

	tlfStorage, err := md.getStorage(tlfID)
	if err != nil {
		return nil, nil, err
	}

	return tlfStorage.getKeyBundles(tlfID, wkbID, rkbID)
}
258292
func (client Client) GetRepositories() (map[int]Repository, error) {
	start := 0
	repositories := make(map[int]Repository)
	morePages := true
	for morePages {
		retry := retry.New(3, retry.DefaultBackoffFunc)
		var data []byte
		work := func() error {
			req, err := http.NewRequest("GET", fmt.Sprintf("%s/rest/api/1.0/repos?start=%d&limit=%d", client.baseURL.String(), start, stashPageLimit), nil)
			if err != nil {
				return err
			}
			req.Header.Set("Accept", "application/json")
			// use credentials if we have them.  If not, the repository must be public.
			if client.userName != "" && client.password != "" {
				req.SetBasicAuth(client.userName, client.password)
			}

			var responseCode int
			responseCode, data, err = client.consumeResponse(req)
			if err != nil {
				return err
			}
			if responseCode != http.StatusOK {
				reason := "unhandled reason"
				switch {
				case responseCode == http.StatusBadRequest:
					reason = "Bad request."
				}
				return errorResponse{StatusCode: responseCode, Reason: reason}
			}
			return nil
		}
		if err := retry.Try(work); err != nil {
			return nil, err
		}

		var r Repositories
		err := json.Unmarshal(data, &r)
		if err != nil {
			return nil, err
		}
		for _, repo := range r.Repository {
			repositories[repo.ID] = repo
		}
		morePages = !r.IsLastPage
		start = r.NextPageStart
	}
	return repositories, nil
}
1237397
func (u *User) GetRepositories(page, pageSize int) (err error) {
	u.Repos, err = GetUserRepositories(&UserRepoOptions{
		UserID:   u.ID,
		Private:  true,
		Page:     page,
		PageSize: pageSize,
	})
	return err
}
1176602
func (c Client) ListResources(charms []CharmID) ([][]resource.Resource, error) {
	results := make([][]resource.Resource, len(charms))
	for i, ch := range charms {
		res, err := c.listResources(ch)
		if err != nil {
			if csclient.IsAuthorizationError(err) || errors.Cause(err) == csparams.ErrNotFound {
				// Ignore authorization errors and not-found errors so we get some results
				// even if others fail.
				continue
			}
			return nil, errors.Trace(err)
		}
		results[i] = res
	}
	return results, nil
}
23299
func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error) {
	entities, err := r.ReadWriteRepo.FindAll(ctx)
	if err != nil {
		return nil, err
	}

	// Cache all items.
	ns := r.namespace(ctx)
	r.cacheMu.Lock()
	for _, entity := range entities {
		r.cache[ns][entity.EntityID()] = entity
	}
	r.cacheMu.Unlock()

	return entities, nil
}
684512
func (r *prefixedRegistrar) FindAll() []*RegisteredEntity {
	res := []*RegisteredEntity{}
	for _, re := range r.typeIndex {
		res = append(res, re)
	}
	return res
}
569415
func (ds *resourcesUnitDataStore) ListResources() (resource.ApplicationResources, error) {
	return ds.resources.ListResources(ds.unit.ApplicationName())
}
416066
func (s *RepositoriesService) ListTrafficPaths(ctx context.Context, owner, repo string) ([]*TrafficPath, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/traffic/popular/paths", owner, repo)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var paths []*TrafficPath
	resp, err := s.client.Do(ctx, req, &paths)
	if err != nil {
		return nil, resp, err
	}

	return paths, resp, nil
}
158408
func (s *SearchService) Repositories(ctx context.Context, query string, opt *SearchOptions) (*RepositoriesSearchResult, *Response, error) {
	result := new(RepositoriesSearchResult)
	resp, err := s.search(ctx, "repositories", &searchParameters{Query: query}, opt, result)
	return result, resp, err
}
80557
func GetUserRepositories(opts *UserRepoOptions) ([]*Repository, error) {
	sess := x.Where("owner_id=?", opts.UserID).Desc("updated_unix")
	if !opts.Private {
		sess.And("is_private=?", false)
	}

	if opts.Page <= 0 {
		opts.Page = 1
	}
	sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)

	repos := make([]*Repository, 0, opts.PageSize)
	return repos, sess.Find(&repos)
}
18882
func (config *Config) PluginRepositories() []PluginRepository {
	repos := config.ConfigFile.PluginRepositories
	sort.Slice(repos, func(i, j int) bool {
		return strings.ToLower(repos[i].Name) < strings.ToLower(repos[j].Name)
	})
	return repos
}
238469
func (e *DockerRegistryServiceController) getDockerRegistryLocations() []string {
	ret := append([]string{}, e.additionalRegistryURLs...)
	for _, location := range serviceLocations {
		ret = append(ret, getDockerRegistryLocations(e.serviceLister, location, e.clusterDNSSuffix)...)
	}
	klog.V(4).Infof("found docker registry urls: %v", ret)
	return ret
}
1248216
func (r *RepoKeyResource) List(owner, slug string) ([]*Key, error) {
	keys := []*Key{}
	path := fmt.Sprintf("/repositories/%s/%s/deploy-keys", owner, slug)

	if err := r.client.do("GET", path, nil, nil, &keys); err != nil {
		return nil, err
	}

	return keys, nil
}