tailer

package
v0.0.0-...-7aa9df5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RUNNING    = "running"
	WAITING    = "waiting"
	TERMINATED = "terminated"
)

Variables

This section is empty.

Functions

func DefaultSingleNamespaceTemplate

func DefaultSingleNamespaceTemplate() *template.Template

DefaultSingleNamespaceTemplate returns a printing template used when printing with colors and watching resources in a single namespace

func Run

func Run(ui *ui.UI, ctx context.Context, config *Config, cluster *kubernetes.Cluster) error

Run starts the log watching

func Watch

func Watch(ctx context.Context, i v1.PodInterface, podFilter *regexp.Regexp, containerFilter *regexp.Regexp, containerExcludeFilter *regexp.Regexp, containerState ContainerState, labelSelector labels.Selector) (chan *Target, chan *Target, error)

Watch starts listening to Kubernetes events and emits modified containers/pods. The first result is targets added, the second is targets removed

Types

type Config

type Config struct {
	Namespace             string           // Name of the namespace to monitor
	PodQuery              *regexp.Regexp   // Limit monitoring to pods matching the RE
	Timestamps            bool             // Print timestamps before each entry.
	ContainerQuery        *regexp.Regexp   // Limit monitoring to containers matching the RE
	ExcludeContainerQuery *regexp.Regexp   // Exclusion list if the above alone is not enough.
	ContainerState        ContainerState   // Limit monitoring to containers in this state.
	Exclude               []*regexp.Regexp // If specified suppress all log entries matching the RE
	Include               []*regexp.Regexp // If specified show only log entries matching this RE
	Since                 time.Duration    // Show only log entries younger than the duration.
	AllNamespaces         bool
	LabelSelector         labels.Selector
	TailLines             *int64
	Template              *template.Template // Template to apply to log entries for formatting
}

Config contains the config for stern

type ContainerState

type ContainerState string

func NewContainerState

func NewContainerState(stateConfig string) (ContainerState, error)

func (ContainerState) Match

func (stateConfig ContainerState) Match(containerState v1.ContainerState) bool

type Log

type Log struct {
	// Message is the log message itself
	Message string `json:"message"`

	// Namespace of the pod
	Namespace string `json:"namespace"`

	// PodName of the pod
	PodName string `json:"podName"`

	// Origin
	Origin string `json:"origin"`

	// ContainerName of the container
	ContainerName string `json:"containerName"`

	PodColor       *color.Color `json:"-"`
	ContainerColor *color.Color `json:"-"`
}

Log is the object which will be used together with the template to generate the output.

type Tail

type Tail struct {
	Namespace     string
	PodName       string
	Origin        string
	ContainerName string
	Options       *TailOptions
	// contains filtered or unexported fields
}

func NewTail

func NewTail(ui *ui.UI, namespace, podName, containerName string, tmpl *template.Template, options *TailOptions) *Tail

NewTail returns a new tail for a Kubernetes container inside a pod

func (*Tail) Close

func (t *Tail) Close()

Close stops tailing

func (*Tail) Print

func (t *Tail) Print(msg string)

Print prints a color coded log message with the pod and container names

func (*Tail) Start

func (t *Tail) Start(ctx context.Context, i v1.PodInterface)

Start starts tailing

type TailOptions

type TailOptions struct {
	Timestamps   bool
	SinceSeconds int64
	Exclude      []*regexp.Regexp
	Include      []*regexp.Regexp
	Namespace    bool
	TailLines    *int64
}

type Target

type Target struct {
	Namespace string
	Pod       string
	Container string
}

Target is a target to watch

func (*Target) GetID

func (t *Target) GetID() string

GetID returns the ID of the object

Jump to

Keyboard shortcuts

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