Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureDirPath(path string, mod os.FileMode) error
- func EnsureFullPath(path string, mod os.FileMode) error
- func InList(ll []string, n string) bool
- func SanitizeContextSubpath(cluster, context string) string
- func SanitizeFileName(name string) string
- type Config
- type Context
- type Dir
- type FeatureGates
- type KubeSettings
- type Namespace
- type View
Constants ¶
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" )
const DefaultPFAddress = "localhost"
DefaultPFAddress specifies the default PortForward host address.
const DefaultView = "po"
const (
// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
MaxFavoritesNS = 9
)
Variables ¶
var JSONValidator = json.NewValidator()
JSONValidator validate yaml configurations.
Functions ¶
func EnsureDirPath ¶
EnsureDirPath ensures a directory exist from the given path.
func EnsureFullPath ¶
EnsureFullPath ensures a directory exist from the given path.
func SanitizeContextSubpath ¶ added in v0.30.3
SanitizeContextSubpath ensure cluster/context produces a valid path.
func SanitizeFileName ¶ added in v0.30.3
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 (*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 NewContextFromConfig ¶
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 (*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.
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 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.