Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureFullPath(path string, mod os.FileMode)
- func EnsurePath(path string, mod os.FileMode)
- func InList(ll []string, n string) bool
- func IsBoolSet(b *bool) bool
- func MustW2User() string
- func W2Home() string
- type Alias
- type Aliases
- func (a *Aliases) Clear()
- func (a *Aliases) Define(gvr string, aliases ...string)
- func (a *Aliases) Get(k string) (string, bool)
- func (a *Aliases) Keys() []string
- func (a *Aliases) Load() error
- func (a *Aliases) LoadFileAliases(path string) error
- func (a *Aliases) Save() error
- func (a *Aliases) SaveAliases(path string) error
- func (a *Aliases) ShortNames() ShortNames
- type Auth
- type Bench
- type BenchConfig
- type Benchmark
- type Benchmarks
- type Body
- type Border
- type Charts
- type Cluster
- type Color
- type Colors
- type Config
- func (c *Config) ActiveNamespace() string
- func (c *Config) ActiveView() string
- func (c *Config) Dump(msg string)
- func (c *Config) FavNamespaces() []string
- func (c *Config) Load(path string) error
- func (c *Config) Refine() error
- func (c *Config) Save() error
- func (c *Config) SaveFile(path string) error
- func (c *Config) SetActiveNamespace(ns string) error
- func (c *Config) SetActiveView(view string)
- type Crumb
- type CustomView
- type Dialog
- type FeatureGates
- type Flags
- type Frame
- type HTTP
- type Help
- type HotKey
- type HotKeys
- type Info
- type Log
- type LogIndicator
- type Logger
- type Menu
- type Namespace
- type Plugin
- type Plugins
- type Prompt
- type Severity
- type SeverityLevel
- type ShortNames
- type Status
- type Style
- type StyleListener
- type Styles
- func (s *Styles) AddListener(l StyleListener)
- func (s *Styles) BgColor() tcell.Color
- func (s *Styles) Body() Body
- func (s *Styles) Charts() Charts
- func (s *Styles) Crumb() Crumb
- func (s *Styles) DefaultSkin()
- func (s *Styles) Dialog() Dialog
- func (s *Styles) FgColor() tcell.Color
- func (s *Styles) Frame() Frame
- func (s *Styles) Load(path string) error
- func (s *Styles) RemoveListener(l StyleListener)
- func (s *Styles) Reset()
- func (s *Styles) Table() Table
- func (s *Styles) Title() Title
- func (s *Styles) Update()
- func (s *Styles) Views() Views
- func (s *Styles) Xray() Xray
- type Table
- type TableHeader
- type Title
- type View
- type ViewConfigListener
- type ViewSetting
- type ViewSettings
- type Views
- type W2
- func (w *W2) ActiveCluster() *Cluster
- func (w *W2) GRPCServer() string
- func (w *W2) GetRefreshRate() int
- func (w *W2) GetScreenDumpDir() string
- func (w *W2) IsCrumbsless() bool
- func (w *W2) IsHeadless() bool
- func (w *W2) IsLogoless() bool
- func (w *W2) IsReadOnly() bool
- func (w *W2) OverrideCommand(cmd string)
- func (w *W2) OverrideCrumbsless(b bool)
- func (w *W2) OverrideHeadless(b bool)
- func (w *W2) OverrideHost(h string)
- func (w *W2) OverrideLogoless(b bool)
- func (w *W2) OverridePort(p string)
- func (w *W2) OverrideReadOnly(b bool)
- func (w *W2) OverrideRefreshRate(r int)
- func (w *W2) OverrideScreenDumpDir(dir string)
- func (w *W2) OverrideWrite(b bool)
- type Xray
- type Yaml
Constants ¶
const ( // DefaultC default concurrency. DefaultC = 1 // DefaultN default number of requests. DefaultN = 200 // DefaultMethod default http verb. DefaultMethod = "GET" )
const ( // DefaultRefreshRate represents the refresh interval. DefaultRefreshRate = 2 // secs // DefaultLogLevel represents the default log level. DefaultLogLevel = "info" // DefaultCommand represents the default command to run. DefaultCommand = "" DefaultHost = "127.0.0.1" DefaultPort = "9527" )
const ( // DefaultDirMod default unix perms for k9s directory. DefaultDirMod os.FileMode = 0755 // DefaultFileMod default unix perms for k9s files. DefaultFileMod os.FileMode = 0600 )
const ( // DefaultLoggerTailCount tracks default log tail size. DefaultLoggerTailCount = 100 // MaxLogThreshold sets the max value for log size. MaxLogThreshold = 5000 // DefaultSinceSeconds tracks default log age. DefaultSinceSeconds = 60 // all logs )
const DefaultPFAddress = "localhost"
DefaultPFAddress specifies the default PortForward host address.
const (
// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
MaxFavoritesNS = 9
)
const W2Config = "W2CONFIG"
W2Config represents W2 configuration dir env var.
Variables ¶
var ( // W2ConfigFile represents W2 config file location. W2ConfigFile = filepath.Join(W2Home(), "config.yml") // W2DefaultScreenDumpDir represents a default directory where W2 screen dumps will be persisted. W2DefaultScreenDumpDir = filepath.Join(os.TempDir(), fmt.Sprintf("weewoe-screens-%s", MustW2User())) )
var DefaultLogFile = filepath.Join(os.TempDir(), fmt.Sprintf("w2-%s.log", MustW2User()))
DefaultLogFile represents the default W2 log file.
var K9sAlias = filepath.Join(W2Home(), "alias.yml")
K9sAlias manages W2 aliases.
var K9sBench = "bench"
K9sBench the name of the benchmarks config file.
var K9sHotKeys = filepath.Join(W2Home(), "hotkey.yml")
K9sHotKeys manages W2 hotKeys.
var K9sPlugins = filepath.Join(W2Home(), "plugin.yml")
K9sPlugins manages W2 plugins.
var K9sStylesFile = filepath.Join(W2Home(), "skin.yml")
K9sStylesFile represents W2 skins file location.
var K9sViewConfigFile = filepath.Join(W2Home(), "views.yml")
K9sViewConfigFile represents the location for the views configuration.
Functions ¶
func EnsureFullPath ¶
EnsureFullPath ensures a directory exist from the given path.
func EnsurePath ¶
EnsurePath ensures a directory exist from the given path.
Types ¶
type Aliases ¶
type Aliases struct { Alias Alias `yaml:"alias"` // contains filtered or unexported fields }
Aliases represents a collection of aliases.
func (*Aliases) LoadFileAliases ¶
LoadFileAliases loads alias from a given file.
func (*Aliases) SaveAliases ¶
SaveAliases saves aliases to a given file.
func (*Aliases) ShortNames ¶
func (a *Aliases) ShortNames() ShortNames
ShortNames return all shortnames.
type Bench ¶
type Bench struct {
Benchmarks *Benchmarks `yaml:"benchmarks"`
}
Bench tracks W2 styling options.
type BenchConfig ¶
type BenchConfig struct { Name string C int `yaml:"concurrency"` N int `yaml:"requests"` Auth Auth `yaml:"auth"` HTTP HTTP `yaml:"http"` }
BenchConfig represents a service benchmark.
func DefaultBenchSpec ¶
func DefaultBenchSpec() BenchConfig
DefaultBenchSpec returns a default bench spec.
type Benchmarks ¶
type Benchmarks struct { Defaults Benchmark `yaml:"defaults"` Services map[string]BenchConfig `yam':"services"` Containers map[string]BenchConfig `yam':"containers"` }
Benchmarks tracks W2 benchmarks configuration.
type Body ¶
type Body struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` LogoColor Color `yaml:"logoColor"` }
Body tracks body styles.
type Charts ¶
type Charts struct { BgColor Color `yaml:"bgColor"` DialBgColor Color `yaml:"dialBgColor"` ChartBgColor Color `yaml:"chartBgColor"` DefaultDialColors Colors `yaml:"defaultDialColors"` DefaultChartColors Colors `yaml:"defaultChartColors"` ResourceColors map[string]Colors `yaml:"resourceColors"` }
Charts tracks charts styles.
type Cluster ¶
type Cluster struct { Namespace *Namespace `yaml:"namespace"` View *View `yaml:"view"` FeatureGates *FeatureGates `yaml:"featureGates"` PortForwardAddress string `yaml:"portForwardAddress"` }
Cluster tracks W2 cluster configuration.
type Config ¶
type Config struct {
W2 *W2 `yaml:"weewoe"`
}
Config tracks W2 configuration options.
func (*Config) ActiveNamespace ¶
ActiveNamespace returns the active namespace in the current cluster.
func (*Config) ActiveView ¶
ActiveView returns the active view in the current cluster.
func (*Config) FavNamespaces ¶
FavNamespaces returns fav namespaces in the current cluster.
func (*Config) SetActiveNamespace ¶
SetActiveNamespace set the active namespace in the current cluster.
func (*Config) SetActiveView ¶
SetActiveView set the currently cluster active view.
type Crumb ¶
type Crumb struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` ActiveColor Color `yaml:"activeColor"` }
Crumb tracks crumbs styles.
type CustomView ¶
type CustomView struct { K9s ViewSettings `yaml:"k9s"` // contains filtered or unexported fields }
CustomView represents a collection of view customization.
func (*CustomView) AddListener ¶
func (v *CustomView) AddListener(gvr string, l ViewConfigListener)
AddListener registers a new listener.
func (*CustomView) Load ¶
func (v *CustomView) Load(path string) error
Load loads view configurations.
func (*CustomView) RemoveListener ¶
func (v *CustomView) RemoveListener(gvr string)
RemoveListener unregister a listener.
type Dialog ¶
type Dialog struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` ButtonFgColor Color `yaml:"buttonFgColor"` ButtonBgColor Color `yaml:"buttonBgColor"` ButtonFocusFgColor Color `yaml:"buttonFocusFgColor"` ButtonFocusBgColor Color `yaml:"buttonFocusBgColor"` LabelFgColor Color `yaml:"labelFgColor"` FieldFgColor Color `yaml:"fieldFgColor"` }
Dialog tracks dialog styles.
type FeatureGates ¶
type FeatureGates struct {
NodeShell bool `yaml:"nodeShell"`
}
FeatureGates represents W2 opt-in features.
func NewFeatureGates ¶
func NewFeatureGates() *FeatureGates
NewFeatureGates returns a new feature gate.
type Flags ¶
type Flags struct { RefreshRate *int Host *string Port *string LogLevel *string LogFile *string Headless *bool Logoless *bool Command *string AllNamespaces *bool ReadOnly *bool Write *bool Crumbsless *bool ScreenDumpDir *string }
Flags represents W2 configuration flags.
type Frame ¶
type Frame struct { Title Title `yaml:"title"` Border Border `yaml:"border"` Menu Menu `yaml:"menu"` Crumb Crumb `yaml:"crumbs"` Status Status `yaml:"status"` }
Frame tracks frame styles.
type HTTP ¶
type HTTP struct { Method string `yaml:"method"` Host string `yaml:"host"` Path string `yaml:"path"` HTTP2 bool `yaml:"http2"` Body string `yaml:"body"` Headers http.Header `yaml:"headers"` }
HTTP represents an http request.
type Help ¶
type Help struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` SectionColor Color `yaml:"sectionColor"` KeyColor Color `yaml:"keyColor"` NumKeyColor Color `yaml:"numKeyColor"` }
Help tracks help styles.
type HotKey ¶
type HotKey struct { ShortCut string `yaml:"shortCut"` Description string `yaml:"description"` Command string `yaml:"command"` }
HotKey describes a W2 hotkey.
type HotKeys ¶
HotKeys represents a collection of plugins.
func (HotKeys) LoadHotKeys ¶
LoadHotKeys loads plugins from a given file.
type Log ¶
type Log struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` Indicator LogIndicator `yaml:"indicator"` }
Log tracks Log styles.
type LogIndicator ¶
LogIndicator tracks log view indicator.
type Logger ¶
type Logger struct { TailCount int64 `yaml:"tail"` BufferSize int `yaml:"buffer"` SinceSeconds int64 `yaml:"sinceSeconds"` FullScreenLogs bool `yaml:"fullScreenLogs"` TextWrap bool `yaml:"textWrap"` ShowTime bool `yaml:"showTime"` }
Logger tracks logger options.
type Menu ¶
type Menu struct { FgColor Color `yaml:"fgColor"` KeyColor Color `yaml:"keyColor"` NumKeyColor Color `yaml:"numKeyColor"` }
Menu tracks menu styles.
type Namespace ¶
Namespace tracks active and favorites namespaces.
func NewNamespace ¶
func NewNamespace() *Namespace
NewNamespace create a new namespace configuration.
type Plugin ¶
type Plugin struct { Scopes []string `yaml:"scopes"` Args []string `yaml:"args"` ShortCut string `yaml:"shortCut"` Pipes []string `yaml:"pipes"` Description string `yaml:"description"` Command string `yaml:"command"` Confirm bool `yaml:"confirm"` Background bool `yaml:"background"` }
Plugin describes a W2 plugin.
type Plugins ¶
Plugins represents a collection of plugins.
func (Plugins) LoadPlugins ¶
LoadPlugins loads plugins from a given file.
type Prompt ¶
type Prompt struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` SuggestColor Color `yaml:"suggestColor"` }
Prompt tracks command styles
type SeverityLevel ¶
type SeverityLevel int
SeverityLevel tracks severity levels.
const ( // SeverityLow tracks low severity. SeverityLow SeverityLevel = iota // SeverityMedium tracks medium severity level. SeverityMedium // SeverityHigh tracks high severity level. SeverityHigh )
type ShortNames ¶
ShortNames represents a collection of shortnames for aliases.
type Status ¶
type Status struct { NewColor Color `yaml:"newColor"` ModifyColor Color `yaml:"modifyColor"` AddColor Color `yaml:"addColor"` PendingColor Color `yaml:"pendingColor"` ErrorColor Color `yaml:"errorColor"` HighlightColor Color `yaml:"highlightColor"` KillColor Color `yaml:"killColor"` CompletedColor Color `yaml:"completedColor"` }
Status tracks resource status styles.
type Style ¶
type Style struct { Body Body `yaml:"body"` Prompt Prompt `yaml:"prompt"` Help Help `yaml:"help"` Frame Frame `yaml:"frame"` Info Info `yaml:"info"` Views Views `yaml:"views"` Dialog Dialog `yaml:"dialog"` }
Style tracks W2 styles.
type StyleListener ¶
type StyleListener interface { // StylesChanged notifies listener the skin changed. StylesChanged(*Styles) }
StyleListener represents a skin's listener.
type Styles ¶
type Styles struct { K9s Style `yaml:"k9s"` // contains filtered or unexported fields }
Styles tracks W2 styling options.
func (*Styles) AddListener ¶
func (s *Styles) AddListener(l StyleListener)
AddListener registers a new listener.
func (*Styles) BgColor ¶
func (s *Styles) BgColor() tcell.Color
BgColor returns the background color.
func (*Styles) FgColor ¶
func (s *Styles) FgColor() tcell.Color
FgColor returns the foreground color.
func (*Styles) RemoveListener ¶
func (s *Styles) RemoveListener(l StyleListener)
RemoveListener removes a listener.
type Table ¶
type Table struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` CursorFgColor Color `yaml:"cursorFgColor"` CursorBgColor Color `yaml:"cursorBgColor"` MarkColor Color `yaml:"markColor"` Header TableHeader `yaml:"header"` }
Table tracks table styles.
type TableHeader ¶
type TableHeader struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` SorterColor Color `yaml:"sorterColor"` }
TableHeader tracks table header styles.
type Title ¶
type Title struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` HighlightColor Color `yaml:"highlightColor"` CounterColor Color `yaml:"counterColor"` FilterColor Color `yaml:"filterColor"` }
Title tracks title styles.
type View ¶
type View struct {
Active string `yaml:"active"`
}
View tracks view configuration options.
type ViewConfigListener ¶
type ViewConfigListener interface { // ConfigChanged notifies listener the view configuration changed. ViewSettingsChanged(ViewSetting) }
ViewConfigListener represents a view config listener.
type ViewSetting ¶
ViewSetting represents a view configuration.
type ViewSettings ¶
type ViewSettings struct {
Views map[string]ViewSetting `yaml:"views"`
}
ViewSettings represent a collection of view configurations.
func NewViewSettings ¶
func NewViewSettings() ViewSettings
NewViewSettings returns a new configuration.
type Views ¶
type Views struct { Table Table `yaml:"table"` Xray Xray `yaml:"xray"` Charts Charts `yaml:"charts"` Yaml Yaml `yaml:"yaml"` Log Log `yaml:"logs"` }
Views tracks individual view styles.
type W2 ¶
type W2 struct { RefreshRate int `yaml:"refreshRate"` MaxConnRetry int `yaml:"maxConnRetry"` EnableMouse bool `yaml:"enableMouse"` Headless bool `yaml:"headless"` Logoless bool `yaml:"logoless"` Crumbsless bool `yaml:"crumbsless"` ReadOnly bool `yaml:"readOnly"` NoIcons bool `yaml:"noIcons"` Logger *Logger `yaml:"logger"` Cluster *Cluster `yaml:"cluster,omitempty"` ScreenDumpDir string `yaml:"screenDumpDir"` // contains filtered or unexported fields }
W2 tracks W2 configuration options.
func (*W2) ActiveCluster ¶
ActiveCluster returns the currently active cluster.
func (*W2) GRPCServer ¶
func (*W2) GetRefreshRate ¶
GetRefreshRate returns the current refresh rate.
func (*W2) GetScreenDumpDir ¶
func (*W2) OverrideCommand ¶
OverrideCommand set the command manually.
func (*W2) OverrideCrumbsless ¶
OverrideCrumbsless tooh the crumbslessness manually.
func (*W2) OverrideHeadless ¶
OverrideHeadless toggle the header manually.
func (*W2) OverrideLogoless ¶
OverrideLogoless toggle the k9s logo manually.
func (*W2) OverrideReadOnly ¶
OverrideReadOnly set the readonly mode manually.
func (*W2) OverrideRefreshRate ¶
OverrideRefreshRate set the refresh rate manually.
func (*W2) OverrideScreenDumpDir ¶
OverrideScreenDumpDir set the screen dump dir manually.
func (*W2) OverrideWrite ¶
OverrideWrite set the write mode manually.