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)
| 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. |
| 137 | func 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, |
no test coverage detected
searching dependent graphs…