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

Function StorageBucketProject

internal/server/project/project.go:137–154  ·  view source on GitHub ↗

StorageBucketProject returns the effective project name to use to for the bucket based on the requested project. If the project specified has the "features.storage.buckets" flag enabled then the project name is returned, otherwise the default project name is returned.

(ctx context.Context, c *db.Cluster, projectName string)

Source from the content-addressed store, hash-verified

135// If the project specified has the "features.storage.buckets" flag enabled then the project name is returned,
136// otherwise the default project name is returned.
137func StorageBucketProject(ctx context.Context, c *db.Cluster, projectName string) (string, error) {
138 var p *api.Project
139 err := c.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
140 dbProject, err := cluster.GetProject(ctx, tx.Tx(), projectName)
141 if err != nil {
142 return err
143 }
144
145 p, err = dbProject.ToAPI(ctx, tx.Tx())
146
147 return err
148 })
149 if err != nil {
150 return "", fmt.Errorf("Failed to load project %q: %w", projectName, err)
151 }
152
153 return StorageBucketProjectFromRecord(p), nil
154}
155
156// StorageBucketProjectFromRecord returns the project name to use to for the bucket based on the supplied project.
157// If the project supplied has the "features.storage.buckets" flag enabled then the project name is returned,

Callers 15

storagePoolBucketsGetFunction · 0.92
storagePoolBucketGetFunction · 0.92
storagePoolBucketsPostFunction · 0.92
storagePoolBucketPutFunction · 0.92
storagePoolBucketDeleteFunction · 0.92
storagePoolBucketKeysGetFunction · 0.92
storagePoolBucketKeyGetFunction · 0.92
storagePoolBucketKeyPutFunction · 0.92

Calls 6

GetProjectFunction · 0.92
TxMethod · 0.80
ErrorfMethod · 0.80
ToAPIMethod · 0.65
TransactionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…