config

package
v0.0.0-...-8acee00 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultC default concurrency.
	DefaultC = 1
	// DefaultN default number of requests.
	DefaultN = 200
	// DefaultMethod default http verb.
	DefaultMethod = "GET"
)
View Source
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 = "po"
)
View Source
const (
	// DefaultDirMod default unix perms for k9s directory.
	DefaultDirMod os.FileMode = 0755
	// DefaultFileMod default unix perms for k9s files.
	DefaultFileMod os.FileMode = 0644
)
View Source
const (
	// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
	MaxFavoritesNS = 10
)

Variables

View Source
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()))
)
View Source
var (
	// K9sBench the name of the benchmarks config file.
	K9sBench = "bench"
)
View Source
var (
	// K9sStylesFile represents K9s skins file location.
	K9sStylesFile = filepath.Join(K9sHome, "skin.yml")
)

Functions

func AsColor

func AsColor(c string) tcell.Color

AsColor checks color index, if match return color otherwise pink it is.

func EnsurePath

func EnsurePath(path string, mod os.FileMode)

EnsurePath ensures a directory exist from the given path.

func InList

func InList(ll []string, n string) bool

InList check if string is in a collection of strings.

func InNSList

func InNSList(nn []interface{}, ns string) bool

InNSList check if ns is in an ns collection.

func MustK9sUser

func MustK9sUser() string

MustK9sUser establishes current user identity or fail.

Types

type Auth

type Auth struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

Auth basic auth creds

type Bench

type Bench struct {
	Benchmarks *Benchmarks `yaml:"benchmarks"`
}

Bench tracks K9s styling options.

func NewBench

func NewBench(path string) (*Bench, error)

NewBench creates a new default config.

func (*Bench) Reload

func (s *Bench) Reload(path string) error

Reload update the configuration from disk.

type BenchConfig

type BenchConfig struct {
	C    int  `yaml:"concurrency"`
	N    int  `yaml:"requests"`
	Auth Auth `yaml:"auth"`
	HTTP HTTP `yaml:"http"`
	Name string
}

BenchConfig represents a service benchmark.

type Benchmark

type Benchmark struct {
	C int `yaml:"concurrency"`
	N int `yaml:"requests"`
}

Benchmark represents a generic benchmark.

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   string `yaml:"fgColor"`
	BgColor   string `yaml:"bgColor"`
	LogoColor string `yaml:"logoColor"`
}

Body tracks body styles.

type Border

type Border struct {
	FgColor    string `yaml:"fgColor"`
	FocusColor string `yaml:"focusColor"`
}

Border tracks border styles.

type Cluster

type Cluster struct {
	Namespace *Namespace `yaml:"namespace"`
	View      *View      `yaml:"view"`
}

Cluster tracks K9s cluster configuration.

func NewCluster

func NewCluster() *Cluster

NewCluster creates a new cluster configuration.

func (*Cluster) Validate

func (c *Cluster) Validate(conn Connection, ks KubeSettings)

Validate a cluster config.

type Config

type Config struct {
	K9s *K9s `yaml:"k9s"`
	// contains filtered or unexported fields
}

Config tracks K9s configuration options.

func NewConfig

func NewConfig(ks KubeSettings) *Config

NewConfig creates a new default config.

func (*Config) ActiveNamespace

func (c *Config) ActiveNamespace() string

ActiveNamespace returns the active namespace in the current cluster.

func (*Config) ActiveView

func (c *Config) ActiveView() string

ActiveView returns the active view in the current cluster.

func (*Config) CurrentCluster

func (c *Config) CurrentCluster() *Cluster

CurrentCluster fetch the configuration activeCluster.

func (*Config) Dump

func (c *Config) Dump(msg string)

Dump debug...

func (*Config) FavNamespaces

func (c *Config) FavNamespaces() []string

FavNamespaces returns fav namespaces in the current cluster.

func (*Config) GetConnection

func (c *Config) GetConnection() Connection

GetConnection return an api server connection.

func (*Config) Load

func (c *Config) Load(path string) error

Load K9s configuration from file

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) Save

func (c *Config) Save() error

Save configuration to disk.

func (*Config) SaveFile

func (c *Config) SaveFile(path string) error

SaveFile K9s configuration to disk.

func (*Config) SetActiveNamespace

func (c *Config) SetActiveNamespace(ns string) error

SetActiveNamespace set the active namespace in the current cluster.

func (*Config) SetActiveView

func (c *Config) SetActiveView(view string)

SetActiveView set the currently cluster active view

func (*Config) SetConnection

func (c *Config) SetConnection(conn Connection)

SetConnection set an api server connection.

func (*Config) Validate

func (c *Config) Validate()

Validate the configuration.

type Connection

type Connection k8s.Connection

Connection present a kubernetes api server connection.

type Crumb

type Crumb struct {
	FgColor     string `yaml:"fgColor"`
	BgColor     string `yaml:"bgColor"`
	ActiveColor string `yaml:"activeColor"`
}

Crumb tracks crumbs styles.

type Flags

type Flags struct {
	RefreshRate *int
	LogLevel    *string
	Headless    *bool
	Command     *string
}

Flags represents K9s configuration flags.

func NewFlags

func NewFlags() *Flags

NewFlags returns new 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 Info

type Info struct {
	SectionColor string `yaml:"sectionColor"`
	FgColor      string `yaml:"fgColor"`
}

Info tracks info styles.

type K9s

type K9s struct {
	RefreshRate    int                 `yaml:"refreshRate"`
	Headless       bool                `yaml:"headless"`
	LogBufferSize  int                 `yaml:"logBufferSize"`
	LogRequestSize int                 `yaml:"logRequestSize"`
	CurrentContext string              `yaml:"currentContext"`
	CurrentCluster string              `yaml:"currentCluster"`
	Clusters       map[string]*Cluster `yaml:"clusters,omitempty"`
	Plugins        map[string]*Plugin  `yaml:"plugins,omitempty"`
	// contains filtered or unexported fields
}

K9s tracks K9s configuration options.

func NewK9s

func NewK9s() *K9s

NewK9s create a new K9s configuration.

func (*K9s) ActiveCluster

func (k *K9s) ActiveCluster() *Cluster

ActiveCluster returns the currently active cluster.

func (*K9s) GetHeadless

func (k *K9s) GetHeadless() bool

GetHeadless returns headless setting.

func (*K9s) GetRefreshRate

func (k *K9s) GetRefreshRate() int

GetRefreshRate returns the current refresh rate.

func (*K9s) OverrideCommand

func (k *K9s) OverrideCommand(cmd string)

OverrideCommand set the command manually.

func (*K9s) OverrideHeadless

func (k *K9s) OverrideHeadless(b bool)

OverrideHeadless set the headlessness manually.

func (*K9s) OverrideRefreshRate

func (k *K9s) OverrideRefreshRate(r int)

OverrideRefreshRate set the refresh rate manually.

func (*K9s) Validate

func (k *K9s) Validate(c k8s.Connection, ks KubeSettings)

Validate the current configuration.

type KubeSettings

type KubeSettings interface {
	CurrentContextName() (string, error)
	CurrentClusterName() (string, error)
	CurrentNamespaceName() (string, error)
	ClusterNames() ([]string, error)
	NamespaceNames(nn []v1.Namespace) []string
}

KubeSettings exposes kubeconfig context informations.

type Log

type Log struct {
	FgColor string `yaml:"fgColor"`
	BgColor string `yaml:"bgColor"`
}

Log tracks Log styles.

type Menu struct {
	FgColor     string `yaml:"fgColor"`
	KeyColor    string `yaml:"keyColor"`
	NumKeyColor string `yaml:"numKeyColor"`
}

Menu tracks menu styles.

type Namespace

type Namespace struct {
	Active    string   `yaml:"active"`
	Favorites []string `yaml:"favorites"`
}

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 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 Status

type Status struct {
	NewColor       string `yaml:"newColor"`
	ModifyColor    string `yaml:"modifyColor"`
	AddColor       string `yaml:"addColor"`
	ErrorColor     string `yaml:"errorColor"`
	HighlightColor string `yaml:"highlightColor"`
	KillColor      string `yaml:"killColor"`
	CompletedColor string `yaml:"completedColor"`
}

Status tracks resource status styles.

type Style

type Style struct {
	Body  Body  `yaml:"body"`
	Frame Frame `yaml:"frame"`
	Info  Info  `yaml:"info"`
	Table Table `yaml:"table"`
	Views Views `yaml:"views"`
}

Style tracks K9s styles.

type Styles

type Styles struct {
	K9s Style `yaml:"k9s"`
}

Styles tracks K9s styling options.

func NewStyles

func NewStyles(path string) (*Styles, error)

NewStyles creates a new default config.

func (*Styles) BgColor

func (s *Styles) BgColor() tcell.Color

BgColor returns the background color.

func (*Styles) Body

func (s *Styles) Body() Body

Body returns body styles.

func (*Styles) Crumb

func (s *Styles) Crumb() Crumb

Crumb returns crumb styles.

func (*Styles) FgColor

func (s *Styles) FgColor() tcell.Color

FgColor returns the foreground color.

func (*Styles) Frame

func (s *Styles) Frame() Frame

Frame returns frame styles.

func (*Styles) Table

func (s *Styles) Table() Table

Table returns table styles.

func (*Styles) Title

func (s *Styles) Title() Title

Title returns title styles.

func (*Styles) Update

func (s *Styles) Update()

Update apply terminal colors based on styles.

func (*Styles) Views

func (s *Styles) Views() Views

Views returns views styles.

type Table

type Table struct {
	FgColor     string      `yaml:"fgColor"`
	BgColor     string      `yaml:"bgColor"`
	CursorColor string      `yaml:"cursorColor"`
	Header      TableHeader `yaml:"header"`
}

Table tracks table styles.

type TableHeader

type TableHeader struct {
	FgColor     string `yaml:"fgColor"`
	BgColor     string `yaml:"bgColor"`
	SorterColor string `yaml:"sorterColor"`
}

TableHeader tracks table header styles.

type Title

type Title struct {
	FgColor        string `yaml:"fgColor"`
	BgColor        string `yaml:"bgColor"`
	HighlightColor string `yaml:"highlightColor"`
	CounterColor   string `yaml:"counterColor"`
	FilterColor    string `yaml:"filterColor"`
}

Title tracks title styles.

type View

type View struct {
	Active string `yaml:"active"`
}

View tracks view configuration options.

func NewView

func NewView() *View

NewView creates a new view configuration.

func (*View) Validate

func (v *View) Validate()

Validate a view configuration.

type Views

type Views struct {
	Yaml Yaml `yaml:"yaml"`
	Log  Log  `yaml:"logs"`
}

Views tracks individual view styles.

type Yaml

type Yaml struct {
	KeyColor   string `yaml:"keyColor"`
	ValueColor string `yaml:"valueColor"`
	ColonColor string `yaml:"colonColor"`
}

Yaml tracks yaml styles.

Jump to

Keyboard shortcuts

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