diff --git a/README.md b/README.md index 7397b81b..f5787e63 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ for changes and offers subsequent commands to interact with observed resources. --- [![Go Report Card](https://goreportcard.com/badge/github.com/derailed/k9s)](https://goreportcard.com/report/github.com/derailed/k9s) -[![Build Status](https://travis-ci.org/derailed/k9s.svg?branch=master)](https://travis-ci.org/derailed/k9s) +[![Build Status](https://travis-ci.com/derailed/k9s.svg?branch=master)](https://travis-ci.com/derailed/k9s)
diff --git a/resource/cr_binding_test.go b/resource/cr_binding_test.go index ff771874..d469bd40 100644 --- a/resource/cr_binding_test.go +++ b/resource/cr_binding_test.go @@ -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"}, }, } } diff --git a/resource/cr_test.go b/resource/cr_test.go index 1a203be1..70111bf2 100644 --- a/resource/cr_test.go +++ b/resource/cr_test.go @@ -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"}, diff --git a/resource/k8s/api.go b/resource/k8s/api.go index 02e8f38a..faaeb89d 100644 --- a/resource/k8s/api.go +++ b/resource/k8s/api.go @@ -30,6 +30,7 @@ func init() { } type ( + // ApiGroup represents a K8s resource descriptor. ApiGroup struct { Resource string Group, Kind, Version string diff --git a/resource/no_test.go b/resource/no_test.go index 18fc9042..9ba80fea 100644 --- a/resource/no_test.go +++ b/resource/no_test.go @@ -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)) diff --git a/resource/pod_test.go b/resource/pod_test.go index 8e90d24f..e63542a1 100644 --- a/resource/pod_test.go +++ b/resource/pod_test.go @@ -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)) diff --git a/resource/sa_test.go b/resource/sa_test.go index e18f0b22..5e711e7c 100644 --- a/resource/sa_test.go +++ b/resource/sa_test.go @@ -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"}}, } } diff --git a/resource/svc_int_test.go b/resource/svc_int_test.go index d899d85c..4fdbc2a9 100644 --- a/resource/svc_int_test.go +++ b/resource/svc_int_test.go @@ -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() diff --git a/resource/svc_test.go b/resource/svc_test.go index c899144d..9f3e1fc2 100644 --- a/resource/svc_test.go +++ b/resource/svc_test.go @@ -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", diff --git a/views/colorer.go b/views/colorer.go index 725875d1..2667438f 100644 --- a/views/colorer.go +++ b/views/colorer.go @@ -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" ) diff --git a/views/colorer_test.go b/views/colorer_test.go index d622242c..9130a6c9 100644 --- a/views/colorer_test.go +++ b/views/colorer_test.go @@ -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" ) diff --git a/views/context.go b/views/context.go index 11a873bc..eee79ffc 100644 --- a/views/context.go +++ b/views/context.go @@ -1,8 +1,8 @@ package views import ( - "github.com/gdamore/tcell" "github.com/derailed/k9s/resource" + "github.com/gdamore/tcell" ) type contextView struct { diff --git a/views/registrar.go b/views/registrar.go index 3c36d2f9..18028801 100644 --- a/views/registrar.go +++ b/views/registrar.go @@ -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, diff --git a/views/xray.go b/views/xray.go index eb63bcea..d1ea009e 100644 --- a/views/xray.go +++ b/views/xray.go @@ -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" )