forked from hashicorp/vault
/
logical_storage.go
52 lines (43 loc) · 1.09 KB
/
logical_storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package logical
import (
"context"
"github.com/hashicorp/vault/physical"
)
type LogicalStorage struct {
underlying physical.Backend
}
func (s *LogicalStorage) Get(ctx context.Context, key string) (*StorageEntry, error) {
entry, err := s.underlying.Get(ctx, key)
if err != nil {
return nil, err
}
if entry == nil {
return nil, nil
}
return &StorageEntry{
Key: entry.Key,
Value: entry.Value,
SealWrap: entry.SealWrap,
}, nil
}
func (s *LogicalStorage) Put(ctx context.Context, entry *StorageEntry) error {
return s.underlying.Put(ctx, &physical.Entry{
Key: entry.Key,
Value: entry.Value,
SealWrap: entry.SealWrap,
})
}
func (s *LogicalStorage) Delete(ctx context.Context, key string) error {
return s.underlying.Delete(ctx, key)
}
func (s *LogicalStorage) List(ctx context.Context, prefix string) ([]string, error) {
return s.underlying.List(ctx, prefix)
}
func (s *LogicalStorage) Underlying() physical.Backend {
return s.underlying
}
func NewLogicalStorage(underlying physical.Backend) *LogicalStorage {
return &LogicalStorage{
underlying: underlying,
}
}