cleaning up
parent
990d58e585
commit
9fd02d11a4
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
var _ Describer = (*Generic)(nil)
|
||||
|
||||
var defaultKillGrace int64 = 0
|
||||
var defaultKillGrace int64
|
||||
|
||||
// Generic represents a generic resource.
|
||||
type Generic struct {
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ func NewTable(gvr string) *Table {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *Table) SetInstance(s string) {
|
||||
t.instance = s
|
||||
// SetInstance sets a single entry table.
|
||||
func (t *Table) SetInstance(path string) {
|
||||
t.instance = path
|
||||
}
|
||||
|
||||
// AddListener adds a new model listener.
|
||||
|
|
|
|||
|
|
@ -46,10 +46,12 @@ func NewTree(gvr string) *Tree {
|
|||
}
|
||||
}
|
||||
|
||||
// ClearFilter clears out active filter.
|
||||
func (t *Tree) ClearFilter() {
|
||||
t.query = ""
|
||||
}
|
||||
|
||||
// SetFiltersets the current filter.
|
||||
func (t *Tree) SetFilter(q string) {
|
||||
t.query = q
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ type Describer interface {
|
|||
Describe(client client.Connection, gvr, path string) (string, error)
|
||||
}
|
||||
|
||||
// TreeRenderer represents an xray node.
|
||||
type TreeRenderer interface {
|
||||
Render(ctx context.Context, ns string, o interface{}) error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ func TestAppNew(t *testing.T) {
|
|||
a := view.NewApp(config.NewConfig(ks{}))
|
||||
a.Init("blee", 10)
|
||||
|
||||
assert.Equal(t, 12, len(a.GetActions()))
|
||||
assert.Equal(t, 11, len(a.GetActions()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ func (b *Browser) bindKeys() {
|
|||
})
|
||||
}
|
||||
|
||||
// SetInstance sets a single instance view.
|
||||
func (b *Browser) SetInstance(path string) {
|
||||
b.GetModel().SetInstance(path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ func (x *Xray) refreshActions() {
|
|||
x.actions.Add(aa)
|
||||
}
|
||||
|
||||
// GetSelectedItem returns the current selection as string.
|
||||
func (x *Xray) GetSelectedItem() string {
|
||||
ref := x.selectedSpec()
|
||||
if ref == nil {
|
||||
|
|
@ -497,7 +498,7 @@ func (x *Xray) TreeNodeSelected() {
|
|||
})
|
||||
}
|
||||
|
||||
// XrayLoadFailed notifies the load failed.
|
||||
// TreeLoadFailed notifies the load failed.
|
||||
func (x *Xray) TreeLoadFailed(err error) {
|
||||
x.app.Flash().Err(err)
|
||||
}
|
||||
|
|
@ -542,7 +543,7 @@ func (x *Xray) update(node *xray.TreeNode) {
|
|||
})
|
||||
}
|
||||
|
||||
// XrayDataChanged notifies the model data changed.
|
||||
// TreeChanged notifies the model data changed.
|
||||
func (x *Xray) TreeChanged(node *xray.TreeNode) {
|
||||
x.count = node.Count(x.gvr.String())
|
||||
x.update(x.filter(node))
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/labels"
|
||||
)
|
||||
|
||||
// Container represents an xray renderer.
|
||||
type Container struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (c *Container) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
co, ok := o.(render.ContainerRes)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// Deployment represents an xray renderer.
|
||||
type Deployment struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (d *Deployment) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ func TestDeployRender(t *testing.T) {
|
|||
for k := range uu {
|
||||
f := makeFactory()
|
||||
f.rows = map[string][]runtime.Object{
|
||||
"v1/pods": []runtime.Object{load(t, "po")},
|
||||
"v1/serviceaccounts": []runtime.Object{load(t, "sa")},
|
||||
"v1/pods": {load(t, "po")},
|
||||
"v1/serviceaccounts": {load(t, "sa")},
|
||||
}
|
||||
|
||||
u := uu[k]
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DaemonSet represents an xray renderer.
|
||||
type DaemonSet struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (d *DaemonSet) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func TestDaemonSetRender(t *testing.T) {
|
|||
var re xray.DaemonSet
|
||||
for k := range uu {
|
||||
f := makeFactory()
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": []runtime.Object{load(t, "po")}}
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": {load(t, "po")}}
|
||||
u := uu[k]
|
||||
t.Run(k, func(t *testing.T) {
|
||||
o := load(t, u.file)
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// Namespace represents an xray renderer.
|
||||
type Namespace struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (n *Namespace) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ import (
|
|||
"k8s.io/kubernetes/pkg/util/node"
|
||||
)
|
||||
|
||||
// Pod represents an xray renderer.
|
||||
type Pod struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (p *Pod) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
pwm, ok := o.(*render.PodWithMetrics)
|
||||
if !ok {
|
||||
|
|
@ -45,7 +47,7 @@ func (p *Pod) Render(ctx context.Context, ns string, o interface{}) error {
|
|||
return err
|
||||
}
|
||||
p.podVolumeRefs(f, node, po.Namespace, po.Spec.Volumes)
|
||||
if err := p.serviceAccountRef(f, ctx, node, po.Namespace, po.Spec); err != nil {
|
||||
if err := p.serviceAccountRef(ctx, f, node, po.Namespace, po.Spec); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +89,7 @@ func (*Pod) containerRefs(ctx context.Context, parent *TreeNode, ns string, spec
|
|||
return nil
|
||||
}
|
||||
|
||||
func (*Pod) serviceAccountRef(f dao.Factory, ctx context.Context, parent *TreeNode, ns string, spec v1.PodSpec) error {
|
||||
func (*Pod) serviceAccountRef(ctx context.Context, f dao.Factory, parent *TreeNode, ns string, spec v1.PodSpec) error {
|
||||
if spec.ServiceAccountName == "" {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ServiceAcccount represents an xray renderer.
|
||||
type ServiceAccount struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (s *ServiceAccount) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// StatefulSet represents an xray renderer.
|
||||
type StatefulSet struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (s *StatefulSet) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func TestStatefulSetRender(t *testing.T) {
|
|||
u := uu[k]
|
||||
t.Run(k, func(t *testing.T) {
|
||||
f := makeFactory()
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": []runtime.Object{load(t, "po")}}
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": {load(t, "po")}}
|
||||
|
||||
o := load(t, u.file)
|
||||
root := xray.NewTreeNode("statefulsets", "statefulsets")
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// Service represents an xray renderer.
|
||||
type Service struct{}
|
||||
|
||||
// Render renders an xray node.
|
||||
func (s *Service) Render(ctx context.Context, ns string, o interface{}) error {
|
||||
raw, ok := o.(*unstructured.Unstructured)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func TestServiceRender(t *testing.T) {
|
|||
var re xray.Service
|
||||
for k := range uu {
|
||||
f := makeFactory()
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": []runtime.Object{load(t, "po")}}
|
||||
f.rows = map[string][]runtime.Object{"v1/pods": {load(t, "po")}}
|
||||
|
||||
u := uu[k]
|
||||
t.Run(k, func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const (
|
|||
OkStatus = "ok"
|
||||
|
||||
// ToastStatus stands for a resource is not up to snuff
|
||||
// aka not running or imcomplete.
|
||||
// aka not running or incomplete.
|
||||
ToastStatus = "toast"
|
||||
|
||||
// CompletedStatus stands for a completed resource.
|
||||
|
|
@ -325,7 +325,7 @@ func dump(n *TreeNode, level int) {
|
|||
}
|
||||
}
|
||||
|
||||
// Dump to stdout for debug.
|
||||
// DumpStdOut to stdout for debug.
|
||||
func (t *TreeNode) DumpStdOut() {
|
||||
dumpStdOut(t, 0)
|
||||
}
|
||||
|
|
@ -341,7 +341,6 @@ func dumpStdOut(n *TreeNode, level int) {
|
|||
}
|
||||
}
|
||||
|
||||
// 😡👎💥🧨💣🎭 🟥🟩✅✔︎☑️✔️✓
|
||||
func toEmoji(gvr string) string {
|
||||
switch gvr {
|
||||
case "v1/pods":
|
||||
|
|
@ -369,6 +368,7 @@ func toEmoji(gvr string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// AsString transforms a node as a string for viewing.
|
||||
func (t TreeNode) AsString() string {
|
||||
const colorFmt = "%s [gray::-][%s[gray::-]] [%s::b]%s[::]"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue