util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableDateFormat is the date format used for table output
	TableDateFormat = "2006-01-02 15:04:05"
	// DateOnlyFormat is a date format only containing the date
	DateOnlyFormat = "2006-01-02"
	// UpdateRepo is the repository to check for updates on
	UpdateRepo = "netsoc/cli"
)

Variables

View Source
var (
	// ErrPasswordMismatch indicates that a user entered two different passwords
	ErrPasswordMismatch = errors.New("passwords didn't match")
)
View Source
var IsDebug bool

IsDebug determines if debugging is enabled

Functions

func APIError

func APIError(err error) error

APIError re-formats an OpenAPI-generated API client error

func AddOptFormat added in v0.1.0

func AddOptFormat(cmd *cobra.Command, p *string)

AddOptFormat adds the output format option to a command

func AddOptUser added in v0.2.0

func AddOptUser(cmd *cobra.Command, p *string)

AddOptUser adds the user option to a command

func CheckUpdate added in v0.1.0

func CheckUpdate() (string, error)

CheckUpdate checks to see if a new version is available

func Debugf

func Debugf(format string, v ...interface{})

Debugf prints log messages only if debugging is enabled

func IsInteractive added in v0.2.0

func IsInteractive() bool

IsInteractive returns true if the CLI is being run interactively

func PrintUsers added in v0.1.0

func PrintUsers(users []iam.User, outputType string, single bool) error

PrintUsers renders a list of users (with various output options)

func ReadPassword

func ReadPassword(confirm bool) (string, error)

ReadPassword reads a password from stdin

func SimpleProgress added in v0.2.0

func SimpleProgress(message string, eta time.Duration) (func(), progress.Writer, *progress.Tracker)

SimpleProgress renders a simple progress

func YesNo added in v0.1.0

func YesNo(prompt string, yesDefault bool) (bool, error)

YesNo asks a yes/no question on the command line

Types

type CmdFactory

type CmdFactory struct {
	Config          func() (*config.Config, error)
	Claims          func() (*UserClaims, error)
	IAMClient       func() (*iam.APIClient, error)
	WebspacedClient func() (*webspaced.APIClient, error)
}

CmdFactory provides methods to obtain commonly used structures

func NewDefaultCmdFactory

func NewDefaultCmdFactory(configFlag, debugFlag *pflag.Flag) *CmdFactory

NewDefaultCmdFactory creates a new command factory

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	IsAdmin bool `json:"is_admin"`
	Version uint `json:"version"`
}

UserClaims represents claims in an auth JWT

Jump to

Keyboard shortcuts

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