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 InNSList(nn []interface{}, ns string) bool
- func MustK9sUser() 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) CurrentCluster() *Cluster
- func (c *Config) DemoMode() bool
- func (c *Config) Dump(msg string)
- func (c *Config) FavNamespaces() []string
- func (c *Config) GetConnection() client.Connection
- func (c *Config) Load(path string) error
- func (c *Config) Refine(flags *genericclioptions.ConfigFlags) error
- func (c *Config) Reset()
- 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)
- func (c *Config) SetConnection(conn client.Connection)
- func (c *Config) SetDemoMode(b bool)
- func (c *Config) Validate()
- type Crumb
- type CustomView
- type FeatureGates
- type Flags
- type Frame
- type HTTP
- type HotKey
- type HotKeys
- type Info
- type K9s
- func (k *K9s) ActiveCluster() *Cluster
- func (k *K9s) GetHeadless() bool
- func (k *K9s) GetReadOnly() bool
- func (k *K9s) GetRefreshRate() int
- func (k *K9s) OverrideCommand(cmd string)
- func (k *K9s) OverrideHeadless(b bool)
- func (k *K9s) OverrideReadOnly(b bool)
- func (k *K9s) OverrideRefreshRate(r int)
- func (k *K9s) Validate(c client.Connection, ks KubeSettings)
- type KubeSettings
- type Log
- type LogIndicator
- type Logger
- type Menu
- type Namespace
- type Plugin
- type Plugins
- 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) 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 Threshold
- type Title
- type View
- type ViewConfigListener
- type ViewSetting
- type ViewSettings
- type Views
- 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 = "" )
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 = -1 // all logs )
const (
// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
MaxFavoritesNS = 9
)
Variables ¶
var ( // K9sHome represent K9s home directory. K9sHome = filepath.Join(mustK9sHome(), ".k9s") // K9sConfigFile represents K9s config file location. K9sConfigFile = filepath.Join(K9sHome, "config.yml") // K9sLogs represents K9s log. K9sLogs = filepath.Join(os.TempDir(), fmt.Sprintf("k9s-%s.log", MustK9sUser())) // K9sDumpDir represents a directory where K9s screen dumps will be persisted. K9sDumpDir = filepath.Join(os.TempDir(), fmt.Sprintf("k9s-screens-%s", MustK9sUser())) )
var K9sAlias = filepath.Join(K9sHome, "alias.yml")
K9sAlias manages K9s aliases.
var (
// K9sBench the name of the benchmarks config file.
K9sBench = "bench"
)
var K9sHotKeys = filepath.Join(K9sHome, "hotkey.yml")
K9sHotKeys manages K9s hotKeys.
var K9sPlugins = filepath.Join(K9sHome, "plugin.yml")
K9sPlugins manages K9s plugins.
var K9sStylesFile = filepath.Join(K9sHome, "skin.yml")
K9sStylesFile represents K9s skins file location.
var K9sViewConfigFile = filepath.Join(K9sHome, "views.yml")
K9sViewConfigFile represents the location for the views configuration.
Functions ¶
func EnsureFullPath ¶ added in v0.17.7
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 ¶ added in v0.16.0
LoadFileAliases loads alias from a given file.
func (*Aliases) SaveAliases ¶
SaveAliases saves aliases to a given file.
func (*Aliases) ShortNames ¶ added in v0.13.8
func (a *Aliases) ShortNames() ShortNames
ShortNames return all shortnames.
type Bench ¶
type Bench struct {
Benchmarks *Benchmarks `yaml:"benchmarks"`
}
Bench tracks K9s 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 ¶ added in v0.15.2
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 K9s 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 ¶ added in v0.16.0
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"` }
Cluster tracks K9s cluster configuration.
func (*Cluster) Validate ¶
func (c *Cluster) Validate(conn client.Connection, ks KubeSettings)
Validate a cluster config.
type Color ¶ added in v0.16.0
type Color string
Color represents a color.
type Config ¶
type Config struct { K9s *K9s `yaml:"k9s"` // contains filtered or unexported fields }
Config tracks K9s 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) CurrentCluster ¶
CurrentCluster fetch the configuration activeCluster.
func (*Config) DemoMode ¶ added in v0.17.6
DemoMode returns true if demo mode is active, false otherwise.
func (*Config) FavNamespaces ¶
FavNamespaces returns fav namespaces in the current cluster.
func (*Config) GetConnection ¶
func (c *Config) GetConnection() client.Connection
GetConnection return an api server connection.
func (*Config) Refine ¶
func (c *Config) Refine(flags *genericclioptions.ConfigFlags) error
Refine the configuration based on cli args.
func (*Config) Reset ¶
func (c *Config) Reset()
Reset the context to the new current context/cluster. if it does not exist.
func (*Config) SetActiveNamespace ¶
SetActiveNamespace set the active namespace in the current cluster.
func (*Config) SetActiveView ¶
SetActiveView set the currently cluster active view
func (*Config) SetConnection ¶
func (c *Config) SetConnection(conn client.Connection)
SetConnection set an api server connection.
func (*Config) SetDemoMode ¶ added in v0.17.6
SetDemoMode sets the demo mode.
type Crumb ¶
type Crumb struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` ActiveColor Color `yaml:"activeColor"` }
Crumb tracks crumbs styles.
type CustomView ¶ added in v0.17.0
type CustomView struct { K9s ViewSettings `yaml:"k9s"` // contains filtered or unexported fields }
CustomView represents a collection of view customization.
func NewCustomView ¶ added in v0.17.0
func NewCustomView() *CustomView
NewCustomView returns a views configuration.
func (*CustomView) AddListener ¶ added in v0.17.0
func (v *CustomView) AddListener(gvr string, l ViewConfigListener)
AddListener registers a new listener.
func (*CustomView) Load ¶ added in v0.17.0
func (v *CustomView) Load(path string) error
Load loads view configurations.
func (*CustomView) RemoveListener ¶ added in v0.17.0
func (v *CustomView) RemoveListener(gvr string)
RemoveListener unregister a listener.
func (*CustomView) Reset ¶ added in v0.17.0
func (v *CustomView) Reset()
Reset clears out configurations.
type FeatureGates ¶ added in v0.19.3
type FeatureGates struct {
NodeShell bool `yaml:"nodeShell"`
}
FeatureGates represents K9s opt-in features.
func NewFeatureGates ¶ added in v0.19.3
func NewFeatureGates() *FeatureGates
NewFeatureGate returns a new feature gate.
type Flags ¶
type Flags struct { RefreshRate *int LogLevel *string Headless *bool Command *string AllNamespaces *bool ReadOnly *bool }
Flags represents K9s 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 HotKey ¶
type HotKey struct { ShortCut string `yaml:"shortCut"` Description string `yaml:"description"` Command string `yaml:"command"` }
HotKey describes a K9s hotkey.
type HotKeys ¶
HotKeys represents a collection of plugins.
func (HotKeys) LoadHotKeys ¶
LoadHotKeys loads plugins from a given file.
type K9s ¶
type K9s struct { RefreshRate int `yaml:"refreshRate"` Headless bool `yaml:"headless"` ReadOnly bool `yaml:"readOnly"` NoIcons bool `yaml:"noIcons"` Logger *Logger `yaml:"logger"` CurrentContext string `yaml:"currentContext"` CurrentCluster string `yaml:"currentCluster"` Clusters map[string]*Cluster `yaml:"clusters,omitempty"` Thresholds Threshold `yaml:"thresholds"` // contains filtered or unexported fields }
K9s tracks K9s configuration options.
func (*K9s) ActiveCluster ¶
ActiveCluster returns the currently active cluster.
func (*K9s) GetReadOnly ¶ added in v0.13.8
GetReadOnly returns the readonly setting.
func (*K9s) GetRefreshRate ¶
GetRefreshRate returns the current refresh rate.
func (*K9s) OverrideCommand ¶
OverrideCommand set the command manually.
func (*K9s) OverrideHeadless ¶
OverrideHeadless set the headlessness manually.
func (*K9s) OverrideReadOnly ¶ added in v0.13.8
OverrideReadOnly set the readonly mode manually.
func (*K9s) OverrideRefreshRate ¶
OverrideRefreshRate set the refresh rate manually.
func (*K9s) Validate ¶
func (k *K9s) Validate(c client.Connection, ks KubeSettings)
Validate the current configuration.
type KubeSettings ¶
type KubeSettings interface { // CurrentContextName returns the name of the current context. CurrentContextName() (string, error) // CurrentClusterName returns the name of the current cluster. CurrentClusterName() (string, error) // CurrentNamespace returns the name of the current namespace. CurrentNamespaceName() (string, error) // ClusterNames() returns all available cluster names. ClusterNames() ([]string, error) // NamespaceNames returns all available namespace names. NamespaceNames(nn []v1.Namespace) []string }
KubeSettings exposes kubeconfig context information.
type Log ¶
type Log struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` Indicator LogIndicator `yaml:"indicator"` }
Log tracks Log styles.
type LogIndicator ¶ added in v0.18.0
LogIndicator tracks log view indicator.
type Logger ¶ added in v0.18.0
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
func (*Logger) Validate ¶ added in v0.18.0
func (l *Logger) Validate(_ client.Connection, _ KubeSettings)
Validate checks thresholds and make sure we're cool. If not use defaults.
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.
func (*Namespace) SetActive ¶
func (n *Namespace) SetActive(ns string, ks KubeSettings) error
SetActive set the active namespace.
func (*Namespace) Validate ¶
func (n *Namespace) Validate(c client.Connection, ks KubeSettings)
Validate a namespace is setup correctly
type Plugin ¶
type Plugin struct { ShortCut string `yaml:"shortCut"` Scopes []string `yaml:"scopes"` Description string `yaml:"description"` Command string `yaml:"command"` Background bool `yaml:"background"` Args []string `yaml:"args"` }
Plugin describes a K9s plugin
type Plugins ¶
Plugins represents a collection of plugins.
func (Plugins) LoadPlugins ¶
LoadPlugins loads plugins from a given file.
type Severity ¶ added in v0.17.5
Severity tracks a resource severity levels.
func NewSeverity ¶ added in v0.17.5
func NewSeverity() *Severity
NewSeverity returns a new instance.
type SeverityLevel ¶ added in v0.17.5
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"` 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"` Frame Frame `yaml:"frame"` Info Info `yaml:"info"` Views Views `yaml:"views"` }
Style tracks K9s 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 K9s styling options.
func (*Styles) AddListener ¶
func (s *Styles) AddListener(l StyleListener)
AddListener registers a new listener.
func (*Styles) DefaultSkin ¶ added in v0.15.0
func (s *Styles) DefaultSkin()
DefaultSkin loads the default skin
func (*Styles) RemoveListener ¶
func (s *Styles) RemoveListener(l StyleListener)
RemoveListener unregister a listener.
type Table ¶
type Table struct { FgColor Color `yaml:"fgColor"` BgColor Color `yaml:"bgColor"` CursorColor Color `yaml:"cursorColor"` 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 Threshold ¶ added in v0.17.4
Threshold tracks threshold to alert user when excided.
func NewThreshold ¶ added in v0.17.5
func NewThreshold() Threshold
NewThreshold returns a new threshold.
func (Threshold) LevelFor ¶ added in v0.17.5
func (t Threshold) LevelFor(k string, v int) SeverityLevel
LevelFor returns a defcon level for the current state.
func (*Threshold) SeverityColor ¶ added in v0.17.5
SeverityColor returns an defcon level associated level.
func (Threshold) Validate ¶ added in v0.17.4
func (t Threshold) Validate(c client.Connection, ks KubeSettings)
Validate a namespace is setup correctly
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 ¶ added in v0.17.0
type ViewConfigListener interface { // ConfigChanged notifies listener the view configuration changed. ViewSettingsChanged(ViewSetting) }
ViewConfigListener represents a view config listener.
type ViewSetting ¶ added in v0.17.0
type ViewSetting struct {
Columns []string `yaml:"columns"`
}
ViewSetting represents a view configuration.
type ViewSettings ¶ added in v0.17.0
type ViewSettings struct {
Views map[string]ViewSetting `yaml:"views"`
}
ViewSettings represent a collection of view configurations.
func NewViewSettings ¶ added in v0.17.0
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.