resource

package
v0.0.0-...-8acee00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNamespace indicator to fetch default namespace.
	DefaultNamespace = "default"
	// AllNamespace namespace name to span all namespaces.
	AllNamespace = "all"
	// AllNamespaces indicator to retrieve K8s resource for all namespaces.
	AllNamespaces = ""
	// NotNamespaced indicator for non namespaced resource.
	NotNamespaced = "-"

	// New track new resource events.
	New watch.EventType = "NEW"
	// Unchanged provides no change events.
	Unchanged watch.EventType = "UNCHANGED"

	// MissingValue indicates an unset value.
	MissingValue = "<none>"
	// NAValue indicates a value that does not pertain.
	NAValue = "n/a"
)
View Source
const (
	// GetAccess set if resource can be fetched.
	GetAccess = 1 << iota
	// ListAccess set if resource can be listed.
	ListAccess
	// EditAccess set if resource can be edited.
	EditAccess
	// DeleteAccess set if resource can be deleted.
	DeleteAccess
	// ViewAccess set if resource can be viewed.
	ViewAccess
	// NamespaceAccess set if namespaced resource.
	NamespaceAccess
	// DescribeAccess set if resource can be described.
	DescribeAccess
	// SwitchAccess set if resource can be switched (Context).
	SwitchAccess

	// CRUDAccess Verbs.
	CRUDAccess = GetAccess | ListAccess | DeleteAccess | ViewAccess | EditAccess

	// AllVerbsAccess super powers.
	AllVerbsAccess = CRUDAccess | NamespaceAccess
)

Variables

This section is empty.

Functions

func AsPerc

func AsPerc(f float64) string

AsPerc prints a number as a percentage.

func FQN

func FQN(ns, n string) string

FQN returns a fully qualified resource name.

func MetaFQN

func MetaFQN(m metav1.ObjectMeta) string

MetaFQN returns a fully qualified resource name.

func Namespaced

func Namespaced(n string) (string, string)

Namespaced return a namesapace and a name.

func NewList

func NewList(ns, name string, res Resource, verbs int) *list

NewList returns a new resource list.

func ToMi

func ToMi(v float64) string

ToMi shows mem reading for human.

func ToMillicore

func ToMillicore(v int64) string

ToMillicore shows cpu reading for human.

func Truncate

func Truncate(str string, width int) string

Truncate a string to the given l and suffix ellipsis if needed.

Types

type Base

type Base struct {
	Factory

	Connection Connection

	Resource Cruder
	// contains filtered or unexported fields
}

Base resource.

func NewBase

func NewBase(c Connection, r Cruder) *Base

NewBase returns a new base

func (*Base) Delete

func (b *Base) Delete(path string, cascade, force bool) error

Delete a resource by name.

func (*Base) Describe

func (b *Base) Describe(kind, pa string) (string, error)

Describe a given resource.

func (*Base) ExtFields

func (*Base) ExtFields() Properties

ExtFields returns extended fields in relation to headers.

func (*Base) Get

func (b *Base) Get(path string) (Columnar, error)

Get a resource by name

func (*Base) GetFieldSelector

func (b *Base) GetFieldSelector() string

GetFieldSelector returns field selector.

func (*Base) GetLabelSelector

func (b *Base) GetLabelSelector() string

GetLabelSelector returns label selector.

func (*Base) HasSelectors

func (b *Base) HasSelectors() bool

HasSelectors returns true if field or label selectors are set.

func (*Base) List

func (b *Base) List(ns string) (Columnars, error)

List all resources

func (*Base) Name

func (b *Base) Name() string

Name returns the resource namespaced name.

func (*Base) NumCols

func (*Base) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*Base) SetFieldSelector

func (b *Base) SetFieldSelector(s string)

SetFieldSelector refines query results via selector.

func (*Base) SetLabelSelector

func (b *Base) SetLabelSelector(s string)

SetLabelSelector refines query results via labels.

func (*Base) SetNodeMetrics

func (b *Base) SetNodeMetrics(*mv1beta1.NodeMetrics)

SetNodeMetrics attach node metrics to resource.

func (*Base) SetPodMetrics

func (b *Base) SetPodMetrics(*mv1beta1.PodMetrics)

SetPodMetrics attach pod metrics to resource.

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster represents a kubernetes resource.

func NewCluster

func NewCluster(c Connection, log *zerolog.Logger, mx MetricsServer) *Cluster

NewCluster returns a new cluster info resource.

func NewClusterWithArgs

func NewClusterWithArgs(ci ClusterMeta, mx MetricsServer) *Cluster

NewClusterWithArgs for tests only!

func (*Cluster) ClusterName

func (c *Cluster) ClusterName() string

ClusterName returns the cluster name.

func (*Cluster) ContextName

func (c *Cluster) ContextName() string

ContextName returns the context name.

func (*Cluster) Metrics

func (c *Cluster) Metrics(nos k8s.Collection, nmx k8s.Collection, mx *k8s.ClusterMetrics)

Metrics gathers node level metrics and compute utilization percentages.

func (*Cluster) UserName

func (c *Cluster) UserName() string

UserName returns the user name.

func (*Cluster) Version

func (c *Cluster) Version() string

Version returns the current K8s cluster version.

type ClusterMeta

type ClusterMeta interface {
	Connection

	Version() (string, error)
	ContextName() string
	ClusterName() string
	UserName() string
	GetNodes() (*v1.NodeList, error)
}

ClusterMeta represents metadata about a Kubernetes cluster.

type ClusterRole

type ClusterRole struct {
	*Base
	// contains filtered or unexported fields
}

ClusterRole tracks a kubernetes resource.

func NewClusterRole

func NewClusterRole(c Connection) *ClusterRole

NewClusterRole instantiates a new ClusterRole.

func (*ClusterRole) Fields

func (r *ClusterRole) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ClusterRole) Header

func (*ClusterRole) Header(ns string) Row

Header return resource header.

func (*ClusterRole) Marshal

func (r *ClusterRole) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*ClusterRole) New

func (r *ClusterRole) New(i interface{}) Columnar

New builds a new ClusterRole instance from a k8s resource.

type ClusterRoleBinding

type ClusterRoleBinding struct {
	*Base
	// contains filtered or unexported fields
}

ClusterRoleBinding tracks a kubernetes resource.

func NewClusterRoleBinding

func NewClusterRoleBinding(c Connection) *ClusterRoleBinding

NewClusterRoleBinding instantiates a new ClusterRoleBinding.

func (*ClusterRoleBinding) Fields

func (r *ClusterRoleBinding) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ClusterRoleBinding) Header

func (*ClusterRoleBinding) Header(_ string) Row

Header return resource header.

func (*ClusterRoleBinding) Marshal

func (r *ClusterRoleBinding) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*ClusterRoleBinding) New

func (r *ClusterRoleBinding) New(i interface{}) Columnar

New builds a new tabular instance from a k8s resource.

type Columnar

type Columnar interface {
	Header(ns string) Row
	Fields(ns string) Row
	ExtFields() Properties
	Name() string
	SetPodMetrics(*mv1beta1.PodMetrics)
	SetNodeMetrics(*mv1beta1.NodeMetrics)
}

Columnar tracks resources that can be diplayed in a tabular fashion.

type Columnars

type Columnars []Columnar

Columnars a collection of columnars.

type ConfigMap

type ConfigMap struct {
	*Base
	// contains filtered or unexported fields
}

ConfigMap tracks a kubernetes resource.

func NewConfigMap

func NewConfigMap(c Connection) *ConfigMap

NewConfigMap instantiates a new ConfigMap.

func (*ConfigMap) Fields

func (r *ConfigMap) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ConfigMap) Header

func (*ConfigMap) Header(ns string) Row

Header return resource header.

func (*ConfigMap) Marshal

func (r *ConfigMap) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*ConfigMap) New

func (r *ConfigMap) New(i interface{}) Columnar

New builds a new ConfigMap instance from a k8s resource.

func (*ConfigMap) NumCols

func (*ConfigMap) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

type Connection

type Connection k8s.Connection

Connection represents a Kubenetes apiserver connection.

type Container

type Container struct {
	*Base
	// contains filtered or unexported fields
}

Container represents a container on a pod.

func NewContainer

func NewContainer(c Connection, pod *v1.Pod) *Container

NewContainer returns a new set of containers.

func (*Container) Fields

func (r *Container) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Container) Header

func (*Container) Header(ns string) Row

Header return resource header.

func (*Container) List

func (r *Container) List(ns string) (Columnars, error)

List resources for a given namespace.

func (*Container) Logs

func (r *Container) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tails a given container logs

func (*Container) Marshal

func (r *Container) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Container) New

func (r *Container) New(i interface{}) Columnar

New builds a new Container instance from a k8s resource.

func (*Container) NumCols

func (*Container) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*Container) SetPodMetrics

func (r *Container) SetPodMetrics(m *mv1beta1.PodMetrics)

SetPodMetrics set the current k8s resource metrics on associated pod.

type Containers

type Containers interface {
	Containers(path string, includeInit bool) ([]string, error)
}

Containers represents a resource that supports containers.

type Context

type Context struct {
	*Base
	// contains filtered or unexported fields
}

Context tracks a kubernetes resource.

func NewContext

func NewContext(c Connection) *Context

NewContext instantiates a new Context.

func (*Context) Fields

func (r *Context) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Context) Header

func (*Context) Header(string) Row

Header return resource header.

func (*Context) Marshal

func (r *Context) Marshal(path string) (string, error)

Marshal the resource to yaml.

func (*Context) New

func (r *Context) New(i interface{}) Columnar

New builds a new Context instance from a k8s resource.

func (*Context) Switch

func (r *Context) Switch(c string) error

Switch out current context.

type CronJob

type CronJob struct {
	*Base
	// contains filtered or unexported fields
}

CronJob tracks a kubernetes resource.

func NewCronJob

func NewCronJob(c Connection) *CronJob

NewCronJob instantiates a new CronJob.

func (*CronJob) Fields

func (r *CronJob) Fields(ns string) Row

Fields retrieves displayable fields.

func (*CronJob) Header

func (*CronJob) Header(ns string) Row

