util

package
v3.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSON = "json"
	YAML = "yaml"
)
View Source
const (
	ErrNoNamespaces chkitErrors.Err = "no namespaces in account"
)
View Source
const (
	// ErrUnableToSaveConfig -- unable to save config
	ErrUnableToSaveConfig chkitErrors.Err = "unable to save config"
)

Variables

View Source
var DeleteFlags = []cli.Flag{
	NamespaceFlag,
}
View Source
var GetFlags = []cli.Flag{
	&cli.StringFlag{
		Name:    "file",
		Usage:   "file to write output",
		Aliases: []string{"f"},
	},
	&cli.StringFlag{
		Name:    "output",
		Usage:   "define output formats: yaml, json",
		Aliases: []string{"o"},
	},
	NamespaceFlag,
}
View Source
var NamespaceFlag = &cli.StringFlag{
	Name:    "namespace",
	Aliases: []string{"n", "ns"},
	Usage:   "namespace to use",
}

Functions

func ExitOnErr

func ExitOnErr(log *logrus.Logger, err error)

ExitOnErr -- logs error and exit program

func ExportData

func ExportData(format string, outputFile *string, renderer model.Renderer) error

func ExportDataCommand

func ExportDataCommand(ctx *cli.Context, renderer model.Renderer) error

func GetClient

func GetClient(ctx *cli.Context) *chClient.Client

GetClient -- extract chkit Client

func GetConfig

func GetConfig(ctx *cli.Context) model.Config

GetConfig -- exctract config structure from Context

func GetConfigPath

func GetConfigPath(ctx *cli.Context) string

GetConfigPath -- exctract config path from Context

func GetFirstClientNamespace

func GetFirstClientNamespace(ctx *cli.Context) (string, error)

GetFirstClientNamespace -- fetches namespace list and returns first element. Needed for login.

func GetNamespace

func GetNamespace(ctx *cli.Context) string

GetNamespace -- return namespace for usage in commands. Priority: "namespace" flag, config file.

func GetTokens

func GetTokens(ctx *cli.Context) model.Tokens

GetTokens -- extract tokens from Context

func GetVersion

func GetVersion(ctx *cli.Context) semver.Version

func LoadConfig

func LoadConfig(configFilePath string, config *model.Config) error

LoadConfig -- loads config from fs

func LoadTokens

func LoadTokens(ctx *cli.Context) (model.Tokens, error)

LoadTokens -- loads tokens from fs

func LogFileName

func LogFileName() string

func SaveConfig

func SaveConfig(ctx *cli.Context) error

SaveConfig -- writes config in config path

func SaveTokens

func SaveTokens(ctx *cli.Context, tokens model.Tokens) error

SaveTokens -- save tokens in config path

func SetClient

func SetClient(ctx *cli.Context, client *chClient.Client)

SetClient -- store Client in Context

func SetConfig

func SetConfig(ctx *cli.Context, config model.Config)

SetConfig -- store config in Context

func SetTokens

func SetTokens(ctx *cli.Context, tokens model.Tokens)

SetTokens -- stores tokens in Context

func StoreClient

func StoreClient(ctx *cli.Context, client *chClient.Client)

func WriteConfig

func WriteConfig(ctx *cli.Context) error

WriteConfig -- writes config from Context to config dir

Types

type Set

type Set map[string]struct{}

func NewSet

func NewSet(vals []string) Set

func (Set) Have

func (s Set) Have(v string) bool

Jump to

Keyboard shortcuts

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