| 59 | } |
| 60 | |
| 61 | func CreateBranch(ctx context.Context, engine storage.Engine, logger *zap.Logger, root *storage.URI, poolConfig *pools.Config, name string, parent ksuid.KSUID) (*branches.Config, error) { |
| 62 | poolPath := poolConfig.Path(root) |
| 63 | branchesPath := poolPath.JoinPath(BranchesTag) |
| 64 | store, err := branches.OpenStore(ctx, engine, logger, branchesPath) |
| 65 | if err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | if _, err := store.LookupByName(ctx, name); err == nil { |
| 69 | return nil, fmt.Errorf("%s/%s: %w", poolConfig.Name, name, branches.ErrExists) |
| 70 | } |
| 71 | branchConfig := branches.NewConfig(name, parent) |
| 72 | if err := store.Add(ctx, branchConfig); err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | return branchConfig, err |
| 76 | } |
| 77 | |
| 78 | func OpenPool(ctx context.Context, engine storage.Engine, logger *zap.Logger, root *storage.URI, config *pools.Config) (*Pool, error) { |
| 79 | path := config.Path(root) |