Header return resource header.

func (*CronJob) Marshal

func (r *CronJob) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*CronJob) New

func (r *CronJob) New(i interface{}) Columnar

New builds a new CronJob instance from a k8s resource.

func (*CronJob) Run

func (r *CronJob) Run(pa string) error

Run a given cronjob.

type Cruder

type Cruder interface {
	Get(ns string, name string) (interface{}, error)
	List(ns string) (k8s.Collection, error)
	Delete(ns string, name string, cascade, force bool) error
	SetLabelSelector(string)
	SetFieldSelector(string)
	GetLabelSelector() string
	GetFieldSelector() string
	HasSelectors() bool
}

Cruder represents a crudable Kubernetes resource.

type Custom

type Custom struct {
	*Base
	// contains filtered or unexported fields
}

Custom tracks a kubernetes resource.

func NewCustom

func NewCustom(c k8s.Connection, group, version, name string) *Custom

NewCustom instantiates a new Kubernetes Resource.

func (*Custom) Fields

func (r *Custom) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Custom) Header

func (r *Custom) Header(ns string) Row

Header return resource header.

func (*Custom) List

func (r *Custom) List(ns string) (Columnars, error)

List all resources

func (*Custom) Marshal

func (r *Custom) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Custom) New

func (r *Custom) New(i interface{}) Columnar

New builds a new Custom instance from a k8s resource.

type CustomResourceDefinition

type CustomResourceDefinition struct {
	*Base
	// contains filtered or unexported fields
}

CustomResourceDefinition tracks a kubernetes resource.

func NewCustomResourceDefinition

func NewCustomResourceDefinition(c Connection) *CustomResourceDefinition

NewCustomResourceDefinition instantiates a new CustomResourceDefinition.

func (*CustomResourceDefinition) ExtFields

func (r *CustomResourceDefinition) ExtFields() Properties

ExtFields returns extended fields.

func (*CustomResourceDefinition) Fields

func (r *CustomResourceDefinition) Fields(ns string) Row

Fields retrieves displayable fields.

func (*CustomResourceDefinition) Header

func (*CustomResourceDefinition) Header(ns string) Row

Header return the resource header.

func (*CustomResourceDefinition) Marshal

func (r *CustomResourceDefinition) Marshal(path string) (string, error)

Marshal a resource.

func (*CustomResourceDefinition) New

func (r *CustomResourceDefinition) New(i interface{}) Columnar

New builds a new CustomResourceDefinition instance from a k8s resource.

type DaemonSet

type DaemonSet struct {
	*Base
	// contains filtered or unexported fields
}

DaemonSet tracks a kubernetes resource.

func NewDaemonSet

func NewDaemonSet(c Connection) *DaemonSet

NewDaemonSet instantiates a new DaemonSet.

func (*DaemonSet) Fields

func (r *DaemonSet) Fields(ns string) Row

Fields retrieves displayable fields.

func (*DaemonSet) Header

func (*DaemonSet) Header(ns string) Row

Header return resource header.

func (*DaemonSet) Logs

func (r *DaemonSet) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tail logs for all pods represented by this DaemonSet.

func (*DaemonSet) Marshal

func (r *DaemonSet) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*DaemonSet) New

func (r *DaemonSet) New(i interface{}) Columnar

New builds a new DaemonSet instance from a k8s resource.

type Deployment

type Deployment struct {
	*Base
	// contains filtered or unexported fields
}

Deployment tracks a kubernetes resource.

func NewDeployment

func NewDeployment(c Connection) *Deployment

NewDeployment instantiates a new Deployment.

func (*Deployment) Fields

func (r *Deployment) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Deployment) Header

func (*Deployment) Header(ns string) Row

Header return resource header.

func (*Deployment) Logs

func (r *Deployment) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tail logs for all pods represented by this deployment.

func (*Deployment) Marshal

func (r *Deployment) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Deployment) New

func (r *Deployment) New(i interface{}) Columnar

New builds a new Deployment instance from a k8s resource.

func (*Deployment) NumCols

func (*Deployment) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*Deployment) Scale

func (r *Deployment) Scale(ns, n string, replicas int32) error

Scale the specified resource.

type Endpoints

type Endpoints struct {
	*Base
	// contains filtered or unexported fields
}

Endpoints tracks a kubernetes resource.

func NewEndpoints

func NewEndpoints(c Connection) *Endpoints

NewEndpoints instantiates a new Endpoints.

func (*Endpoints) Fields

func (r *Endpoints) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Endpoints) Header

func (*Endpoints) Header(ns string) Row

Header return resource header.

func (*Endpoints) Marshal

func (r *Endpoints) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Endpoints) New

func (r *Endpoints) New(i interface{}) Columnar

New builds a new Endpoints instance from a k8s resource.

type Event

type Event struct {
	*Base
	// contains filtered or unexported fields
}

Event tracks a kubernetes resource.

func NewEvent

func NewEvent(c Connection) *Event

NewEvent instantiates a new Event.

func (*Event) Delete

func (r *Event) Delete(path string, cascade, force bool) error

Delete a resource by name.

func (*Event) Fields

