dao

package
v0.25.9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0, Apache-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const CRD = "crd"

CRD identifies a CRD.

Variables

View Source
var ItemEOF = new(LogItem)
View Source
var MetaAccess = NewMeta()

MetaAccess tracks resources metadata.

View Source
var RestMapping = &RestMapper{}

RestMapping holds k8s resource mapping.

Functions

func BenchConfigFor added in v0.15.2

func BenchConfigFor(benchFile, path string) config.BenchConfig

BenchConfigFor returns a custom bench spec if defined otherwise returns the default one.

func Describe

func Describe(c client.Connection, gvr client.GVR, path string) (string, error)

Describe describes a resource.

func FQN

func FQN(ns, n string) string

FQN returns a fully qualified resource name.

func FetchNode added in v0.17.6

func FetchNode(ctx context.Context, f Factory, path string) (*v1.Node, error)

FetchNode retrieves a node.

func FetchNodes

func FetchNodes(ctx context.Context, f Factory, labelsSel string) (*v1.NodeList, error)

FetchNodes retrieves all nodes.

func GetDefaultLogContainer added in v0.24.11

func GetDefaultLogContainer(m metav1.ObjectMeta, spec v1.PodSpec) (string, bool)

GetDefaultLogContainer returns a container name if specified in an annotation.

func GetJsonPatch added in v0.23.0

func GetJsonPatch(imageSpecs ImageSpecs) ([]byte, error)

GetJsonPatch returns container image patch.

func GetTemplateJsonPatch added in v0.23.0

func GetTemplateJsonPatch(imageSpecs ImageSpecs) ([]byte, error)

GetTemplateJsonPatch builds a json patch string to update PodSpec images.

func IsCRD added in v0.24.15

func IsCRD(r v1.APIResource) bool

IsCRD checks if resource represents a CRD

func IsFuzzySelector added in v0.18.0

func IsFuzzySelector(s string) bool

IsFuzzySelector checks if filter is fuzzy or not.

func IsInverseSelector added in v0.23.2

func IsInverseSelector(s string) bool

IsInverseSelector checks if inverse char has been provided.

func IsK8sMeta

func IsK8sMeta(m metav1.APIResource) bool

IsK8sMeta checks for non resource meta.

func IsK9sMeta

func IsK9sMeta(m metav1.APIResource) bool

IsK9sMeta checks for non resource meta.

func MetaFQN

func MetaFQN(m metav1.ObjectMeta) string

MetaFQN returns a fully qualified resource name.

func PodToKey added in v0.15.2

func PodToKey(path string) string

PodToKey converts a pod path to a generic bench config key.

func PortForwardID added in v0.15.2

func PortForwardID(path, co, portMap string) string

PortForwardID computes port-forward identifier.

func SanitizeFilename added in v0.24.8

func SanitizeFilename(name string) string

SanitizeFilename sanitizes the dump filename.

func ToYAML

func ToYAML(o runtime.Object, showManaged bool) (string, error)

ToYAML converts a resource to its YAML representation.

func Truncate

func Truncate(str string, width int) string

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

Types

type Accessor

type Accessor interface {
	Lister
	Getter

	// Init the resource with a factory object.
	Init(Factory, client.GVR)

	// GVR returns a gvr a string.
	GVR() string
}

Accessor represents an accessible k8s resource.

func AccessorFor

func AccessorFor(f Factory, gvr client.GVR) (Accessor, error)

AccessorFor returns a client accessor for a resource if registered. Otherwise it returns a generic accessor. Customize here for non resource types or types with metrics or logs.

type Accessors

type Accessors map[client.GVR]Accessor

Accessors represents a collection of dao accessors.

type Alias

type Alias struct {
	NonResource
	*config.Aliases
}

Alias tracks standard and custom command aliases.

func NewAlias

func NewAlias(f Factory) *Alias

NewAlias returns a new set of aliases.

func (*Alias) AsGVR

func (a *Alias) AsGVR(cmd string) (client.GVR, bool)

AsGVR returns a matching gvr if it exists.

func (*Alias) Check added in v0.13.4

func (a *Alias) Check(cmd string) bool

Check verifies an alias is defined for this command.

func (*Alias) Ensure

func (a *Alias) Ensure() (config.Alias, error)

Ensure makes sure alias are loaded.

func (*Alias) Get

func (a *Alias) Get(_ context.Context, _ string) (runtime.Object, error)

Get fetch a resource.

func (*Alias) List

func (a *Alias) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of aliases.

type Benchmark

type Benchmark struct {
	NonResource
}

Benchmark represents a benchmark resource.

func (*Benchmark) Delete

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

Delete nukes a resource.

func (*Benchmark) Get

Get returns a resource.

func (*Benchmark) List

func (b *Benchmark) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of resources.

type Container

type Container struct {
	NonResource
}

Container represents a pod's container dao.

func (*Container) List

func (c *Container) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of containers.

func (*Container) TailLogs

func (c *Container) TailLogs(ctx context.Context, logChan LogChan, opts *LogOptions) error

TailLogs tails a given container logs.

type ContainsPodSpec added in v0.23.0

type ContainsPodSpec interface {
	// Get PodSpec of a resource
	GetPodSpec(path string) (*v1.PodSpec, error)

	// Set Images for a resource
	SetImages(ctx context.Context, path string, imageSpecs ImageSpecs) error
}

ContainsPodSpec represents a resource with a pod template.

type Context

type Context struct {
	NonResource
}

Context represents a kubernetes context.

func (*Context) Get

func (c *Context) Get(ctx context.Context, path string) (runtime.Object, error)

Get a Context.

func (*Context) List

func (c *Context) List(_ context.Context, _ string) ([]runtime.Object, error)

List all Contexts on the current cluster.

func (*Context) MustCurrentContextName

func (c *Context) MustCurrentContextName() string

MustCurrentContextName return the active context name.

func (*Context) Switch

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

Switch to another context.

type Controller added in v0.15.2

type Controller interface {
	// Pod returns a pod instance matching the selector.
	Pod(path string) (string, error)
}

Controller represents a pod controller.

type CronJob

type CronJob struct {
	Generic
}

CronJob represents a cronjob K8s resource.

func (*CronJob) Run

func (c *CronJob) Run(path string) error

Run a CronJob.

func (*CronJob) Scan added in v0.20.0

func (c *CronJob) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for cluster resource refs.

func (*CronJob) ScanSA added in v0.20.0

func (c *CronJob) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for serviceaccount refs.

func (*CronJob) ToggleSuspend added in v0.24.3

func (c *CronJob) ToggleSuspend(ctx context.Context, path string) error

ToggleSuspend toggles suspend/resume on a CronJob.

type CustomResourceDefinition

type CustomResourceDefinition struct {
	Resource
}

CustomResourceDefinition represents a CRD resource model.

func (*CustomResourceDefinition) List

List returns a collection of nodes.

type DaemonSet

type DaemonSet struct {
	Resource
}

DaemonSet represents a K8s daemonset.

func (*DaemonSet) GetInstance added in v0.15.2

func (d *DaemonSet) GetInstance(fqn string) (*appsv1.DaemonSet, error)

GetInstance returns a daemonset instance.

func (*DaemonSet) GetPodSpec added in v0.23.0

func (d *DaemonSet) GetPodSpec(path string) (*v1.PodSpec, error)

GetPodSpec returns a pod spec given a resource.

func (*DaemonSet) IsHappy added in v0.16.0

func (d *DaemonSet) IsHappy(ds appsv1.DaemonSet) bool

IsHappy check for happy deployments.

func (*DaemonSet) Pod added in v0.15.2

func (d *DaemonSet) Pod(fqn string) (string, error)

Pod returns a pod victim by name.

func (*DaemonSet) Restart

func (d *DaemonSet) Restart(ctx context.Context, path string) error

Restart a DaemonSet rollout.

func (*DaemonSet) Scan added in v0.20.0

func (d *DaemonSet) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for cluster refs.

func (*DaemonSet) ScanSA added in v0.20.0

func (d *DaemonSet) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for serviceaccount refs.

func (*DaemonSet) SetImages added in v0.23.0

func (d *DaemonSet) SetImages(ctx context.Context, path string, imageSpecs ImageSpecs) error

SetImages sets container images.

func (*DaemonSet) TailLogs

func (d *DaemonSet) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error

TailLogs tail logs for all pods represented by this DaemonSet.

type Deployment

type Deployment struct {
	Resource
}

Deployment represents a deployment K8s resource.

func (*Deployment) GetPodSpec added in v0.23.0

func (d *Deployment) GetPodSpec(path string) (*v1.PodSpec, error)

GetPodSpec returns a pod spec given a resource.

func (*Deployment) IsHappy added in v0.16.0

func (d *Deployment) IsHappy(dp appsv1.Deployment) bool

IsHappy check for happy deployments.

func (*Deployment) Load added in v0.17.0

func (*Deployment) Load(f Factory, fqn string) (*appsv1.Deployment, error)

Load returns a deployment instance.

func (*Deployment) Pod added in v0.15.2

func (d *Deployment) Pod(fqn string) (string, error)

Pod returns a pod victim by name.

func (*Deployment) Restart

func (d *Deployment) Restart(ctx context.Context, path string) error

Restart a Deployment rollout.

func (*Deployment) Scale

func (d *Deployment) Scale(ctx context.Context, path string, replicas int32) error

Scale a Deployment.

func (*Deployment) Scan added in v0.20.0

func (d *Deployment) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for resource references.

func (*Deployment) ScanSA added in v0.20.0

func (d *Deployment) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for serviceaccount refs.

func (*Deployment) SetImages added in v0.23.0

func (d *Deployment) SetImages(ctx context.Context, path string, imageSpecs ImageSpecs) error

SetImages sets container images.

func (*Deployment) TailLogs

func (d *Deployment) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error

TailLogs tail logs for all pods represented by this Deployment.

type Describer

type Describer interface {
	// Describe describes a resource.
	Describe(path string) (string, error)

	// ToYAML dumps a resource to YAML.
	ToYAML(path string, showManaged bool) (string, error)
}

Describer describes a resource.

type Dir added in v0.21.0

type Dir struct {
	NonResource
}

Dir tracks standard and custom command aliases.

func NewDir added in v0.21.0

func NewDir(f Factory) *Dir

NewDir returns a new set of aliases.

func (*Dir) Get added in v0.21.0

func (a *Dir) Get(_ context.Context, _ string) (runtime.Object, error)

Get fetch a resource.

func (*Dir) List added in v0.21.0

func (a *Dir) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of aliases.

type DrainOptions added in v0.17.6

type DrainOptions struct {
	GracePeriodSeconds  int
	Timeout             time.Duration
	IgnoreAllDaemonSets bool
	DeleteEmptyDirData  bool
	Force               bool
}

DrainOptions tracks drain attributes.

type Element added in v0.23.0

type Element struct {
	Image string `json:"image,omitempty"`
	Name  string `json:"name"`
}

Element tracks a given container image.

type Factory

type Factory interface {
	// Client retrieves an api client.
	Client() client.Connection

	// Get fetch a given resource.
	Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error)

	// List fetch a collection of resources.
	List(gvr, ns string, wait bool, sel labels.Selector) ([]runtime.Object, error)

	// ForResource fetch an informer for a given resource.
	ForResource(ns, gvr string) (informers.GenericInformer, error)

	// CanForResource fetch an informer for a given resource if authorized
	CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error)

	// WaitForCacheSync synchronize the cache.
	WaitForCacheSync()

	// DeleteForwarder deletes a pod forwarder.
	DeleteForwarder(path string)

	// Forwards returns all portforwards.
	Forwarders() watch.Forwarders
}

Factory represents a resource factory.

type Generic

type Generic struct {
	NonResource
}

Generic represents a generic resource.

func (*Generic) Delete

func (g *Generic) Delete(path string, cascade, force bool) error

Delete deletes a resource.

func (*Generic) Describe

func (g *Generic) Describe(path string) (string, error)

Describe describes a resource.

func (*Generic) Get

func (g *Generic) Get(ctx context.Context, path string) (runtime.Object, error)

Get returns a given resource.

func (*Generic) List

func (g *Generic) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of resources. BOZO!! no auth check??

func (*Generic) ToYAML

func (g *Generic) ToYAML(path string, showManaged bool) (string, error)

ToYAML returns a resource yaml.

type Getter

type Getter interface {
	// Get return a given resource.
	Get(ctx context.Context, path string) (runtime.Object, error)
}

Getter represents a resource getter.

type Helm added in v0.19.3

type Helm struct {
	NonResource
}

Helm represents a helm chart.

func (*Helm) Delete added in v0.19.3

func (c *Helm) Delete(path string, cascade, force bool) error

Delete uninstall a Helm.

func (*Helm) Describe added in v0.19.3

func (c *Helm) Describe(path string) (string, error)

Describe returns the chart notes.

func (*Helm) EnsureHelmConfig added in v0.19.3

func (c *Helm) EnsureHelmConfig(ns string) (*action.Configuration, error)

EnsureHelmConfig return a new configuration.

func (*Helm) Get added in v0.19.3

