pepr

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pepr contains the logic monitoring Pepr operations in a UDS Cluster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidStreamFilter

func IsValidStreamFilter(kind StreamKind) bool

IsValidStreamFilter validates the stream kind

Types

type LogEntry

type LogEntry struct {
	Level     int    `json:"level"`
	Time      int64  `json:"time"`
	Pid       int    `json:"pid"`
	Hostname  string `json:"hostname"`
	Uid       string `json:"uid"`
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
	Res       struct {
		Uid     string `json:"uid"`
		Allowed bool   `json:"allowed"`
		Status  struct {
			Code    int    `json:"code"`
			Message string `json:"message"`
		} `json:"status"`
		// Patch and PatchType are only present for mutations
		Patch     *string `json:"patch,omitempty"`
		PatchType *string `json:"patchType,omitempty"`
	} `json:"res"`
	Msg string `json:"msg"`
	// Metadata is only present for operator logs
	Metadata *struct {
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	}
}

LogEntry represents a log entry from Pepr

type StreamKind

type StreamKind string

StreamKind represents the type of Pepr stream

const (
	// AnyStream represents all Pepr logs
	AnyStream StreamKind = ""
	// PolicyStream represents all Pepr admission controller logs
	PolicyStream StreamKind = "policies"
	// OperatorStream represents all UDS Operator logs
	OperatorStream StreamKind = "operator"
	// AllowStream represents all Pepr admission controller allow logs
	AllowStream StreamKind = "allowed"
	// DenyStream represents all Pepr admission controller deny logs
	DenyStream StreamKind = "denied"
	// MutateStream represents all Pepr admission controller mutation logs
	MutateStream StreamKind = "mutated"
	// FailureStream represents all admission controller deny logs and operator failure logs
	FailureStream StreamKind = "failed"
)

type StreamReader

type StreamReader struct {
	JSON         bool
	Web          bool
	FilterStream StreamKind
	// contains filtered or unexported fields
}

func NewStreamReader

func NewStreamReader(filterNamespace, filterName string) *StreamReader

NewStreamReader creates a new PeprStreamReader

func (*StreamReader) LogFlush

func (p *StreamReader) LogFlush(writer io.Writer)

LogFlush write any remaining repeated events to the writer

func (*StreamReader) LogStream

func (p *StreamReader) LogStream(writer io.Writer, logStream io.ReadCloser, timestamp bool) error

LogStream processes the log stream from Pepr and writes formatted output to the writer

func (*StreamReader) PodFilter

func (p *StreamReader) PodFilter(pods []corev1.Pod) map[string]string

PodFilter creates a map of pod and container names to pull logs from

Jump to

Keyboard shortcuts

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