func (r *Event) Fields(ns string) Row

Fields returns display fields.

func (*Event) Header

func (*Event) Header(ns string) Row

Header return resource header.

func (*Event) Marshal

func (r *Event) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Event) New

func (r *Event) New(i interface{}) Columnar

New builds a new Event instance from a k8s resource.

type Factory

type Factory interface {
	New(interface{}) Columnar
}

Factory creates new tabular resources.

type Fqn

type Fqn struct {
	Namespace, Name, Container string
}

Fqn uniquely describes a container

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	*Base
	// contains filtered or unexported fields
}

HorizontalPodAutoscaler tracks a kubernetes resource.

func NewHorizontalPodAutoscaler

func NewHorizontalPodAutoscaler(c Connection) *HorizontalPodAutoscaler

NewHorizontalPodAutoscaler instantiates a new HorizontalPodAutoscaler.

func (*HorizontalPodAutoscaler) Fields

func (r *HorizontalPodAutoscaler) Fields(ns string) Row

Fields retrieves displayable fields.

func (*HorizontalPodAutoscaler) Header

func (*HorizontalPodAutoscaler) Header(ns string) Row

Header return resource header.

func (*HorizontalPodAutoscaler) Marshal

func (r *HorizontalPodAutoscaler) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*HorizontalPodAutoscaler) New

func (r *HorizontalPodAutoscaler) New(i interface{}) Columnar

New builds a new HorizontalPodAutoscaler instance from a k8s resource.

type HorizontalPodAutoscalerV1

type HorizontalPodAutoscalerV1 struct {
	*Base
	// contains filtered or unexported fields
}

HorizontalPodAutoscalerV1 tracks a kubernetes resource.

func NewHorizontalPodAutoscalerV1

func NewHorizontalPodAutoscalerV1(c Connection) *HorizontalPodAutoscalerV1

NewHorizontalPodAutoscalerV1 instantiates a new HorizontalPodAutoscalerV1.

func (*HorizontalPodAutoscalerV1) Fields

func (r *HorizontalPodAutoscalerV1) Fields(ns string) Row

Fields retrieves displayable fields.

func (*HorizontalPodAutoscalerV1) Header

func (*HorizontalPodAutoscalerV1) Header(ns string) Row

Header return resource header.

func (*HorizontalPodAutoscalerV1) Marshal

func (r *HorizontalPodAutoscalerV1) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*HorizontalPodAutoscalerV1) New

func (r *HorizontalPodAutoscalerV1) New(i interface{}) Columnar

New builds a new HorizontalPodAutoscalerV1 instance from a k8s resource.

type HorizontalPodAutoscalerV2Beta1

type HorizontalPodAutoscalerV2Beta1 struct {
	*Base
	// contains filtered or unexported fields
}

HorizontalPodAutoscalerV2Beta1 tracks a kubernetes resource.

func NewHorizontalPodAutoscalerV2Beta1

func NewHorizontalPodAutoscalerV2Beta1(c Connection) *HorizontalPodAutoscalerV2Beta1

NewHorizontalPodAutoscalerV2Beta1 instantiates a new HorizontalPodAutoscalerV2Beta1.

func (*HorizontalPodAutoscalerV2Beta1) Fields

Fields retrieves displayable fields.

func (*HorizontalPodAutoscalerV2Beta1) Header

Header return resource header.

func (*HorizontalPodAutoscalerV2Beta1) Marshal

func (r *HorizontalPodAutoscalerV2Beta1) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*HorizontalPodAutoscalerV2Beta1) New

func (r *HorizontalPodAutoscalerV2Beta1) New(i interface{}) Columnar

New builds a new HorizontalPodAutoscalerV2Beta1 instance from a k8s resource.

type IKey

type IKey string

IKey informer context key.

type Ingress

type Ingress struct {
	*Base
	// contains filtered or unexported fields
}

Ingress tracks a kubernetes resource.

func NewIngress

func NewIngress(c Connection) *Ingress

NewIngress instantiates a new Ingress.

func (*Ingress) Fields

func (r *Ingress) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Ingress) Header

func (*Ingress) Header(ns string) Row

Header return resource header.

func (*Ingress) Marshal

func (r *Ingress) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Ingress) New

func (r *Ingress) New(i interface{}) Columnar

New builds a new Ingress instance from a k8s resource.

type Job

type Job struct {
	*Base
	// contains filtered or unexported fields
}

Job tracks a kubernetes resource.

func NewJob

func NewJob(c Connection) *Job

NewJob instantiates a new Job.

func (*Job) Containers

func (r *Job) Containers(path string, includeInit bool) ([]string, error)

Containers fetch all the containers on this job, may include init containers.

func (*Job) Fields

func (r *Job) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Job) Header

func (*Job) Header(ns string) Row

Header return resource header.

func (*Job) Logs

func (r *Job) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs retrieves logs for a given container.

func (*Job) Marshal

func (r *Job) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Job) New

func (r *Job) New(i interface{}) Columnar

New builds a new Job instance from a k8s resource.

type List

