MCPcopy
hub / github.com/lxc/incus / GetProject

Function GetProject

internal/server/db/cluster/projects.mapper.go:230–251  ·  view source on GitHub ↗

GetProject returns the project with the given key. generator: project GetOne

(ctx context.Context, db dbtx, name string)

Source from the content-addressed store, hash-verified

228// GetProject returns the project with the given key.
229// generator: project GetOne
230func GetProject(ctx context.Context, db dbtx, name string) (_ *Project, _err error) {
231 defer func() {
232 _err = mapErr(_err, "Project")
233 }()
234
235 filter := ProjectFilter{}
236 filter.Name = &name
237
238 objects, err := GetProjects(ctx, db, filter)
239 if err != nil {
240 return nil, fmt.Errorf("Failed to fetch from \"projects\" table: %w", err)
241 }
242
243 switch len(objects) {
244 case 0:
245 return nil, ErrNotFound
246 case 1:
247 return &objects[0], nil
248 default:
249 return nil, fmt.Errorf("More than one \"projects\" entry matches")
250 }
251}
252
253// ProjectExists checks if a project with the given key exists.
254// generator: project Exists

Callers 15

StorageVolumeProjectFunction · 0.92
StorageBucketProjectFunction · 0.92
NetworkProjectFunction · 0.92
ProfileProjectFunction · 0.92
NetworkZoneProjectFunction · 0.92
HiddenStoragePoolsFunction · 0.92
fetchProjectFunction · 0.92
AllowBackupCreationFunction · 0.92
UsedByFunction · 0.92

Calls 2

GetProjectsFunction · 0.85
ErrorfMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…