data

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: Apache-2.0, Apache-2.0 Imports: 9 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 DefaultPFAddress = "localhost"

DefaultPFAddress specifies the default PortForward host address.

View Source
const DefaultView = "po"
View Source
const (
	// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
	MaxFavoritesNS = 9
)

Variables

This section is empty.

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.

Types

type Config

type Config struct {
	Context *Context `yaml:"k9s"`
}

Config tracks a context configuration.

func NewConfig

func NewConfig(ct *api.Context) *Config

func (*Config) Dump

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

func (*Config) Save

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

func (*Config) Validate

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

type Context

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

Context tracks K9s context configuration.

func NewContext

func NewContext() *Context

NewContext creates a new cluster configuration.

func NewContextFromConfig

func NewContextFromConfig(cfg *api.Context) *Context

func (*Context) Validate

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

Validate a context config.

type Dir

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

func NewDir

func NewDir(root string, conn client.Connection, ks KubeSettings) *Dir

func (Dir) Load

func (d Dir) Load(n string, ct *api.Context) (*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)

	// CurrentNamespace 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"`
}

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, ks KubeSettings)

Validate 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