-
Notifications
You must be signed in to change notification settings - Fork 0
/
removed.go
46 lines (36 loc) · 1.12 KB
/
removed.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
// Copyright 2019 Luis Guillén Civera <luisguillenc@gmail.com>. View LICENSE.
package xlistd
import (
"context"
"errors"
"github.com/luids-io/api/xlist"
)
// ErrListRemoved is used when a list is marked as removed
var ErrListRemoved = errors.New("removed from database, update your config")
// removedList is used by builder to return lists marked as removed
type removedList struct {
id string
resources []xlist.Resource
}
// ID implements xlistd.List interface.
func (d *removedList) ID() string {
return d.id
}
// Class implements xlistd.List interface.
func (d *removedList) Class() string {
return "deprecated"
}
// Check implements xlist.Checker.
func (d *removedList) Check(ctx context.Context, name string, res xlist.Resource) (xlist.Response, error) {
return xlist.Response{}, nil
}
// Ping implements xlistd.List.
func (d *removedList) Ping() error {
return ErrListRemoved
}
// Resources implements xlist.Checker.
func (d *removedList) Resources(ctx context.Context) ([]xlist.Resource, error) {
ret := make([]xlist.Resource, len(d.resources), len(d.resources))
copy(ret, d.resources)
return ret, nil
}