konfig

package module
v0.0.0-...-cc2feb4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

kubeconfig-picker

wercker status Go Report Card

Pick out a subset of Kube config contexts

Usage

import (
    "fmt"

    konfig "github.com/fenrirunbound/kubeconfig-picker"
)

func main() {
    k, _ := konfig.NewKonfig("/home/me/.kube/config")
    
    availableContexts := k.ListContexts()
    // A list of contexts contained in the kube config
    fmt.Printf("%v\n", availableContexts)

    config, _ := k.SelectContextsAsYaml([]string{"context1", "anotherContext"})
    // A kube config with only "context1" and "anotherContext" derived from the main config
    fmt.Printf("%v\n", string(config))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Konfig

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

Konfig Wrapper object for picking specific contexts from a kube config

func NewKonfig

func NewKonfig(kubeconfig []byte) (*Konfig, error)

NewKonfig Generate a Konfig object from a kubeconfig file that is already in a byte-array

func NewKonfigFromFile

func NewKonfigFromFile(kubeConfigFilepath string) (*Konfig, error)

NewKonfigFromFile Generate a Konfig object by loading a kubeconfig file

func (*Konfig) ListContexts

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

ListContexts List the contexts associated with Konfig A sanity function for displaying what contexts are loaded with Konfig

func (*Konfig) SelectContexts

func (k *Konfig) SelectContexts(contextNames []string) *api.Config

SelectContexts Pick contexts by name and return an object containing the subset. If a context does not exist in the Konfig, there will be _no_ error returned and the context will be omitted from the returned result

func (*Konfig) SelectContextsAsYaml

func (k *Konfig) SelectContextsAsYaml(contextNames []string) ([]byte, error)

SelectContextsAsYaml Pick contexts by name and return the kube config in its YAML form.

Jump to

Keyboard shortcuts

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