MCPcopy Create free account
hub / github.com/rilldata/rill / ProjectNamesByGitRemote

Method ProjectNamesByGitRemote

cli/pkg/cmdutil/helper.go:332–361  ·  view source on GitHub ↗
(ctx context.Context, org, remote, subPath string)

Source from the content-addressed store, hash-verified

330}
331
332func (h *Helper) ProjectNamesByGitRemote(ctx context.Context, org, remote, subPath string) ([]string, error) {
333 if org == "" || remote == "" {
334 return nil, errors.New("org, remote cannot be blank")
335 }
336
337 c, err := h.Client()
338 if err != nil {
339 return nil, err
340 }
341
342 resp, err := c.ListProjectsForOrganization(ctx, &adminv1.ListProjectsForOrganizationRequest{
343 Org: org,
344 })
345 if err != nil {
346 return nil, err
347 }
348
349 names := make([]string, 0)
350 for _, p := range resp.Projects {
351 if strings.EqualFold(p.GitRemote, remote) && (subPath == "" || strings.EqualFold(p.Subpath, subPath)) {
352 names = append(names, p.Name)
353 }
354 }
355
356 if len(names) == 0 {
357 return nil, fmt.Errorf("no project with Git remote %q exists in the org %q", remote, org)
358 }
359
360 return names, nil
361}
362
363// InferProjectName infers a project name from the given path.
364// If multiple projects are found, it prompts the user to select one (or errors in non-interactive mode).

Callers

nothing calls this directly

Calls 3

ClientMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected