data

package
v0.32.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDirMod default unix perms for k9s directory.
	DefaultDirMod os.FileMode = 0744

	// DefaultFileMod default unix perms for k9s files.
	DefaultFileMod os.FileMode = 0600

	// MainConfigFile track main configuration file..
	MainConfigFile = "config.yaml"
)
View Source
const DefaultView = "po"
View Source
const (
	// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
	MaxFavoritesNS = 9
)

Variables

View Source
var JSONValidator = json.NewValidator()

JSONValidator validate yaml configurations.

Functions

func EnsureDirPath

func EnsureDirPath(path string, mod os.FileMode) error

EnsureDirPath ensures a directory exist from the given path.

func EnsureFullPath

func EnsureFullPath(path string, mod os.FileMode) error

EnsureFullPath 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 SanitizeContextSubpath added in v0.30.3

func SanitizeContextSubpath(cluster, context string) string

SanitizeContextSubpath ensure cluster/context produces a valid path.

func SanitizeFileName added in v0.30.3

func SanitizeFileName(name string) string

SanitizeFileName ensure file spec is valid.

Types

type Config

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

Config tracks a context configuration.

func NewConfig

func NewConfig(ct *api.Context) *Config

NewConfig returns a new config.

func (*Config) Dump

func (c *Config) Dump(w io.Writer)

Dump used for debugging.

func (*Config) Merge added in v0.32.0

func (c *Config) Merge(c1 *Config)

func (*Config) Validate

func (c *Config) Validate(conn client.Connection, ks KubeSettings)

Validate ensures config is in norms.

type Context

type Context struct {
	ClusterName        string       `yaml:"cluster,omitempty"`
	ReadOnly           *bool        `yaml:"readOnly,omitempty"`
	Skin               string       `yaml:"skin,omitempty"`
	Namespace          *Namespace   `yaml:"namespace"`
	View               *View        `yaml:"view"`
	FeatureGates       FeatureGates `yaml:"featureGates"`
	PortForwardAddress string       `yaml:"portForwardAddress"`
	// contains filtered or unexported fields
}

Context tracks K9s context configuration.

func NewContext

func NewContext() *Context

NewContext creates a new cluster configuration.

func NewContextFromConfig

func NewContextFromConfig(cfg *api.Context) *Context

NewContextFromConfig returns a config based on a kubecontext.

func NewContextFromKubeConfig added in v0.31.0

func NewContextFromKubeConfig(ks KubeSettings) (*Context, error)

NewContextFromKubeConfig returns a new instance based on kubesettings or an error.

func (*Context) GetClusterName added in v0.31.0

func (c *Context) GetClusterName() string

func (*Context) Validate

func (c *Context) Validate(conn client.Connection, ks KubeSettings)

Validate ensures a context config is tip top.

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir tracks context configurations.

func NewDir

func NewDir(root string) *Dir

NewDir returns a new instance.

func (*Dir) Load

func (d *Dir) Load(n string, ct *api.Context) (*Config, error)

Load loads context configuration.

func (*Dir) Save added in v0.31.8

func (d *Dir) Save(path string, c *Config) error

type FeatureGates

type FeatureGates struct {
	NodeShell bool `yaml:"nodeShell"`
}

FeatureGates represents K9s opt-in features.

func NewFeatureGates

func NewFeatureGates() FeatureGates

NewFeatureGates returns a new feature gate.

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)

	// CurrentNamespaceName returns the name of the current namespace.
	CurrentNamespaceName() (string, error)

	// ContextNames returns all available context names.
	ContextNames() (map[string]struct{}, error)

	// CurrentContext returns the current context configuration.
	CurrentContext() (*api.Context, error)

	// GetContext returns a given context configuration or err if not found.
	GetContext(string) (*api.Context, error)
}

KubeSettings exposes kubeconfig context information.

type Namespace

type Namespace struct {
	Active        string   `yaml:"active"`
	LockFavorites bool     `yaml:"lockFavorites"`
	Favorites     []string `yaml:"favorites"`
	// contains filtered or unexported fields
}

Namespace tracks active and favorites namespaces.

func NewActiveNamespace

func NewActiveNamespace(n string) *Namespace

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)

Validate validates a namespace is setup correctly.

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.

Jump to

Keyboard shortcuts

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