(ctx context.Context, namespace string, labels map[string]string)
| 39 | } |
| 40 | |
| 41 | func (s *namespaceStore) Create(ctx context.Context, namespace string, labels map[string]string) error { |
| 42 | topbkt, err := createBucketIfNotExists(s.tx, bucketKeyVersion) |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | if err := identifiers.Validate(namespace); err != nil { |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | for k, v := range labels { |
| 52 | if err := l.Validate(k, v); err != nil { |
| 53 | return fmt.Errorf("namespace.Labels: %w", err) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // provides the already exists error. |
| 58 | bkt, err := topbkt.CreateBucket([]byte(namespace)) |
| 59 | if err != nil { |
| 60 | if err == errbolt.ErrBucketExists { |
| 61 | return fmt.Errorf("namespace %q: %w", namespace, errdefs.ErrAlreadyExists) |
| 62 | } |
| 63 | |
| 64 | return err |
| 65 | } |
| 66 | |
| 67 | lbkt, err := bkt.CreateBucketIfNotExists(bucketKeyObjectLabels) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | for k, v := range labels { |
| 73 | if err := lbkt.Put([]byte(k), []byte(v)); err != nil { |
| 74 | return err |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | func (s *namespaceStore) Labels(ctx context.Context, namespace string) (map[string]string, error) { |
| 82 | labels := map[string]string{} |
nothing calls this directly
no test coverage detected