type List interface {
	Data() TableData
	Resource() Resource
	Namespaced() bool
	AllNamespaces() bool
	GetNamespace() string
	SetNamespace(string)
	Reconcile(informer *wa.Informer, path *string) error
	GetName() string
	Access(flag int) bool
	GetAccess() int
	SetAccess(int)
	SetFieldSelector(string)
	SetLabelSelector(string)
	HasSelectors() bool
}

List protocol to display and update a collection of resources

func NewClusterRoleBindingList

func NewClusterRoleBindingList(c Connection, _ string) List

NewClusterRoleBindingList returns a new resource list.

func NewClusterRoleList

func NewClusterRoleList(c Connection, ns string) List

NewClusterRoleList returns a new resource list.

func NewConfigMapList

func NewConfigMapList(c Connection, ns string) List

NewConfigMapList returns a new resource list.

func NewContainerList

func NewContainerList(c Connection, pod *v1.Pod) List

NewContainerList returns a collection of container.

func NewContextList

func NewContextList(c Connection, ns string) List

NewContextList returns a new resource list.

func NewCronJobList

func NewCronJobList(c Connection, ns string) List

NewCronJobList returns a new resource list.

func NewCustomList

func NewCustomList(c k8s.Connection, ns, group, version, name string) List

NewCustomList returns a new resource list.

func NewCustomResourceDefinitionList

func NewCustomResourceDefinitionList(c Connection, ns string) List

NewCustomResourceDefinitionList returns a new resource list.

func NewDaemonSetList

func NewDaemonSetList(c Connection, ns string) List

NewDaemonSetList returns a new resource list.

func NewDeploymentList

func NewDeploymentList(c Connection, ns string) List

NewDeploymentList returns a new resource list.

func NewEndpointsList

func NewEndpointsList(c Connection, ns string) List

NewEndpointsList returns a new resource list.

func NewEventList

func NewEventList(c Connection, ns string) List

NewEventList returns a new resource list.

func NewHorizontalPodAutoscalerList

func NewHorizontalPodAutoscalerList(c Connection, ns string) List

NewHorizontalPodAutoscalerList returns a new resource list.

func NewHorizontalPodAutoscalerV1List

func NewHorizontalPodAutoscalerV1List(c Connection, ns string) List

NewHorizontalPodAutoscalerV1List returns a new resource list.

func NewHorizontalPodAutoscalerV2Beta1List

func NewHorizontalPodAutoscalerV2Beta1List(c Connection, ns string) List

NewHorizontalPodAutoscalerV2Beta1List returns a new resource list.

func NewIngressList

func NewIngressList(c Connection, ns string) List

NewIngressList returns a new resource list.

func NewJobList

func NewJobList(c Connection, ns string) List

NewJobList returns a new resource list.

func NewNamespaceList

func NewNamespaceList(c Connection, ns string) List

NewNamespaceList returns a new resource list.

func NewNetworkPolicyList

func NewNetworkPolicyList(c Connection, ns string) List

NewNetworkPolicyList returns a new resource list.

func NewNodeList

func NewNodeList(c Connection, _ string) List

NewNodeList returns a new resource list.

func NewPDBList

func NewPDBList(c Connection, ns string) List

NewPDBList returns a new resource list.

func NewPersistentVolumeClaimList

func NewPersistentVolumeClaimList(c Connection, ns string) List

NewPersistentVolumeClaimList returns a new resource list.

func NewPersistentVolumeList

func NewPersistentVolumeList(c Connection, ns string) List

NewPersistentVolumeList returns a new resource list.

func NewPodList

func NewPodList(c Connection, ns string) List

NewPodList returns a new resource list.

func NewReplicaSetList

func NewReplicaSetList(c Connection, ns string) List

NewReplicaSetList returns a new resource list.

func NewReplicationControllerList

func NewReplicationControllerList(c Connection, ns string) List

NewReplicationControllerList returns a new resource list.

func NewRoleBindingList

func NewRoleBindingList(c Connection, ns string) List

NewRoleBindingList returns a new resource list.

func NewRoleList

func NewRoleList(c Connection, ns string) List

NewRoleList returns a new resource list.

func NewSecretList

func NewSecretList(c Connection, ns string) List

NewSecretList returns a new resource list.

func NewServiceAccountList

func NewServiceAccountList(c Connection, ns string) List

NewServiceAccountList returns a new resource list.

func NewServiceList

func NewServiceList(c Connection, ns string) List

NewServiceList returns a new resource list.

func NewStatefulSetList

func NewStatefulSetList(c Connection, ns string) List

NewStatefulSetList returns a new resource list.

type LogOptions

type LogOptions struct {
	Fqn

	Lines           int64
	Previous        bool
	Color           color.Paint
	SingleContainer bool
	MultiPods       bool
}

LogOptions represent logger options.

func (LogOptions) DecorateLog

func (o LogOptions) DecorateLog(msg string) string

DecorateLog add a log header to display po/co information along with the log message.

func (LogOptions) FQN

func (o LogOptions) FQN() string

FQN returns resource fully qualified name.

func (LogOptions) FixedSizeName

func (o LogOptions) FixedSizeName() string

FixedSizeName returns a normalize fixed size pod name if possible.

func (LogOptions) HasContainer

func (o LogOptions) HasContainer() bool

HasContainer checks if a container is present.

func (LogOptions) Path

func (o LogOptions) Path() string

Path returns resource descriptor path.

type MetricsServer

type MetricsServer interface {
	MetricsService

	ClusterLoad(nodes k8s.Collection, metrics k8s.Collection, cmx *k8s.ClusterMetrics)
	NodesMetrics(k8s.Collection, *mv1beta1.NodeMetricsList, k8s.NodesMetrics)
	PodsMetrics(*mv1beta1.PodMetricsList, k8s.PodsMetrics)
}

MetricsServer gather metrics information from pods and nodes.

type MetricsService

type MetricsService interface {
	HasMetrics() bool
	FetchNodesMetrics() (*mv1beta1.NodeMetricsList, error)
	FetchPodsMetrics(ns string) (*mv1beta1.PodMetricsList, error)
}

MetricsService calls the metrics server for metrics info.

type Namespace

type Namespace struct {
	*Base
	// contains filtered or unexported fields
}

Namespace tracks a kubernetes resource.

func NewNamespace

func NewNamespace(c Connection) *Namespace

NewNamespace instantiates a new Namespace.

func (*Namespace) Fields

func (r *Namespace) Fields(ns string) Row

Fields returns displayable fields.

func (*Namespace) Header

func (*Namespace) Header(ns string) Row

Header returns resource header.

func (*Namespace) Marshal

func (r *Namespace) Marshal(path string) (string, error)

Marshal a resource to yaml.

func (*Namespace) New

func (r *Namespace) New(i interface{}) Columnar

New builds a new Namespace instance from a k8s resource.

type NetworkPolicy

type NetworkPolicy struct {
	*Base
	// contains filtered or unexported fields
}

NetworkPolicy tracks a kubernetes resource.

func NewNetworkPolicy

func NewNetworkPolicy(c Connection) *NetworkPolicy

NewNetworkPolicy instantiates a new NetworkPolicy.

func (*NetworkPolicy) Fields

func (r *NetworkPolicy) Fields(ns string) Row

Fields retrieves displayable fields.

func (*NetworkPolicy) Header

func (*NetworkPolicy) Header(ns string) Row

Header return resource header.

func (*NetworkPolicy) Marshal

func (r *NetworkPolicy) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*NetworkPolicy) New

func (r *NetworkPolicy) New(i interface{}) Columnar

New builds a new NetworkPolicy instance from a k8s resource.

type Node

type Node struct {
	*Base
	// contains filtered or unexported fields
}

Node tracks a kubernetes resource.

func NewNode

func NewNode(c Connection) *Node

NewNode instantiates a new Node.

func (*Node) Fields

func (r *Node) Fields(ns string) Row

Fields returns displayable fields.

func (*Node) Header

func (*Node) Header(ns string) Row

Header returns resource header.

func (*Node) List

func (r *Node) List(ns string) (Columnars, error)

List all resources for a given namespace.

func (*Node) Marshal

func (r *Node) Marshal(path string) (string, error)

Marshal a resource to yaml.

func (*Node) New

func (r *Node) New(i interface{}) Columnar

New builds a new Node instance from a k8s resource.

func (*Node) NumCols

func (*Node) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*Node) SetNodeMetrics

func (r *Node) SetNodeMetrics(m *mv1beta1.NodeMetrics)

SetNodeMetrics set the current k8s resource metrics on a given node.

type PersistentVolume

type PersistentVolume struct {
	*Base
	// contains filtered or unexported fields
}

PersistentVolume tracks a kubernetes resource.

func NewPersistentVolume

func NewPersistentVolume(c Connection) *PersistentVolume

NewPersistentVolume instantiates a new PersistentVolume.

func (*PersistentVolume) Fields

func (r *PersistentVolume) Fields(ns string) Row

Fields retrieves displayable fields.

func (*PersistentVolume) Header

func (*PersistentVolume) Header(ns string) Row

Header return resource header.

func (*PersistentVolume) Marshal

func (r *PersistentVolume) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*PersistentVolume) New

func (r *PersistentVolume) New(i interface{}) Columnar

New builds a new PersistentVolume instance from a k8s resource.

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	*Base
	// contains filtered or unexported fields
}

PersistentVolumeClaim tracks a kubernetes resource.

func NewPersistentVolumeClaim

func NewPersistentVolumeClaim(c Connection) *PersistentVolumeClaim

NewPersistentVolumeClaim instantiates a new PersistentVolumeClaim.

func (*PersistentVolumeClaim) Fields

func (r *PersistentVolumeClaim) Fields(ns string) Row

Fields retrieves displayable fields.

func (*PersistentVolumeClaim) Header

func (*PersistentVolumeClaim) Header(ns string) Row

Header return resource header.

func (*PersistentVolumeClaim) Marshal

func (r *PersistentVolumeClaim) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*PersistentVolumeClaim) New

func (r *PersistentVolumeClaim) New(i interface{}) Columnar

New builds a new PersistentVolumeClaim instance from a k8s resource.

type Pod

type Pod struct {
	*Base
	// contains filtered or unexported fields
}

Pod that can be displayed in a table and interacted with.

func NewPod

func NewPod(c Connection) *Pod

NewPod instantiates a new Pod.

func (*Pod) Containers

func (r *Pod) Containers(path string, includeInit bool) ([]string, error)

Containers lists out all the docker containers name contained in a pod.

func (*Pod) Fields

func (r *Pod) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Pod) Header

func (*Pod) Header(ns string) Row

Header return resource header.

func (*Pod) List

func (r *Pod) List(ns string) (Columnars, error)

List resources for a given namespace.

func (*Pod) Logs

func (r *Pod) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tails a given container logs

func (*Pod) Marshal

func (r *Pod) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Pod) New

func (r *Pod) New(i interface{}) Columnar

New builds a new Pod instance from a k8s resource.

func (*Pod) NumCols

func (*Pod) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*Pod) PodLogs

func (r *Pod) PodLogs(ctx context.Context, c chan<- string, opts LogOptions) error

PodLogs tail logs for all containers in a running Pod.

func (*Pod) SetPodMetrics

func (r *Pod) SetPodMetrics(m *mv1beta1.PodMetrics)

SetPodMetrics set the current k8s resource metrics on a given pod.

type PodDisruptionBudget

type PodDisruptionBudget struct {
	*Base
	// contains filtered or unexported fields
}

PodDisruptionBudget that can be displayed in a table and interacted with.

func NewPDB

NewPDB instantiates a new PDB.

func (*PodDisruptionBudget) Fields

func (r *PodDisruptionBudget) Fields(ns string) Row

Fields retrieves displayable fields.

func (*PodDisruptionBudget) Header

func (*PodDisruptionBudget) Header(ns string) Row

Header return resource header.

func (*PodDisruptionBudget) Marshal

func (r *PodDisruptionBudget) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*PodDisruptionBudget) New

func (r *PodDisruptionBudget) New(i interface{}) Columnar

New builds a new PDB instance from a k8s resource.

type Properties

type Properties map[string]interface{}

Properties a collection of extra properties on a K8s resource.

type ReplicaSet

type ReplicaSet struct {
	*Base
	// contains filtered or unexported fields
}

ReplicaSet tracks a kubernetes resource.

func NewReplicaSet

func NewReplicaSet(c Connection) *ReplicaSet

NewReplicaSet instantiates a new ReplicaSet.

func (*ReplicaSet) Fields

func (r *ReplicaSet) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ReplicaSet) Header

func (*ReplicaSet) Header(ns string) Row

Header return resource header.

func (*ReplicaSet) Marshal

func (r *ReplicaSet) Marshal(path string) (string, error)

Marshal a deployment given a namespaced name.

func (*ReplicaSet) New

func (r *ReplicaSet) New(i interface{}) Columnar

New builds a new ReplicaSet instance from a k8s resource.

type ReplicationController

type ReplicationController struct {
	*Base
	// contains filtered or unexported fields
}

ReplicationController tracks a kubernetes resource.

func NewReplicationController

func NewReplicationController(c Connection) *ReplicationController

NewReplicationController instantiates a new ReplicationController.

func (*ReplicationController) Fields

func (r *ReplicationController) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ReplicationController) Header

func (*ReplicationController) Header(ns string) Row

Header return resource header.

func (*ReplicationController) Marshal

func (r *ReplicationController) Marshal(path string) (string, error)

Marshal a deployment given a namespaced name.

func (*ReplicationController) New

func (r *ReplicationController) New(i interface{}) Columnar

New builds a new ReplicationController instance from a k8s resource.

func (*ReplicationController) Scale

func (r *ReplicationController) Scale(ns, n string, replicas int32) error

Scale the specified resource.

type Resource

type Resource interface {
	New(interface{}) Columnar
	Get(path string) (Columnar, error)
	List(ns string) (Columnars, error)
	Delete(path string, cascade, force bool) error
	Describe(kind, pa string) (string, error)
	Marshal(pa string) (string, error)
	Header(ns string) Row
	NumCols(ns string) map[string]bool
	SetFieldSelector(string)
	SetLabelSelector(string)
	GetFieldSelector() string
	GetLabelSelector() string
	HasSelectors() bool
}

Resource represents a tabular Kubernetes resource.

type Role

type Role struct {
	*Base
	// contains filtered or unexported fields
}

Role tracks a kubernetes resource.

func NewRole

func NewRole(c Connection) *Role

NewRole instantiates a new Role.

func (*Role) Fields

func (r *Role) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Role) Header

func (*Role) Header(ns string) Row

Header return resource header.

func (*Role) Marshal

func (r *Role) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Role) New

func (r *Role) New(i interface{}) Columnar

New builds a new Role instance from a k8s resource.

type RoleBinding

type RoleBinding struct {
	*Base
	// contains filtered or unexported fields
}

RoleBinding tracks a kubernetes resource.

func NewRoleBinding

func NewRoleBinding(c Connection) *RoleBinding

NewRoleBinding instantiates a new RoleBinding.

func (*RoleBinding) Fields

func (r *RoleBinding) Fields(ns string) Row

Fields retrieves displayable fields.