func (c *Helm) Get(_ context.Context, path string) (runtime.Object, error)

Get returns a resource.

func (*Helm) List added in v0.19.3

func (c *Helm) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of resources.

func (*Helm) ToYAML added in v0.19.3

func (c *Helm) ToYAML(path string, showManaged bool) (string, error)

ToYAML returns the chart manifest.

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	Resource
}

HorizontalPodAutoscaler represents a HPA resource model.

func (*HorizontalPodAutoscaler) List

List returns a collection of nodes.

type ImageSpec added in v0.23.0

type ImageSpec struct {
	Index             int
	Name, DockerImage string
	Init              bool
}

ImageSpec represents a container image.

type ImageSpecs added in v0.23.0

type ImageSpecs []ImageSpec

ImageSpecs represents a collection of container images.

type ImagesSpec added in v0.23.0

type ImagesSpec struct {
	SetElementOrderContainers     []Element `json:"$setElementOrder/containers,omitempty"`
	SetElementOrderInitContainers []Element `json:"$setElementOrder/initContainers,omitempty"`
	Containers                    []Element `json:"containers,omitempty"`
	InitContainers                []Element `json:"initContainers,omitempty"`
}

ImagesSpec tracks container image updates.

type Job

type Job struct {
	Resource
}

Job represents a K8s job resource.

func (*Job) List added in v0.21.3

func (j *Job) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of resources.

func (*Job) Scan added in v0.20.0

func (j *Job) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for resource references.

func (*Job) ScanSA added in v0.20.0

func (j *Job) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for serviceaccount refs.

func (*Job) TailLogs

func (j *Job) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error

TailLogs tail logs for all pods represented by this Job.

type JsonPatch added in v0.23.0

type JsonPatch struct {
	Spec Spec `json:"spec"`
}

JsonPatch track pod spec updates.

type Lister

type Lister interface {
	// List returns a resource collection.
	List(ctx context.Context, ns string) ([]runtime.Object, error)
}

Lister represents a resource lister.

type LogChan added in v0.18.0

type LogChan chan *LogItem

LogChan represents a channel for logs.

type LogItem added in v0.18.0

type LogItem struct {
	Pod, Container  string
	SingleContainer bool
	Bytes           []byte
}

LogItem represents a container log line.

func NewLogItem added in v0.18.0

func NewLogItem(bb []byte) *LogItem

NewLogItem returns a new item.

func NewLogItemFromString added in v0.18.0

func NewLogItemFromString(s string) *LogItem

NewLogItemFromString returns a new item.

func (*LogItem) GetTimestamp added in v0.25.0

func (l *LogItem) GetTimestamp() string

GetTimestamp fetch log lime timestamp

func (*LogItem) ID added in v0.18.1

func (l *LogItem) ID() string

ID returns pod and or container based id.

func (*LogItem) Info added in v0.18.1

func (l *LogItem) Info() string

Info returns pod and container information.

func (*LogItem) IsEmpty added in v0.18.0

func (l *LogItem) IsEmpty() bool

IsEmpty checks if the entry is empty.

func (*LogItem) Render added in v0.18.0

func (l *LogItem) Render(paint string, showTime bool, bb *bytes.Buffer)

Render returns a log line as string.

func (*LogItem) Size added in v0.25.0

func (l *LogItem) Size() int

Size returns the size of the item.

type LogItems added in v0.18.0

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

LogItems represents a collection of log items.

func NewLogItems added in v0.24.11

func NewLogItems() *LogItems

NewLogItems returns a new instance.

func (*LogItems) Add added in v0.24.11

func (l *LogItems) Add(ii ...*LogItem)

Add augments the items.

func (*LogItems) Clear added in v0.24.11

func (l *LogItems) Clear()

Clear removes all items.

func (*LogItems) DumpDebug added in v0.18.0

func (l *LogItems) DumpDebug(m string)

DumpDebug for debugging.

func (*LogItems) Filter added in v0.18.0

func (l *LogItems) Filter(index int, q string, showTime bool) ([]int, [][]int, error)

Filter filters out log items based on given filter.

func (*LogItems) Items added in v0.24.11

func (l *LogItems) Items() []*LogItem

Items returns the log items.

func (*LogItems) Len added in v0.24.11

func (l *LogItems) Len() int

Len returns the items length.

func (*LogItems) Lines added in v0.18.0

func (l *LogItems) Lines(index int, showTime bool, ll [][]byte)

Lines returns a collection of log lines.

func (*LogItems) Merge added in v0.24.11

func (l *LogItems) Merge(n *LogItems)

Merge merges two logitems list.

func (*LogItems) Render added in v0.18.0

func (l *LogItems) Render(index int, showTime bool, ll [][]byte)

Render returns logs as a collection of strings.

func (*LogItems) Shift added in v0.24.11

func (l *LogItems) Shift(i *LogItem)

Shift scrolls the lines by one.

func (*LogItems) StrLines added in v0.23.0

func (l *LogItems) StrLines(index int, showTime bool) []string

StrLines returns a collection of log lines.

func (*LogItems) Subset added in v0.24.11

func (l *LogItems) Subset(index int) *LogItems

Subset return a subset of logitems.

type LogOptions

type LogOptions struct {
	CreateDuration   time.Duration
	Path             string
	Container        string
	DefaultContainer string
	SinceTime        string
	Lines            int64
	SinceSeconds     int64
	Head             bool
	Previous         bool
	SingleContainer  bool
	MultiPods        bool
	ShowTimestamp    bool
	AllContainers    bool
}

LogOptions represents logger options.

func (*LogOptions) Clone added in v0.24.11

func (o *LogOptions) Clone() *LogOptions

Clone clones options.

func (*LogOptions) DecorateLog

func (o *LogOptions) DecorateLog(bytes []byte) *LogItem

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

func (*LogOptions) HasContainer

func (o *LogOptions) HasContainer() bool

HasContainer checks if a container is present.

func (*LogOptions) Info added in v0.18.1

func (o *LogOptions) Info() string

Info returns the option pod and container info.

func (*LogOptions) ToPodLogOptions added in v0.18.0

func (o *LogOptions) ToPodLogOptions() *v1.PodLogOptions

ToPodLogOptions returns pod log options.

func (*LogOptions) ToggleAllContainers added in v0.24.11

func (o *LogOptions) ToggleAllContainers()

ToggleAllContainers toggles single or all-containers if possible.

type Loggable

type Loggable interface {
	// TaiLogs streams resource logs.
	TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error
}

Loggable represents resources with logs.

type Logger

type Logger interface {
	// Logs tails a resource logs.
	Logs(path string, opts *v1.PodLogOptions) (*restclient.Request, error)
}

Logger represents a resource that exposes logs.

type Meta added in v0.13.8

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

Meta represents available resource metas.

func NewMeta added in v0.13.8

func NewMeta() *Meta

NewMeta returns a resource meta.

func (*Meta) AllGVRs added in v0.13.8

func (m *Meta) AllGVRs() client.GVRs

AllGVRs returns all cluster resources.

func (*Meta) LoadResources added in v0.13.8

func (m *Meta) LoadResources(f Factory) error

LoadResources hydrates server preferred+CRDs resource metadata.

func (*Meta) MetaFor added in v0.13.8

func (m *Meta) MetaFor(gvr client.GVR) (metav1.APIResource, error)

MetaFor returns a resource metadata for a given gvr.

func (*Meta) RegisterMeta added in v0.13.8

func (m *Meta) RegisterMeta(gvr string, res metav1.APIResource)

RegisterMeta registers a new resource meta object.

type Node

type Node struct {
	Resource
}

Node represents a node model.

func (*Node) CountPods added in v0.21.4

func (n *Node) CountPods(nodeName string) (int, error)

CountPods counts the pods scheduled on a given node.

func (*Node) Drain added in v0.17.6

func (n *Node) Drain(path string, opts DrainOptions, w io.Writer) error

Drain drains a node.

func (*Node) Get added in v0.17.6

func (n *Node) Get(ctx context.Context, path string) (runtime.Object, error)

Get returns a node resource.

func (*Node) GetPods added in v0.23.0

func (n *Node) GetPods(nodeName string) ([]*v1.Pod, error)

GetPods returns all pods running on given node.

func (*Node) List

func (n *Node) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of node resources.

func (*Node) ToggleCordon added in v0.17.6

func (n *Node) ToggleCordon(path string, cordon bool) error

ToggleCordon toggles cordon/uncordon a node.

type NodeMaintainer added in v0.17.6

type NodeMaintainer interface {
	// ToggleCordon toggles cordon/uncordon a node.
	ToggleCordon(path string, cordon bool) error

	// Drain drains the given node.
	Drain(path string, opts DrainOptions, w io.Writer) error
}

NodeMaintainer performs node maintenance operations.

type NodeMetricsFunc

type NodeMetricsFunc func() (*mv1beta1.NodeMetricsList, error)

NodeMetricsFunc retrieves node metrics.

type NonResource

type NonResource struct {
	Factory
	// contains filtered or unexported fields
}

NonResource represents a non k8s resource.

func (*NonResource) GVR

func (n *NonResource) GVR() string

GVR returns a gvr.

func (*NonResource) Get

Get returns the given resource.

func (*NonResource) Init

func (n *NonResource) Init(f Factory, gvr client.GVR)

Init initializes the resource.

type Nuker

type Nuker interface {
	// Delete removes a resource from the api server.
	Delete(path string, cascade, force bool) error
}

Nuker represents a resource deleter.

type Pod

type Pod struct {
	Resource
}

Pod represents a pod resource.

func (*Pod) Containers

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

Containers returns all container names on pod.

func (*Pod) Get

func (p *Pod) Get(ctx context.Context, path string) (runtime.Object, error)

Get returns a resource instance if found, else an error.

func (*Pod) GetInstance added in v0.15.2

func (p *Pod) GetInstance(fqn string) (*v1.Pod, error)

GetInstance returns a pod instance.

func (*Pod) GetPodSpec added in v0.23.0

func (p *Pod) GetPodSpec(path string) (*v1.PodSpec, error)

GetPodSpec returns a pod spec given a resource.

func (*Pod) IsHappy added in v0.16.0

func (p *Pod) IsHappy(po v1.Pod) bool

IsHappy check for happy deployments.

func (*Pod) List

func (p *Pod) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of nodes.

func (*Pod) Logs

func (p *Pod) Logs(path string, opts *v1.PodLogOptions) (*restclient.Request, error)

Logs fetch container logs for a given pod and container.

func (*Pod) Pod added in v0.15.2

func (p *Pod) Pod(fqn string) (string, error)

Pod returns a pod victim by name.

func (*Pod) Scan added in v0.20.0

func (p *Pod) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for cluster resource refs.

func (*Pod) ScanSA added in v0.20.0

func (p *Pod) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for ServiceAccount refs.

func (*Pod) SetImages added in v0.23.0

func (p *Pod) SetImages(ctx context.Context, path string, imageSpecs ImageSpecs) error

SetImages sets container images.

func (*Pod) TailLogs

func (p *Pod) TailLogs(ctx context.Context, out LogChan, opts *LogOptions) error

TailLogs tails a given container logs.

type PodSpec added in v0.23.0

type PodSpec struct {
	Spec ImagesSpec `json:"spec"`
}

PodSpec represents a collection of container images.

type Policy

type Policy struct {
	Resource
}

Policy represent rbac policy.

func (*Policy) List

func (p *Policy) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns available policies.

type Popeye added in v0.19.0

type Popeye struct {
	NonResource
}

Popeye tracks cluster sanitization.

func NewPopeye added in v0.19.0

func NewPopeye(f Factory) *Popeye

NewPopeye returns a new set of aliases.

func (*Popeye) Get added in v0.19.0

func (p *Popeye) Get(_ context.Context, _ string) (runtime.Object, error)

Get retrieves a resource.

func (*Popeye) List added in v0.19.0

func (p *Popeye) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of aliases.

type PortForward

type PortForward struct {
	NonResource
}

PortForward represents a port forward dao.

func (*PortForward) Delete

func (p *PortForward) Delete(path string, cascade, force bool) error

Delete a portforward.

func (*PortForward) List

func (p *PortForward) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of port forwards.

type PortForwarder

type PortForwarder struct {
	Factory
	genericclioptions.IOStreams
	// contains filtered or unexported fields
}

PortForwarder tracks a port forward stream.

func NewPortForwarder

func NewPortForwarder(f Factory) *PortForwarder

NewPortForwarder returns a new port forward streamer.

func (*PortForwarder) Active

func (p *PortForwarder) Active() bool

Active returns the forward status.

func (*PortForwarder) Age

func (p *PortForwarder) Age() string

Age returns the port forward age.

func (*PortForwarder) Container

func (p *PortForwarder) Container() string

Container returns the target's container.

func (*PortForwarder) ContainerPort added in v0.25.0

func (p *PortForwarder) ContainerPort() string

ContainerPort returns the container port.

func (*PortForwarder) FQN

func (p *PortForwarder) FQN() string

FQN returns the portforward unique id.

func (*PortForwarder) HasPortMapping added in v0.15.2

func (p *PortForwarder) HasPortMapping(portMap string) bool

HasPortMapping checks if port mapping is defined for this fwd.

func (*PortForwarder) ID added in v0.25.0

func (p *PortForwarder) ID() string

ID returns a pf id.

func (*PortForwarder) LocalPort added in v0.25.0

func (p *PortForwarder) LocalPort() string

LocalPort returns the local port.

func (*PortForwarder) Path

func (p *PortForwarder) Path() string

Path returns the pod resource path.

func (*PortForwarder) Port added in v0.25.0

func (p *PortForwarder) Port() string

Port returns the port mapping.

func (*PortForwarder) SetActive

func (p *PortForwarder) SetActive(b bool)

SetActive mark a portforward as active.

func (*PortForwarder) Start

Start initiates a port forward session for a given pod and ports.

func (*PortForwarder) Stop

func (p *PortForwarder) Stop()

Stop terminates a port forward.

type Pulse added in v0.16.0

type Pulse struct {
	NonResource
}

Pulse tracks pulses.

func (*Pulse) List added in v0.16.0

func (h *Pulse) List(ctx context.Context, ns string) ([]runtime.Object, error)

List lists out pulses.

type Rbac

type Rbac struct {
	Resource
}

Rbac represents a model for listing rbac resources.

func (*Rbac) List

func (r *Rbac) List(ctx context.Context, ns string) ([]runtime.Object, error)

List lists out rbac resources.

type Ref added in v0.20.0

type Ref struct {
	GVR string
	FQN string
}

Ref represents a resource reference.

type RefScanner added in v0.20.0

type RefScanner interface {
	// Init initializes the scanner
	Init(Factory, client.GVR)
	// Scan scan the resource for references.
	Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)
	ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)
}

RefScanner represents a resource reference scanner.

type Reference added in v0.20.0

type Reference struct {
	NonResource
}

Reference represents cluster resource references.

func (*Reference) Get added in v0.20.0

func (r *Reference) Get(ctx context.Context, path string) (runtime.Object, error)

Get fetch a given reference.

func (*Reference) List added in v0.20.0

func (r *Reference) List(ctx context.Context, ns string) ([]runtime.Object, error)

List collects all references.

func (*Reference) Scan added in v0.20.0

func (r *Reference) Scan(ctx context.Context) ([]runtime.Object, error)

Scan scan cluster resources for references.

func (*Reference) ScanSA added in v0.20.0

func (r *Reference) ScanSA(ctx context.Context) ([]runtime.Object, error)

ScanSA scans for serviceaccount refs.

type Refs added in v0.20.0

type Refs []Ref

Refs represents a collection of resource references.

func ScanForRefs added in v0.20.0

func ScanForRefs(ctx context.Context, f Factory) (Refs, error)

ScanForRefs scans cluster resources for resource references.

func ScanForSARefs added in v0.20.0

func ScanForSARefs(ctx context.Context, f Factory) (Refs, error)

ScanForSARefs scans cluster resources for serviceaccount refs.

type ReplicaSet added in v0.16.0

type ReplicaSet struct {
	Resource
}

ReplicaSet represents a replicaset K8s resource.

func (*ReplicaSet) Load added in v0.17.0

func (r *ReplicaSet) Load(f Factory, path string) (*v1.ReplicaSet, error)

Load returns a given instance.

func (*ReplicaSet) Rollback added in v0.17.0

func (r *ReplicaSet) Rollback(fqn string) error

Rollback reverses the last deployment.

type Resource

type Resource struct {
	Generic
}

Resource represents an informer based resource.

func (*Resource) Get

func (r *Resource) Get(_ context.Context, path string) (runtime.Object, error)

Get returns a resource instance if found, else an error.

func (*Resource) List

func (r *Resource) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of resources.

func (*Resource) ToYAML

func (r *Resource) ToYAML(path string, showManaged bool) (string, error)

ToYAML returns a resource yaml.

type ResourceMetas

type ResourceMetas map[client.GVR]metav1.APIResource

ResourceMetas represents a collection of resource metadata.

type RestMapper

type RestMapper struct {
	client.Connection
}

RestMapper map resource to REST mapping ie kind, group, version.

func (*RestMapper) Name

func (*RestMapper) Name() meta.RESTScopeName

Name protocol returns rest scope name.

func (*RestMapper) ResourceFor

func (r *RestMapper) ResourceFor(resourceArg, kind string) (*meta.RESTMapping, error)

