cleanup pass

mine
derailed 2019-03-12 06:05:21 -06:00
parent e8aadc67f0
commit 57c77ca557
32 changed files with 96 additions and 97 deletions

View File

@ -32,10 +32,9 @@ var (
Long: `K9s is a CLI to view and manage your Kubernetes clusters.`, Long: `K9s is a CLI to view and manage your Kubernetes clusters.`,
Run: run, Run: run,
} }
_ config.KubeSettings = &k8s.Config{}
) )
var _ config.KubeSettings = &k8s.Config{}
func init() { func init() {
rootCmd.AddCommand(versionCmd(), infoCmd()) rootCmd.AddCommand(versionCmd(), infoCmd())

View File

@ -1,9 +1,9 @@
package k8s package k8s
// Cluster manages a Kubernetes ClusterRole. // Cluster represents a Kubernetes cluster.
type Cluster struct{} type Cluster struct{}
// NewCluster instantiates a new ClusterRole. // NewCluster instantiates a new cluster.
func NewCluster() *Cluster { func NewCluster() *Cluster {
return &Cluster{} return &Cluster{}
} }

View File

@ -12,13 +12,13 @@ func NewClusterRole() Res {
return &ClusterRole{} return &ClusterRole{}
} }
// Get a service. // Get a cluster role.
func (*ClusterRole) Get(_, n string) (interface{}, error) { func (*ClusterRole) Get(_, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().RbacV1().ClusterRoles().Get(n, opts) return conn.dialOrDie().RbacV1().ClusterRoles().Get(n, opts)
} }
// List all ClusterRoles in a given namespace // List all ClusterRoles on a cluster.
func (*ClusterRole) List(_ string) (Collection, error) { func (*ClusterRole) List(_ string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*ClusterRole) List(_ string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a ClusterRole // Delete a ClusterRole.
func (*ClusterRole) Delete(_, n string) error { func (*ClusterRole) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().RbacV1().ClusterRoles().Delete(n, &opts) return conn.dialOrDie().RbacV1().ClusterRoles().Delete(n, &opts)

View File

@ -18,7 +18,7 @@ func (*ClusterRoleBinding) Get(_, n string) (interface{}, error) {
return conn.dialOrDie().RbacV1().ClusterRoleBindings().Get(n, opts) return conn.dialOrDie().RbacV1().ClusterRoleBindings().Get(n, opts)
} }
// List all ClusterRoleBindings in a given namespace // List all ClusterRoleBindings on a cluster.
func (*ClusterRoleBinding) List(_ string) (Collection, error) { func (*ClusterRoleBinding) List(_ string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*ClusterRoleBinding) List(_ string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a ClusterRoleBinding // Delete a ClusterRoleBinding.
func (*ClusterRoleBinding) Delete(_, n string) error { func (*ClusterRoleBinding) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().RbacV1().ClusterRoleBindings().Delete(n, &opts) return conn.dialOrDie().RbacV1().ClusterRoleBindings().Delete(n, &opts)

View File

@ -18,7 +18,7 @@ func (c *ConfigMap) Get(ns, n string) (interface{}, error) {
return conn.dialOrDie().CoreV1().ConfigMaps(ns).Get(n, opts) return conn.dialOrDie().CoreV1().ConfigMaps(ns).Get(n, opts)
} }
// List all ConfigMaps in a given namespace // List all ConfigMaps in a given namespace.
func (c *ConfigMap) List(ns string) (Collection, error) { func (c *ConfigMap) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (c *ConfigMap) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a ConfigMap // Delete a ConfigMap.
func (c *ConfigMap) Delete(ns, n string) error { func (c *ConfigMap) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().ConfigMaps(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().ConfigMaps(ns).Delete(n, &opts)

View File

@ -7,7 +7,7 @@ import (
"k8s.io/client-go/tools/clientcmd/api" "k8s.io/client-go/tools/clientcmd/api"
) )
// ContextRes represents a kubernetes clusters configurations. // ContextRes represents a Kubernetes clusters configurations.
type ContextRes interface { type ContextRes interface {
Res Res
Switch(n string) error Switch(n string) error
@ -45,7 +45,7 @@ func (*Context) Get(_, n string) (interface{}, error) {
return &NamedContext{Name: n, Context: ctx}, nil return &NamedContext{Name: n, Context: ctx}, nil
} }
// List all Contexts in a given namespace // List all Contexts on the current cluster.
func (*Context) List(string) (Collection, error) { func (*Context) List(string) (Collection, error) {
ctxs, err := conn.config.Contexts() ctxs, err := conn.config.Contexts()
if err != nil { if err != nil {
@ -58,7 +58,7 @@ func (*Context) List(string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Context // Delete a Context.
func (*Context) Delete(_, n string) error { func (*Context) Delete(_, n string) error {
ctx, err := conn.config.CurrentContextName() ctx, err := conn.config.CurrentContextName()
if err != nil { if err != nil {
@ -70,7 +70,7 @@ func (*Context) Delete(_, n string) error {
return conn.config.DelContext(n) return conn.config.DelContext(n)
} }
// Switch cluster Context. // Switch to another context.
func (*Context) Switch(n string) error { func (*Context) Switch(n string) error {
conn.switchContextOrDie(n) conn.switchContextOrDie(n)
return nil return nil

View File

@ -18,7 +18,7 @@ func (*CRD) Get(_, n string) (interface{}, error) {
return conn.nsDialOrDie().Get(n, opts) return conn.nsDialOrDie().Get(n, opts)
} }
// List all CRDs in a given namespace // List all CRDs in a given namespace.
func (*CRD) List(string) (Collection, error) { func (*CRD) List(string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*CRD) List(string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a CRD // Delete a CRD.
func (*CRD) Delete(_, n string) error { func (*CRD) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.nsDialOrDie().Delete(n, &opts) return conn.nsDialOrDie().Delete(n, &opts)

View File

@ -9,7 +9,7 @@ import (
const maxJobNameSize = 42 const maxJobNameSize = 42
// CronJob represents a Kubernetes CronJob // CronJob represents a Kubernetes CronJob.
type CronJob struct{} type CronJob struct{}
// NewCronJob returns a new CronJob. // NewCronJob returns a new CronJob.
@ -23,7 +23,7 @@ func (c *CronJob) Get(ns, n string) (interface{}, error) {
return conn.dialOrDie().BatchV1beta1().CronJobs(ns).Get(n, opts) return conn.dialOrDie().BatchV1beta1().CronJobs(ns).Get(n, opts)
} }
// List all CronJobs in a given namespace // List all CronJobs in a given namespace.
func (c *CronJob) List(ns string) (Collection, error) { func (c *CronJob) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -40,7 +40,7 @@ func (c *CronJob) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a CronJob // Delete a CronJob.
func (c *CronJob) Delete(ns, n string) error { func (c *CronJob) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().BatchV1beta1().CronJobs(ns).Delete(n, &opts) return conn.dialOrDie().BatchV1beta1().CronJobs(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Deployment represents a Kubernetes Deployment // Deployment represents a Kubernetes Deployment.
type Deployment struct{} type Deployment struct{}
// NewDeployment returns a new Deployment. // NewDeployment returns a new Deployment.
@ -12,13 +12,13 @@ func NewDeployment() Res {
return &Deployment{} return &Deployment{}
} }
// Get a service. // Get a deployment.
func (*Deployment) Get(ns, n string) (interface{}, error) { func (*Deployment) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().Apps().Deployments(ns).Get(n, opts) return conn.dialOrDie().Apps().Deployments(ns).Get(n, opts)
} }
// List all Deployments in a given namespace // List all Deployments in a given namespace.
func (*Deployment) List(ns string) (Collection, error) { func (*Deployment) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Deployment) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Deployment // Delete a Deployment.
func (*Deployment) Delete(ns, n string) error { func (*Deployment) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().Apps().Deployments(ns).Delete(n, &opts) return conn.dialOrDie().Apps().Deployments(ns).Delete(n, &opts)

View File

@ -12,13 +12,13 @@ func NewDaemonSet() Res {
return &DaemonSet{} return &DaemonSet{}
} }
// Get a service. // Get a DaemonSet.
func (*DaemonSet) Get(ns, n string) (interface{}, error) { func (*DaemonSet) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().ExtensionsV1beta1().DaemonSets(ns).Get(n, opts) return conn.dialOrDie().ExtensionsV1beta1().DaemonSets(ns).Get(n, opts)
} }
// List all DaemonSets in a given namespace // List all DaemonSets in a given namespace.
func (*DaemonSet) List(ns string) (Collection, error) { func (*DaemonSet) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*DaemonSet) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a DaemonSet // Delete a DaemonSet.
func (*DaemonSet) Delete(ns, n string) error { func (*DaemonSet) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().ExtensionsV1beta1().DaemonSets(ns).Delete(n, &opts) return conn.dialOrDie().ExtensionsV1beta1().DaemonSets(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Endpoints represents a Kubernetes Endpoints // Endpoints represents a Kubernetes Endpoints.
type Endpoints struct{} type Endpoints struct{}
// NewEndpoints returns a new Endpoints. // NewEndpoints returns a new Endpoints.
@ -12,13 +12,13 @@ func NewEndpoints() Res {
return &Endpoints{} return &Endpoints{}
} }
// Get a service. // Get a Endpoint.
func (*Endpoints) Get(ns, n string) (interface{}, error) { func (*Endpoints) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().Endpoints(ns).Get(n, opts) return conn.dialOrDie().CoreV1().Endpoints(ns).Get(n, opts)
} }
// List all Endpointss in a given namespace // List all Endpoints in a given namespace.
func (*Endpoints) List(ns string) (Collection, error) { func (*Endpoints) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Endpoints) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Endpoints // Delete a Endpoint.
func (*Endpoints) Delete(ns, n string) error { func (*Endpoints) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Endpoints(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().Endpoints(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Event represents a Kubernetes Event // Event represents a Kubernetes Event.
type Event struct{} type Event struct{}
// NewEvent returns a new Event. // NewEvent returns a new Event.
@ -12,13 +12,13 @@ func NewEvent() Res {
return &Event{} return &Event{}
} }
// Get a service. // Get a Event.
func (*Event) Get(ns, n string) (interface{}, error) { func (*Event) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().Events(ns).Get(n, opts) return conn.dialOrDie().CoreV1().Events(ns).Get(n, opts)
} }
// List all services in a given namespace // List all Events in a given namespace.
func (*Event) List(ns string) (Collection, error) { func (*Event) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Event) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete an Event.
func (*Event) Delete(ns, n string) error { func (*Event) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Events(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().Events(ns).Delete(n, &opts)

View File

@ -12,13 +12,13 @@ func NewHPA() Res {
return &HPA{} return &HPA{}
} }
// Get a service. // Get a HPA.
func (*HPA) Get(ns, n string) (interface{}, error) { func (*HPA) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Get(n, opts) return conn.dialOrDie().AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Get(n, opts)
} }
// List all services in a given namespace // List all HPAs in a given namespace.
func (*HPA) List(ns string) (Collection, error) { func (*HPA) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*HPA) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a HPA.
func (*HPA) Delete(ns, n string) error { func (*HPA) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Delete(n, &opts) return conn.dialOrDie().AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Ingress represents a Kubernetes Ingress // Ingress represents a Kubernetes Ingress.
type Ingress struct{} type Ingress struct{}
// NewIngress returns a new Ingress. // NewIngress returns a new Ingress.
@ -12,13 +12,13 @@ func NewIngress() Res {
return &Ingress{} return &Ingress{}
} }
// Get a service. // Get a Ingress.
func (*Ingress) Get(ns, n string) (interface{}, error) { func (*Ingress) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().ExtensionsV1beta1().Ingresses(ns).Get(n, opts) return conn.dialOrDie().ExtensionsV1beta1().Ingresses(ns).Get(n, opts)
} }
// List all Ingresss in a given namespace // List all Ingresss in a given namespace.
func (*Ingress) List(ns string) (Collection, error) { func (*Ingress) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Ingress) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Ingress // Delete a Ingress.
func (*Ingress) Delete(ns, n string) error { func (*Ingress) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().ExtensionsV1beta1().Ingresses(ns).Delete(n, &opts) return conn.dialOrDie().ExtensionsV1beta1().Ingresses(ns).Delete(n, &opts)

View File

@ -10,7 +10,7 @@ import (
restclient "k8s.io/client-go/rest" restclient "k8s.io/client-go/rest"
) )
// Job represents a Kubernetes Job // Job represents a Kubernetes Job.
type Job struct{} type Job struct{}
// NewJob returns a new Job. // NewJob returns a new Job.
@ -24,7 +24,7 @@ func (*Job) Get(ns, n string) (interface{}, error) {
return conn.dialOrDie().BatchV1().Jobs(ns).Get(n, opts) return conn.dialOrDie().BatchV1().Jobs(ns).Get(n, opts)
} }
// List all Jobs in a given namespace // List all Jobs in a given namespace.
func (*Job) List(ns string) (Collection, error) { func (*Job) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -41,13 +41,13 @@ func (*Job) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Job // Delete a Job.
func (*Job) Delete(ns, n string) error { func (*Job) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().BatchV1().Jobs(ns).Delete(n, &opts) return conn.dialOrDie().BatchV1().Jobs(ns).Delete(n, &opts)
} }
// Containers returns all container names on pod // Containers returns all container names on job.
func (j *Job) Containers(ns, n string, includeInit bool) ([]string, error) { func (j *Job) Containers(ns, n string, includeInit bool) ([]string, error) {
pod, err := j.assocPod(ns, n) pod, err := j.assocPod(ns, n)
if err != nil { if err != nil {
@ -57,7 +57,7 @@ func (j *Job) Containers(ns, n string, includeInit bool) ([]string, error) {
return NewPod().(Loggable).Containers(ns, pod, includeInit) return NewPod().(Loggable).Containers(ns, pod, includeInit)
} }
// Logs fetch container logs for a given pod and container. // Logs fetch container logs for a given job and container.
func (j *Job) Logs(ns, n, co string, lines int64, prev bool) *restclient.Request { func (j *Job) Logs(ns, n, co string, lines int64, prev bool) *restclient.Request {
pod, err := j.assocPod(ns, n) pod, err := j.assocPod(ns, n)
if err != nil { if err != nil {

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Node represents a Kubernetes service // Node represents a Kubernetes node.
type Node struct{} type Node struct{}
// NewNode returns a new Node. // NewNode returns a new Node.
@ -12,13 +12,13 @@ func NewNode() Res {
return &Node{} return &Node{}
} }
// Get a service. // Get a node.
func (*Node) Get(_, n string) (interface{}, error) { func (*Node) Get(_, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().Nodes().Get(n, opts) return conn.dialOrDie().CoreV1().Nodes().Get(n, opts)
} }
// List all services in a given namespace // List all nodes on the cluster.
func (*Node) List(_ string) (Collection, error) { func (*Node) List(_ string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Node) List(_ string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a node.
func (*Node) Delete(_, n string) error { func (*Node) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Nodes().Delete(n, &opts) return conn.dialOrDie().CoreV1().Nodes().Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Namespace represents a Kubernetes service // Namespace represents a Kubernetes namespace.
type Namespace struct{} type Namespace struct{}
// NewNamespace returns a new Namespace. // NewNamespace returns a new Namespace.
@ -12,13 +12,13 @@ func NewNamespace() Res {
return &Namespace{} return &Namespace{}
} }
// Get a service. // Get a namespace.
func (*Namespace) Get(_, n string) (interface{}, error) { func (*Namespace) Get(_, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().Namespaces().Get(n, opts) return conn.dialOrDie().CoreV1().Namespaces().Get(n, opts)
} }
// List all services in a given namespace // List all namespaces on the cluster.
func (*Namespace) List(_ string) (Collection, error) { func (*Namespace) List(_ string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Namespace) List(_ string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a namespace.
func (*Namespace) Delete(_, n string) error { func (*Namespace) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Namespaces().Delete(n, &opts) return conn.dialOrDie().CoreV1().Namespaces().Delete(n, &opts)

View File

@ -25,13 +25,13 @@ func NewPod() Res {
return &Pod{} return &Pod{}
} }
// Get a service. // Get a pod.
func (*Pod) Get(ns, n string) (interface{}, error) { func (*Pod) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().Pods(ns).Get(n, opts) return conn.dialOrDie().CoreV1().Pods(ns).Get(n, opts)
} }
// List all services in a given namespace // List all pods in a given namespace.
func (*Pod) List(ns string) (Collection, error) { func (*Pod) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -48,7 +48,7 @@ func (*Pod) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a pod.
func (*Pod) Delete(ns, n string) error { func (*Pod) Delete(ns, n string) error {
var grace = defaultKillGrace var grace = defaultKillGrace
opts := metav1.DeleteOptions{ opts := metav1.DeleteOptions{

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// PV represents a Kubernetes service // PV represents a Kubernetes PersistentVolume.
type PV struct{} type PV struct{}
// NewPV returns a new PV. // NewPV returns a new PV.
@ -12,13 +12,13 @@ func NewPV() Res {
return &PV{} return &PV{}
} }
// Get a service. // Get a PV.
func (*PV) Get(_, n string) (interface{}, error) { func (*PV) Get(_, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().PersistentVolumes().Get(n, opts) return conn.dialOrDie().CoreV1().PersistentVolumes().Get(n, opts)
} }
// List all services in a given namespace // List all PVs in a given namespace.
func (*PV) List(_ string) (Collection, error) { func (*PV) List(_ string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*PV) List(_ string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a PV.
func (*PV) Delete(_, n string) error { func (*PV) Delete(_, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().PersistentVolumes().Delete(n, &opts) return conn.dialOrDie().CoreV1().PersistentVolumes().Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// PVC represents a Kubernetes service // PVC represents a Kubernetes service.
type PVC struct{} type PVC struct{}
// NewPVC returns a new PVC. // NewPVC returns a new PVC.
@ -12,13 +12,13 @@ func NewPVC() Res {
return &PVC{} return &PVC{}
} }
// Get a service. // Get a PVC.
func (*PVC) Get(ns, n string) (interface{}, error) { func (*PVC) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().CoreV1().PersistentVolumeClaims(ns).Get(n, opts) return conn.dialOrDie().CoreV1().PersistentVolumeClaims(ns).Get(n, opts)
} }
// List all services in a given namespace // List all PVCs in a given namespace.
func (*PVC) List(ns string) (Collection, error) { func (*PVC) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*PVC) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a PVC.
func (*PVC) Delete(ns, n string) error { func (*PVC) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().PersistentVolumeClaims(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().PersistentVolumeClaims(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// ReplicationController represents a Kubernetes service // ReplicationController represents a Kubernetes service.
type ReplicationController struct{} type ReplicationController struct{}
// NewReplicationController returns a new ReplicationController. // NewReplicationController returns a new ReplicationController.
@ -12,13 +12,13 @@ func NewReplicationController() Res {
return &ReplicationController{} return &ReplicationController{}
} }
// Get a service. // Get a RC.
func (*ReplicationController) Get(ns, n string) (interface{}, error) { func (*ReplicationController) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().Core().ReplicationControllers(ns).Get(n, opts) return conn.dialOrDie().Core().ReplicationControllers(ns).Get(n, opts)
} }
// List all services in a given namespace // List all RCs in a given namespace.
func (*ReplicationController) List(ns string) (Collection, error) { func (*ReplicationController) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*ReplicationController) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a RC.
func (*ReplicationController) Delete(ns, n string) error { func (*ReplicationController) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().Core().ReplicationControllers(ns).Delete(n, &opts) return conn.dialOrDie().Core().ReplicationControllers(ns).Delete(n, &opts)

View File

@ -43,7 +43,7 @@ func (r *Resource) Get(ns, n string) (interface{}, error) {
return r.base().Namespace(ns).Get(n, opts) return r.base().Namespace(ns).Get(n, opts)
} }
// List all Resources in a given namespace // List all Resources in a given namespace.
func (r *Resource) List(ns string) (Collection, error) { func (r *Resource) List(ns string) (Collection, error) {
obj, err := r.listAll(ns, r.name) obj, err := r.listAll(ns, r.name)
if err != nil { if err != nil {
@ -53,7 +53,7 @@ func (r *Resource) List(ns string) (Collection, error) {
return Collection{obj.(*metav1beta1.Table)}, nil return Collection{obj.(*metav1beta1.Table)}, nil
} }
// Delete a Resource // Delete a Resource.
func (r *Resource) Delete(ns, n string) error { func (r *Resource) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return r.base().Namespace(ns).Delete(n, &opts) return r.base().Namespace(ns).Delete(n, &opts)

View File

@ -5,7 +5,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Role represents a Kubernetes service // Role represents a Kubernetes Role.
type Role struct{} type Role struct{}
// NewRole returns a new Role. // NewRole returns a new Role.
@ -13,13 +13,13 @@ func NewRole() Res {
return &Role{} return &Role{}
} }
// Get a service. // Get a Role.
func (*Role) Get(ns, n string) (interface{}, error) { func (*Role) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().RbacV1().Roles(ns).Get(n, opts) return conn.dialOrDie().RbacV1().Roles(ns).Get(n, opts)
} }
// List all services in a given namespace // List all Roles in a given namespace.
func (*Role) List(ns string) (Collection, error) { func (*Role) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -36,7 +36,7 @@ func (*Role) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a Role.
func (*Role) Delete(ns, n string) error { func (*Role) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().RbacV1().Roles(ns).Delete(n, &opts) return conn.dialOrDie().RbacV1().Roles(ns).Delete(n, &opts)

View File

@ -2,7 +2,7 @@ package k8s
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// RoleBinding represents a Kubernetes service // RoleBinding represents a Kubernetes RoleBinding.
type RoleBinding struct{} type RoleBinding struct{}
// NewRoleBinding returns a new RoleBinding. // NewRoleBinding returns a new RoleBinding.
@ -10,13 +10,13 @@ func NewRoleBinding() Res {
return &RoleBinding{} return &RoleBinding{}
} }
// Get a service. // Get a RoleBinding.
func (*RoleBinding) Get(ns, n string) (interface{}, error) { func (*RoleBinding) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().RbacV1().RoleBindings(ns).Get(n, opts) return conn.dialOrDie().RbacV1().RoleBindings(ns).Get(n, opts)
} }
// List all services in a given namespace // List all RoleBindings in a given namespace.
func (*RoleBinding) List(ns string) (Collection, error) { func (*RoleBinding) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -33,7 +33,7 @@ func (*RoleBinding) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a RoleBinding.
func (*RoleBinding) Delete(ns, n string) error { func (*RoleBinding) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().RbacV1().RoleBindings(ns).Delete(n, &opts) return conn.dialOrDie().RbacV1().RoleBindings(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// ReplicaSet represents a Kubernetes service // ReplicaSet represents a Kubernetes ReplicaSet.
type ReplicaSet struct{} type ReplicaSet struct{}
// NewReplicaSet returns a new ReplicaSet. // NewReplicaSet returns a new ReplicaSet.
@ -12,13 +12,13 @@ func NewReplicaSet() Res {
return &ReplicaSet{} return &ReplicaSet{}
} }
// Get a service. // Get a ReplicaSet.
func (*ReplicaSet) Get(ns, n string) (interface{}, error) { func (*ReplicaSet) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
return conn.dialOrDie().Apps().ReplicaSets(ns).Get(n, opts) return conn.dialOrDie().Apps().ReplicaSets(ns).Get(n, opts)
} }
// List all services in a given namespace // List all ReplicaSets in a given namespace.
func (*ReplicaSet) List(ns string) (Collection, error) { func (*ReplicaSet) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*ReplicaSet) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a service // Delete a ReplicaSet.
func (*ReplicaSet) Delete(ns, n string) error { func (*ReplicaSet) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().Apps().ReplicaSets(ns).Delete(n, &opts) return conn.dialOrDie().Apps().ReplicaSets(ns).Delete(n, &opts)

View File

@ -12,7 +12,7 @@ func NewServiceAccount() Res {
return &ServiceAccount{} return &ServiceAccount{}
} }
// Get a ServiceAccount // Get a ServiceAccount.
func (*ServiceAccount) Get(ns, n string) (interface{}, error) { func (*ServiceAccount) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
o, err := conn.dialOrDie().CoreV1().ServiceAccounts(ns).Get(n, opts) o, err := conn.dialOrDie().CoreV1().ServiceAccounts(ns).Get(n, opts)
@ -22,7 +22,7 @@ func (*ServiceAccount) Get(ns, n string) (interface{}, error) {
return o, nil return o, nil
} }
// List all ServiceAccounts in a given namespace // List all ServiceAccounts in a given namespace.
func (*ServiceAccount) List(ns string) (Collection, error) { func (*ServiceAccount) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -39,7 +39,7 @@ func (*ServiceAccount) List(ns string) (Collection, error) {
} }
// Delete a ServiceAccount // Delete a ServiceAccount.
func (*ServiceAccount) Delete(ns, n string) error { func (*ServiceAccount) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().ServiceAccounts(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().ServiceAccounts(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Secret represents a Kubernetes Secret // Secret represents a Kubernetes Secret.
type Secret struct{} type Secret struct{}
// NewSecret returns a new Secret. // NewSecret returns a new Secret.
@ -18,7 +18,7 @@ func (c *Secret) Get(ns, n string) (interface{}, error) {
return conn.dialOrDie().CoreV1().Secrets(ns).Get(n, opts) return conn.dialOrDie().CoreV1().Secrets(ns).Get(n, opts)
} }
// List all Secrets in a given namespace // List all Secrets in a given namespace.
func (c *Secret) List(ns string) (Collection, error) { func (c *Secret) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (c *Secret) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Secret // Delete a Secret.
func (c *Secret) Delete(ns, n string) error { func (c *Secret) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Secrets(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().Secrets(ns).Delete(n, &opts)

View File

@ -12,7 +12,7 @@ func NewStatefulSet() Res {
return &StatefulSet{} return &StatefulSet{}
} }
// Get a StatefulSet // Get a StatefulSet.
func (*StatefulSet) Get(ns, n string) (interface{}, error) { func (*StatefulSet) Get(ns, n string) (interface{}, error) {
opts := metav1.GetOptions{} opts := metav1.GetOptions{}
o, err := conn.dialOrDie().AppsV1().StatefulSets(ns).Get(n, opts) o, err := conn.dialOrDie().AppsV1().StatefulSets(ns).Get(n, opts)
@ -22,7 +22,7 @@ func (*StatefulSet) Get(ns, n string) (interface{}, error) {
return o, nil return o, nil
} }
// List all StatefulSets in a given namespace // List all StatefulSets in a given namespace.
func (*StatefulSet) List(ns string) (Collection, error) { func (*StatefulSet) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -38,7 +38,7 @@ func (*StatefulSet) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a StatefulSet // Delete a StatefulSet.
func (*StatefulSet) Delete(ns, n string) error { func (*StatefulSet) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().AppsV1().StatefulSets(ns).Delete(n, &opts) return conn.dialOrDie().AppsV1().StatefulSets(ns).Delete(n, &opts)

View File

@ -4,7 +4,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
) )
// Service represents a Kubernetes Service // Service represents a Kubernetes Service.
type Service struct{} type Service struct{}
// NewService returns a new Service. // NewService returns a new Service.
@ -18,7 +18,7 @@ func (*Service) Get(ns, n string) (interface{}, error) {
return conn.dialOrDie().CoreV1().Services(ns).Get(n, opts) return conn.dialOrDie().CoreV1().Services(ns).Get(n, opts)
} }
// List all Services in a given namespace // List all Services in a given namespace.
func (*Service) List(ns string) (Collection, error) { func (*Service) List(ns string) (Collection, error) {
opts := metav1.ListOptions{} opts := metav1.ListOptions{}
@ -35,7 +35,7 @@ func (*Service) List(ns string) (Collection, error) {
return cc, nil return cc, nil
} }
// Delete a Service // Delete a Service.
func (*Service) Delete(ns, n string) error { func (*Service) Delete(ns, n string) error {
opts := metav1.DeleteOptions{} opts := metav1.DeleteOptions{}
return conn.dialOrDie().CoreV1().Services(ns).Delete(n, &opts) return conn.dialOrDie().CoreV1().Services(ns).Delete(n, &opts)

View File

@ -3,7 +3,7 @@ package main
import ( import (
"os" "os"
"github.com/derailed/k9s/internal/cmd" "github.com/derailed/k9s/cmd"
"github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/config"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"