func (*RoleBinding) Header

func (*RoleBinding) Header(ns string) Row

Header return resource header.

func (*RoleBinding) Marshal

func (r *RoleBinding) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*RoleBinding) New

func (r *RoleBinding) New(i interface{}) Columnar

New builds a new RoleBinding instance from a k8s resource.

type Row

type Row []string

Row represents a collection of string fields.

type RowEvent

type RowEvent struct {
	Action watch.EventType
	Fields Row
	Deltas Row
}

RowEvent represents a call for action after a resource reconciliation. Tracks whether a resource got added, deleted or updated.

type RowEvents

type RowEvents map[string]*RowEvent

RowEvents tracks resource update events.

type Rows

type Rows []Row

Rows represents a collection of rows.

type Runnable

type Runnable interface {
	Run(ns, n string) error
}

Runnable can run jobs.

type Runner

type Runner interface {
	Run(path string) error
}

Runner can run jobs.

type Scalable

type Scalable interface {
	Scale(ns string, name string, replicas int32) error
}

Scalable represents a scalable Kubernetes resource.

type Secret

type Secret struct {
	*Base
	// contains filtered or unexported fields
}

Secret tracks a kubernetes resource.

func NewSecret

func NewSecret(c Connection) *Secret

NewSecret instantiates a new Secret.

func (*Secret) Fields

func (r *Secret) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Secret) Header

func (*Secret) Header(ns string) Row

Header return resource header.

func (*Secret) Marshal

func (r *Secret) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*Secret) New

func (r *Secret) New(i interface{}) Columnar

New builds a new Secret instance from a k8s resource.

func (*Secret) NumCols

func (*Secret) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

type Service

type Service struct {
	*Base
	// contains filtered or unexported fields
}

Service tracks a kubernetes resource.

func NewService

func NewService(c Connection) *Service

NewService instantiates a new Service.

func (*Service) Fields

func (r *Service) Fields(ns string) Row

Fields retrieves displayable fields.

func (*Service) Header

func (*Service) Header(ns string) Row

Header returns resource header.

func (*Service) Logs

func (r *Service) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tail logs for all pods represented by this service.

func (*Service) Marshal

func (r *Service) Marshal(path string) (string, error)

Marshal resource to yaml. BOZO!! Why you need to fill type info??

func (*Service) New

func (r *Service) New(i interface{}) Columnar

New builds a new Service instance from a k8s resource.

type ServiceAccount

type ServiceAccount struct {
	*Base
	// contains filtered or unexported fields
}

ServiceAccount represents a Kubernetes resource.

func NewServiceAccount

func NewServiceAccount(c Connection) *ServiceAccount

NewServiceAccount instantiates a new ServiceAccount.

func (*ServiceAccount) Fields

func (r *ServiceAccount) Fields(ns string) Row

Fields retrieves displayable fields.

func (*ServiceAccount) Header

func (*ServiceAccount) Header(ns string) Row

Header return resource header.

func (*ServiceAccount) Marshal

func (r *ServiceAccount) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*ServiceAccount) New

func (r *ServiceAccount) New(i interface{}) Columnar

New builds a new ServiceAccount instance from a k8s resource.

type StatefulSet

type StatefulSet struct {
	*Base
	// contains filtered or unexported fields
}

StatefulSet tracks a kubernetes resource.

func NewStatefulSet

func NewStatefulSet(c Connection) *StatefulSet

NewStatefulSet instantiates a new StatefulSet.

func (*StatefulSet) Fields

func (r *StatefulSet) Fields(ns string) Row

Fields retrieves displayable fields.

func (*StatefulSet) Header

func (*StatefulSet) Header(ns string) Row

Header return resource header.

func (*StatefulSet) Logs

func (r *StatefulSet) Logs(ctx context.Context, c chan<- string, opts LogOptions) error

Logs tail logs for all pods represented by this statefulset.

func (*StatefulSet) Marshal

func (r *StatefulSet) Marshal(path string) (string, error)

Marshal resource to yaml.

func (*StatefulSet) New

func (r *StatefulSet) New(i interface{}) Columnar

New builds a new StatefulSet instance from a k8s resource.

func (*StatefulSet) NumCols

func (*StatefulSet) NumCols(n string) map[string]bool

NumCols designates if column is numerical.

func (*StatefulSet) Scale

func (r *StatefulSet) Scale(ns, n string, replicas int32) error

Scale the specified resource.

type Switchable

type Switchable interface {
	Switch(ctx string) error
	MustCurrentContextName() string
}

Switchable represents a switchable resource.

type SwitchableCruder

type SwitchableCruder interface {
	Cruder
	Switchable
}

SwitchableCruder represents a resource that can be switched.

type TableData

type TableData struct {
	Header    Row
	Rows      RowEvents
	NumCols   map[string]bool
	Namespace string
}

TableData tracks a K8s resource for tabular display.

type Tailable

type Tailable interface {
	Logs(ctx context.Context, c chan<- string, opts LogOptions) error
}

Tailable represents a resource with tailable logs.

type TailableResource

type TailableResource interface {
	Resource
	Tailable
}

TailableResource is a resource that have tailable logs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL