kubeswitch

package
v0.2.6 Latest Latest
Warning

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

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

Documentation

Overview

Copyright © 2020 Chung Tran <chung.k.tran@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// EnvVarActive is the env var that will be used
	// to determine if shell is started by kubeswitch.
	EnvVarActive = "KUBESWITCH_ACTIVE"

	// EnvVarConfig is the env var that points to a
	// session's kube config.
	EnvVarConfig = "KUBECONFIG"
)

Variables

This section is empty.

Functions

func IsActive

func IsActive() bool

IsActive returns true if inside kubeswitch session. It uses EnvVarActive value to determine if in kubeswitch session.

func Purge

func Purge(days int)

Purge deletes temporary session files older than `days`.

Types

type Kubeswitch

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

Kubeswitch holds loaded kube config and loaded namespaces.

func New

func New() (*Kubeswitch, error)

New returns an instance of Kubeswitch after loading the config file from passed in path, KUBECONFIG env var, or default location.

func (*Kubeswitch) IsValidContext

func (k *Kubeswitch) IsValidContext(ctx string) bool

IsValidContext return true if context is one of the contexts.

func (*Kubeswitch) IsValidNamespace

func (k *Kubeswitch) IsValidNamespace(ns string) bool

IsValidNamespace return true if namespace is one of the namespaces.

func (*Kubeswitch) ListContexts

func (k *Kubeswitch) ListContexts() *[]string

ListContexts return context names in loaded config.

func (*Kubeswitch) ListNamespaces

func (k *Kubeswitch) ListNamespaces() *[]string

ListNamespaces return namespaces live from Kubernetes.

func (*Kubeswitch) LoadNamespaces

func (k *Kubeswitch) LoadNamespaces() error

LoadNamespaces loads list of namespaces for current context live from Kubernetes.

func (*Kubeswitch) SetContext

func (k *Kubeswitch) SetContext(ctx string) error

SetContext set context as current context.

func (*Kubeswitch) SetNamespace

func (k *Kubeswitch) SetNamespace(ns string) error

SetNamespace sets default namespace for current context.

Jump to

Keyboard shortcuts

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