ResourceFor produces a rest mapping from a given resource. Support full res name ie deployment.v1.apps.

func (*RestMapper) ToRESTMapper

func (r *RestMapper) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper map resources to kind, and map kind and version to interfaces for manipulating K8s objects.

type Restartable

type Restartable interface {
	// Restart performs a rollout restart.
	Restart(ctx context.Context, path string) error
}

Restartable represents a restartable resource.

type Runnable

type Runnable interface {
	// Run triggers a run.
	Run(path string) error
}

Runnable represents a runnable resource.

type Scalable

type Scalable interface {
	// Scale scales a resource up or down.
	Scale(ctx context.Context, path string, replicas int32) error
}

Scalable represents resources that can scale.

type ScreenDump

type ScreenDump struct {
	NonResource
}

ScreenDump represents a scraped resources.

func (*ScreenDump) Delete

func (d *ScreenDump) Delete(path string, cascade, force bool) error

Delete a ScreenDump.

func (*ScreenDump) List

func (d *ScreenDump) List(ctx context.Context, _ string) ([]runtime.Object, error)

List returns a collection of screen dumps.

type Service

type Service struct {
	Resource
}

Service represents a k8s service.

func (*Service) GetInstance added in v0.15.2

func (s *Service) GetInstance(fqn string) (*v1.Service, error)

GetInstance returns a service instance.

func (*Service) Pod added in v0.15.2

func (s *Service) Pod(fqn string) (string, error)

Pod returns a pod victim by name.

func (*Service) TailLogs

func (s *Service) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error

TailLogs tail logs for all pods represented by this Service.

type Spec added in v0.23.0

type Spec struct {
	Template PodSpec `json:"template"`
}

Spec represents a pod template.

type StatefulSet

type StatefulSet struct {
	Resource
}

StatefulSet represents a K8s sts.

func (*StatefulSet) GetPodSpec added in v0.23.0

func (s *StatefulSet) GetPodSpec(path string) (*v1.PodSpec, error)

GetPodSpec returns a pod spec given a resource.

func (*StatefulSet) IsHappy added in v0.16.0

func (s *StatefulSet) IsHappy(sts appsv1.StatefulSet) bool

IsHappy check for happy sts.

func (*StatefulSet) Load added in v0.24.11

func (*StatefulSet) Load(f Factory, fqn string) (*appsv1.StatefulSet, error)

Load returns a statefulset instance.

func (*StatefulSet) Pod added in v0.15.2

func (s *StatefulSet) Pod(fqn string) (string, error)

Pod returns a pod victim by name.

func (*StatefulSet) Restart

func (s *StatefulSet) Restart(ctx context.Context, path string) error

Restart a StatefulSet rollout.

func (*StatefulSet) Scale

func (s *StatefulSet) Scale(ctx context.Context, path string, replicas int32) error

Scale a StatefulSet.

func (*StatefulSet) Scan added in v0.20.0

func (s *StatefulSet) Scan(ctx context.Context, gvr, fqn string, wait bool) (Refs, error)

Scan scans for cluster resource refs.

func (*StatefulSet) ScanSA added in v0.20.0

func (s *StatefulSet) ScanSA(ctx context.Context, fqn string, wait bool) (Refs, error)

ScanSA scans for serviceaccount refs.

func (*StatefulSet) SetImages added in v0.23.0

func (s *StatefulSet) SetImages(ctx context.Context, path string, imageSpecs ImageSpecs) error

SetImages sets container images.

func (*StatefulSet) TailLogs

func (s *StatefulSet) TailLogs(ctx context.Context, c LogChan, opts *LogOptions) error

TailLogs tail logs for all pods represented by this StatefulSet.

type Subject

type Subject struct {
	Resource
}

Subject represents a subject model.

func (*Subject) List

func (s *Subject) List(ctx context.Context, ns string) ([]runtime.Object, error)

List returns a collection of subjects.

type Switchable

type Switchable interface {
	// Switch changes the active context.
	Switch(ctx string) error
}

Switchable represents a switchable resource.

type Table

type Table struct {
	Generic
}

Table retrieves K8s resources as tabular data.

func (*Table) Get

func (t *Table) Get(ctx context.Context, path string) (runtime.Object, error)

Get returns a given resource.

func (*Table) List

func (t *Table) List(ctx context.Context, ns string) ([]runtime.Object, error)

List all Resources in a given namespace.

Jump to

Keyboard shortcuts

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