flag

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package flag implements shortcuts for parsing flags and creating kubernetes client from them.

Usage

Create ConfigFlag that by default looks for config in your home dir and use a shortcut to create kubernetes.Clientset

import kflag "github.com/bukowa/goutils/kubernetes/config/flag"
import "flag"

cf := kflag.NewConfigFlag()
// set flags
cf.Set()
// parse flags
flag.Parse()
// create kubernetes client
c, err := kubeConfigFlag.NewClient()

By default config file from home directory will be used `$HOME/.kube/config`. If you set --kubeconfig to empty value then client will use in-cluster config files.

cf := kflag.NewConfigFlag()
// change default to use in-cluster config
cf.Default = ""
// parse flags
flag.Parse()
// create kubernetes client
c, err := kubeConfigFlag.NewClient()

Index

Constants

View Source
const (
	ConfigPathFlagName = "kubeconfig"
	ConfigPathFlagHelp = "path to kubernetes config file, can be empty - API client will load in-cluster config then"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFlag

type ConfigFlag struct {
	*uflag.String
}

func NewConfigFlag

func NewConfigFlag() *ConfigFlag

func (*ConfigFlag) NewClient

func (cf *ConfigFlag) NewClient() (c *kubernetes.Clientset, err error)

func (*ConfigFlag) SetFlagSet

func (cf *ConfigFlag) SetFlagSet(fs *flag.FlagSet)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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