-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
types.go
78 lines (58 loc) 路 1.75 KB
/
types.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package ui
import (
"context"
"time"
"github.com/derailed/k9s/internal/model"
"github.com/derailed/k9s/internal/render"
"k8s.io/apimachinery/pkg/runtime"
)
type (
// SortFn represent a function that can sort columnar data.
SortFn func(rows render.Rows, sortCol SortColumn)
// SortColumn represents a sortable column.
SortColumn struct {
name string
asc bool
}
)
// Namespaceable represents a namespaceable model.
type Namespaceable interface {
// ClusterWide returns true if the model represents resource in all namespaces.
ClusterWide() bool
// GetNamespace returns the model namespace.
GetNamespace() string
// SetNamespace changes the model namespace.
SetNamespace(string)
// InNamespace check if current namespace matches models.
InNamespace(string) bool
}
// Lister represents a viewable resource.
type Lister interface {
// Get returns a resource instance.
Get(ctx context.Context, path string) (runtime.Object, error)
}
// Tabular represents a tabular model.
type Tabular interface {
Namespaceable
Lister
// SetInstance sets parent resource path.
SetInstance(string)
// SetLabelFilter sets the label filter.
SetLabelFilter(string)
// Empty returns true if model has no data.
Empty() bool
// Peek returns current model data.
Peek() render.TableData
// Watch watches a given resource for changes.
Watch(context.Context) error
// Refresh forces a new refresh.
Refresh(context.Context) error
// SetRefreshRate sets the model watch loop rate.
SetRefreshRate(time.Duration)
// AddListener registers a model listener.
AddListener(model.TableListener)
// RemoveListener unregister a model listener.
RemoveListener(model.TableListener)
// Delete a resource.
Delete(ctx context.Context, path string, cascade, force bool) error
}