cleaning up a bit
parent
48fbb3c1f3
commit
b6208008ff
|
|
@ -13,7 +13,7 @@ for changes and offers subsequent commands to interact with observed resources.
|
|||
---
|
||||
|
||||
[](https://goreportcard.com/report/github.com/derailed/k9s)
|
||||
[](https://travis-ci.org/derailed/k9s)
|
||||
[](https://travis-ci.com/derailed/k9s)
|
||||
|
||||
|
||||
<br/>
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func k8sCRB() *rbacv1.ClusterRoleBinding {
|
|||
CreationTimestamp: metav1.Time{testTime()},
|
||||
},
|
||||
Subjects: []rbacv1.Subject{
|
||||
rbacv1.Subject{Kind: "test", Name: "fred", Namespace: "blee"},
|
||||
{Kind: "test", Name: "fred", Namespace: "blee"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func k8sCR() *rbacv1.ClusterRole {
|
|||
CreationTimestamp: metav1.Time{testTime()},
|
||||
},
|
||||
Rules: []rbacv1.PolicyRule{
|
||||
rbacv1.PolicyRule{
|
||||
{
|
||||
Verbs: []string{"get", "list"},
|
||||
APIGroups: []string{""},
|
||||
ResourceNames: []string{"pod"},
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ func init() {
|
|||
}
|
||||
|
||||
type (
|
||||
// ApiGroup represents a K8s resource descriptor.
|
||||
ApiGroup struct {
|
||||
Resource string
|
||||
Group, Kind, Version string
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func TestNodeMarshal(t *testing.T) {
|
|||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PerNodeMetrics([]v1.Node{*k8sNode()})).
|
||||
ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.Get("blee", "fred")).ThenReturn(k8sNode(), nil)
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ func TestNodeListData(t *testing.T) {
|
|||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PerNodeMetrics([]v1.Node{*k8sNode()})).
|
||||
ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.List("")).ThenReturn(k8s.Collection{*k8sNode()}, nil)
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ func TestNodeListDescribe(t *testing.T) {
|
|||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PerNodeMetrics([]v1.Node{*k8sNode()})).
|
||||
ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.Get("blee", "fred")).ThenReturn(k8sNode(), nil)
|
||||
l := resource.NewNodeListWithArgs("blee", resource.NewNodeWithArgs(ca, mx))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func TestPodMarshal(t *testing.T) {
|
|||
setup(t)
|
||||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.Get("blee", "fred")).ThenReturn(k8sPod(), nil)
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ func TestPodListData(t *testing.T) {
|
|||
setup(t)
|
||||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.List("")).ThenReturn(k8s.Collection{*k8sPod()}, nil)
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ func TestPodListDescribe(t *testing.T) {
|
|||
setup(t)
|
||||
|
||||
mx := NewMockMetricsIfc()
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": k8s.Metric{}}, nil)
|
||||
m.When(mx.PodMetrics()).ThenReturn(map[string]k8s.Metric{"fred": {}}, nil)
|
||||
ca := NewMockCaller()
|
||||
m.When(ca.Get("blee", "fred")).ThenReturn(k8sPod(), nil)
|
||||
l := resource.NewPodListWithArgs("blee", resource.NewPodWithArgs(ca, mx))
|
||||
|
|
|
|||
|
|
@ -106,9 +106,7 @@ func k8sSA() *v1.ServiceAccount {
|
|||
Namespace: "blee",
|
||||
CreationTimestamp: metav1.Time{testTime()},
|
||||
},
|
||||
Secrets: []v1.ObjectReference{
|
||||
v1.ObjectReference{Name: "blee"},
|
||||
},
|
||||
Secrets: []v1.ObjectReference{{Name: "blee"}},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ func TestToPorts(t *testing.T) {
|
|||
e string
|
||||
}{
|
||||
{[]v1.ServicePort{
|
||||
v1.ServicePort{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"}},
|
||||
{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"}},
|
||||
"http:80►90",
|
||||
},
|
||||
{[]v1.ServicePort{
|
||||
v1.ServicePort{Port: 80, NodePort: 30080, Protocol: "UDP"}},
|
||||
{Port: 80, NodePort: 30080, Protocol: "UDP"}},
|
||||
"80►30080╱UDP",
|
||||
},
|
||||
}
|
||||
|
|
@ -48,9 +48,9 @@ func TestToPorts(t *testing.T) {
|
|||
func BenchmarkToPorts(b *testing.B) {
|
||||
var s Service
|
||||
sp := []v1.ServicePort{
|
||||
v1.ServicePort{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
v1.ServicePort{Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
v1.ServicePort{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
{Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
{Name: "http", Port: 80, NodePort: 90, Protocol: "TCP"},
|
||||
}
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ func k8sSVC() *v1.Service {
|
|||
ExternalIPs: []string{"2.2.2.2"},
|
||||
Selector: map[string]string{"fred": "blee"},
|
||||
Ports: []v1.ServicePort{
|
||||
v1.ServicePort{
|
||||
{
|
||||
Name: "http",
|
||||
Port: 90,
|
||||
Protocol: "TCP",
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package views
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/derailed/k9s/resource"
|
||||
"github.com/gdamore/tcell"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package views
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/derailed/k9s/resource"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package views
|
||||
|
||||
import (
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/derailed/k9s/resource"
|
||||
"github.com/gdamore/tcell"
|
||||
)
|
||||
|
||||
type contextView struct {
|
||||
|
|
|
|||
|
|
@ -21,175 +21,175 @@ type (
|
|||
)
|
||||
|
||||
var cmdMap = map[string]resCmd{
|
||||
"cm": resCmd{
|
||||
"cm": {
|
||||
title: "Config Maps",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewConfigMapList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"cr": resCmd{
|
||||
"cr": {
|
||||
title: "Cluster Roles",
|
||||
api: "rbac.authorization.k8s.io",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewClusterRoleList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"crb": resCmd{
|
||||
"crb": {
|
||||
title: "Cluster Role Bindings",
|
||||
api: "rbac.authorization.k8s.io",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewClusterRoleBindingList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"crd": resCmd{
|
||||
"crd": {
|
||||
title: "Custom Resource Definitions",
|
||||
api: "apiextensions.k8s.io",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewCRDList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"cjo": resCmd{
|
||||
"cjo": {
|
||||
title: "CronJobs",
|
||||
api: "batch",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewCronJobList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"ctx": resCmd{
|
||||
"ctx": {
|
||||
title: "Contexts",
|
||||
api: "core",
|
||||
viewFn: newContextView,
|
||||
listFn: resource.NewContextList,
|
||||
colorerFn: ctxColorer,
|
||||
},
|
||||
"ds": resCmd{
|
||||
"ds": {
|
||||
title: "DaemonSets",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewDaemonSetList,
|
||||
colorerFn: dpColorer,
|
||||
},
|
||||
"dp": resCmd{
|
||||
"dp": {
|
||||
title: "Deployments",
|
||||
api: "apps",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewDeploymentList,
|
||||
colorerFn: dpColorer,
|
||||
},
|
||||
"ep": resCmd{
|
||||
"ep": {
|
||||
title: "EndPoints",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewEndpointsList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"ev": resCmd{
|
||||
"ev": {
|
||||
title: "Events",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewEventList,
|
||||
colorerFn: evColorer,
|
||||
},
|
||||
"hpa": resCmd{
|
||||
"hpa": {
|
||||
title: "Horizontal Pod Autoscalers",
|
||||
api: "autoscaling",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewHPAList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"ing": resCmd{
|
||||
"ing": {
|
||||
title: "Ingress",
|
||||
api: "extensions",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewIngressList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"jo": resCmd{
|
||||
"jo": {
|
||||
title: "Jobs",
|
||||
api: "batch",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewJobList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"no": resCmd{
|
||||
"no": {
|
||||
title: "Nodes",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewNodeList,
|
||||
colorerFn: nsColorer,
|
||||
},
|
||||
"ns": resCmd{
|
||||
"ns": {
|
||||
title: "Namespaces",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewNamespaceList,
|
||||
colorerFn: nsColorer,
|
||||
},
|
||||
"po": resCmd{
|
||||
"po": {
|
||||
title: "Pods",
|
||||
api: "core",
|
||||
viewFn: newPodView,
|
||||
listFn: resource.NewPodList,
|
||||
colorerFn: podColorer,
|
||||
},
|
||||
"pv": resCmd{
|
||||
"pv": {
|
||||
title: "Persistent Volumes",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewPVList,
|
||||
colorerFn: pvColorer,
|
||||
},
|
||||
"pvc": resCmd{
|
||||
"pvc": {
|
||||
title: "Persistent Volume Claims",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewPVCList,
|
||||
colorerFn: pvcColorer,
|
||||
},
|
||||
"rb": resCmd{
|
||||
"rb": {
|
||||
title: "Role Bindings",
|
||||
api: "rbac.authorization.k8s.io",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewRoleBindingList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"ro": resCmd{
|
||||
"ro": {
|
||||
title: "Roles",
|
||||
api: "rbac.authorization.k8s.io",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewRoleList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"rs": resCmd{
|
||||
"rs": {
|
||||
title: "Replica Sets",
|
||||
api: "apps",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewReplicaSetList,
|
||||
colorerFn: rsColorer,
|
||||
},
|
||||
"sa": resCmd{
|
||||
"sa": {
|
||||
title: "Service Accounts",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewServiceAccountList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"sec": resCmd{
|
||||
"sec": {
|
||||
title: "Secrets",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewSecretList,
|
||||
colorerFn: defaultColorer,
|
||||
},
|
||||
"sts": resCmd{
|
||||
"sts": {
|
||||
title: "StatefulSets",
|
||||
api: "apps",
|
||||
viewFn: newResourceView,
|
||||
listFn: resource.NewStatefulSetList,
|
||||
colorerFn: stsColorer,
|
||||
},
|
||||
"svc": resCmd{
|
||||
"svc": {
|
||||
title: "Services",
|
||||
api: "core",
|
||||
viewFn: newResourceView,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package views
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/derailed/k9s/resource"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/k8sland/tview"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue