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
- func IsActive() bool
- func Purge(days int)
- type Kubeswitch
- func (k *Kubeswitch) IsValidContext(ctx string) bool
- func (k *Kubeswitch) IsValidNamespace(ns string) bool
- func (k *Kubeswitch) ListContexts() *[]string
- func (k *Kubeswitch) ListNamespaces() *[]string
- func (k *Kubeswitch) LoadNamespaces() error
- func (k *Kubeswitch) SetContext(ctx string) error
- func (k *Kubeswitch) SetNamespace(ns string) error
Constants ¶
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 ¶
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.