-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathrestore.go
56 lines (44 loc) · 1.46 KB
/
restore.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
53
54
55
56
package authorizer
import (
"context"
"io"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/tracing"
)
var _ influxdb.RestoreService = (*RestoreService)(nil)
// RestoreService wraps a influxdb.RestoreService and authorizes actions
// against it appropriately.
type RestoreService struct {
s influxdb.RestoreService
}
// NewRestoreService constructs an instance of an authorizing restore service.
func NewRestoreService(s influxdb.RestoreService) *RestoreService {
return &RestoreService{
s: s,
}
}
func (b RestoreService) RestoreKVStore(ctx context.Context, r io.Reader) error {
span, ctx := tracing.StartSpanFromContext(ctx)
defer span.Finish()
if err := IsAllowedAll(ctx, influxdb.OperPermissions()); err != nil {
return err
}
return b.s.RestoreKVStore(ctx, r)
}
func (b RestoreService) RestoreBucket(ctx context.Context, id platform.ID, dbi []byte) (shardIDMap map[uint64]uint64, err error) {
span, ctx := tracing.StartSpanFromContext(ctx)
defer span.Finish()
if err := IsAllowedAll(ctx, influxdb.OperPermissions()); err != nil {
return nil, err
}
return b.s.RestoreBucket(ctx, id, dbi)
}
func (b RestoreService) RestoreShard(ctx context.Context, shardID uint64, r io.Reader) error {
span, ctx := tracing.StartSpanFromContext(ctx)
defer span.Finish()
if err := IsAllowedAll(ctx, influxdb.OperPermissions()); err != nil {
return err
}
return b.s.RestoreShard(ctx, shardID, r)
}