common

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOutputFlags

func AddOutputFlags(cmd *cobra.Command, flags *OutputFlags)

AddOutputFlags adds output flags to a command

func AddPaginationFlags

func AddPaginationFlags(cmd *cobra.Command, flags *PaginationFlags, defaultLimit int32)

AddPaginationFlags adds pagination flags to a command

func AddSuggestFlags

func AddSuggestFlags(cmd *cobra.Command, flags *SuggestFlags)

AddSuggestFlags adds suggest flag to a command

func AddTimeRangeFlags

func AddTimeRangeFlags(cmd *cobra.Command, flags *TimeRangeFlags, defaultStart string)

AddTimeRangeFlags adds time range flags to a command

func CreatePrinter

func CreatePrinter(printFlags *genericclioptions.PrintFlags) (printers.ResourcePrinter, error)

CreatePrinter creates a printer based on output format

func CreateTablePrinter

func CreateTablePrinter(noHeaders bool) printers.ResourcePrinter

CreateTablePrinter creates a configured table printer for consistent table output

func EscapeCELString

func EscapeCELString(s string) string

EscapeCELString escapes single quotes in a string to make it safe for use in a CEL string literal. Single quotes are escaped by replacing ' with \' to prevent CEL filter injection attacks.

Example:

EscapeCELString("my-namespace") -> "my-namespace"
EscapeCELString("prod' || true || '") -> "prod\\' || true || \\'"

func EscapeFieldSelectorValue

func EscapeFieldSelectorValue(s string) (string, error)

EscapeFieldSelectorValue escapes special characters in a field selector value to prevent field selector injection. Field selectors use = and , as delimiters, so these must be escaped or rejected.

Example:

EscapeFieldSelectorValue("Normal") -> "Normal"
EscapeFieldSelectorValue("type=Warning") -> error

func IsDefaultOutputFormat

func IsDefaultOutputFormat(printFlags *genericclioptions.PrintFlags) bool

IsDefaultOutputFormat checks if using default (table) output

func PrintActivityFacets

func PrintActivityFacets(ctx context.Context, client *clientset.Clientset, field, startTime, endTime, filter string, out io.Writer) error

PrintActivityFacets executes and prints an activity facet query

func PrintAuditLogFacets

func PrintAuditLogFacets(ctx context.Context, client *clientset.Clientset, field, startTime, endTime, filter string, out io.Writer) error

PrintAuditLogFacets executes and prints an audit log facet query

func PrintEventFacets

func PrintEventFacets(ctx context.Context, client *clientset.Clientset, field, startTime, endTime string, out io.Writer) error

PrintEventFacets executes and prints an event facet query

func PrintFacetTable

func PrintFacetTable(facet activityv1alpha1.FacetResult, out io.Writer) error

PrintFacetTable prints a facet result as a table

func SupportsColor

func SupportsColor(out io.Writer) bool

SupportsColor checks if the output stream supports ANSI color codes

func ValidateEventType

func ValidateEventType(t string) error

ValidateEventType validates that an event type is one of the allowed values. Kubernetes only supports "Normal" and "Warning" event types.

Types

type OutputFlags

type OutputFlags struct {
	NoHeaders bool
	Debug     bool
}

OutputFlags contains common output flags

type PaginationFlags

type PaginationFlags struct {
	Limit         int32
	AllPages      bool
	ContinueAfter string
}

PaginationFlags contains common pagination flags

func (*PaginationFlags) Validate

func (f *PaginationFlags) Validate() error

Validate checks that pagination flags are valid

type SuggestFlags

type SuggestFlags struct {
	Suggest string
}

SuggestFlags contains facet query flags

func (*SuggestFlags) IsSuggestMode

func (f *SuggestFlags) IsSuggestMode() bool

IsSuggestMode returns true if suggest mode is active

type TablePrinter

type TablePrinter struct {
	PrintFlags *genericclioptions.PrintFlags
	IOStreams  genericclioptions.IOStreams
	NoHeaders  bool
}

TablePrinter wraps the Kubernetes table printer with helper methods

func NewTablePrinter

func NewTablePrinter(printFlags *genericclioptions.PrintFlags, ioStreams genericclioptions.IOStreams, noHeaders bool) *TablePrinter

NewTablePrinter creates a new table printer

func (*TablePrinter) PrintAllPagesInfo

func (p *TablePrinter) PrintAllPagesInfo(totalCount int)

PrintAllPagesInfo prints info about fetched results

func (*TablePrinter) PrintPaginationInfo

func (p *TablePrinter) PrintPaginationInfo(continueToken string, resultCount int)

PrintPaginationInfo prints pagination information to stderr

func (*TablePrinter) PrintTable

func (p *TablePrinter) PrintTable(table *metav1.Table) error

PrintTable prints a table to the output stream

type TimeRangeFlags

type TimeRangeFlags struct {
	StartTime string
	EndTime   string
}

TimeRangeFlags contains common time range flags

func (*TimeRangeFlags) Validate

func (f *TimeRangeFlags) Validate() error

Validate checks that time range flags are valid

Jump to

Keyboard shortcuts

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