MCPcopy Create free account
hub / github.com/Facets-cloud/flow / ResolveProject

Function ResolveProject

internal/app/resolve.go:37–54  ·  view source on GitHub ↗

ResolveProject resolves a ref to exactly one project by slug.

(db *sql.DB, ref string, includeArchived bool)

Source from the content-addressed store, hash-verified

35
36// ResolveProject resolves a ref to exactly one project by slug.
37func ResolveProject(db *sql.DB, ref string, includeArchived bool) (*flowdb.Project, error) {
38 ref = strings.TrimSpace(ref)
39 if ref == "" {
40 return nil, fmt.Errorf("empty project ref")
41 }
42
43 p, err := flowdb.GetProject(db, ref)
44 if err != nil {
45 if errors.Is(err, sql.ErrNoRows) {
46 return nil, fmt.Errorf("no project matching %q", ref)
47 }
48 return nil, err
49 }
50 if !includeArchived && p.ArchivedAt.Valid {
51 return nil, fmt.Errorf("project %q is archived", ref)
52 }
53 return p, nil
54}
55
56// ResolvePlaybook resolves a ref to exactly one playbook by slug.
57// includeArchived controls whether archived rows are eligible.

Callers 4

cmdUpdateProjectFunction · 0.85
resolveProjectRefFunction · 0.85
ResolveTaskOrProjectFunction · 0.85

Calls 1

GetProjectFunction · 0.92

Tested by

no test coverage detected