Documentation ¶
Index ¶
- Constants
- Variables
- func APIError(err error) error
- func AddOptFormat(cmd *cobra.Command, p *string)
- func AddOptUser(cmd *cobra.Command, p *string)
- func CheckUpdate() (string, error)
- func Debugf(format string, v ...interface{})
- func GetTERM() string
- func IsInteractive() bool
- func PrintUsers(users []iam.User, outputType string, single bool) error
- func ReadPassword(confirm bool) (string, error)
- func ResizeListener(sizeChan chan ConsoleSize, stop chan struct{})
- func SignalValue(sig os.Signal) int
- func SimpleProgress(message string, eta time.Duration) (func(), progress.Writer, *progress.Tracker)
- func WebspacedWebsocket(c *config.Config, user, endpoint string) (*websocket.Conn, error)
- func YesNo(prompt string, yesDefault bool) (bool, error)
- type CmdFactory
- type ConsoleSize
- type EscapeReader
- type UserClaims
- type WebsocketIO
Constants ¶
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 ¶
var ( // ErrPasswordMismatch indicates that a user entered two different passwords ErrPasswordMismatch = errors.New("passwords didn't match") )
var ExitCode int
ExitCode is the code the process should exit with (without an error)
var IsDebug bool
IsDebug determines if debugging is enabled
var SignalForwardingSet = []os.Signal{syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTSTP, syscall.SIGTTIN, syscall.SIGTTOU, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGCONT}
SignalForwardingSet is the set of signals that should can be forwarded
Functions ¶
func AddOptFormat ¶ added in v0.1.0
AddOptFormat adds the output format option to a command
func AddOptUser ¶ added in v0.2.0
AddOptUser adds the user option to a command
func CheckUpdate ¶ added in v0.1.0
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 GetTERM ¶ added in v0.3.3
func GetTERM() string
GetTERM gets the value of the TERM environment variable
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
PrintUsers renders a list of users (with various output options)
func ReadPassword ¶
ReadPassword reads a password from stdin
func ResizeListener ¶ added in v0.3.0
func ResizeListener(sizeChan chan ConsoleSize, stop chan struct{})
ResizeListener listens for changes in console size
func SignalValue ¶ added in v0.3.3
SignalValue converts a signal to its integer value
func SimpleProgress ¶ added in v0.2.0
SimpleProgress renders a simple progress
func WebspacedWebsocket ¶ added in v0.3.0
WebspacedWebsocket opens a websocket to webspaced
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 ConsoleSize ¶ added in v0.3.0
ConsoleSize represents the dimensions of the terminal
type EscapeReader ¶ added in v0.3.0
type EscapeReader struct {
// contains filtered or unexported fields
}
EscapeReader transparently reads an escape sequence (^]) from an io.Reader, assumes a TTY in raw mode (one byte at a time reads)
func NewEscapeReader ¶ added in v0.3.0
func NewEscapeReader(r io.Reader, c chan bool) *EscapeReader
NewEscapeReader creates a new escape reading proxy
type UserClaims ¶
type UserClaims struct { jwt.StandardClaims IsAdmin bool `json:"is_admin"` Version uint `json:"version"` }
UserClaims represents claims in an auth JWT
type WebsocketIO ¶ added in v0.3.0
type WebsocketIO struct { Conn *websocket.Conn Mutex sync.Mutex // contains filtered or unexported fields }
WebsocketIO is a wrapper implementing ReadWriteCloser on top of websocket
func NewWebsocketIO ¶ added in v0.3.0
func NewWebsocketIO(c *websocket.Conn, textHandler func(string, *WebsocketIO)) *WebsocketIO
NewWebsocketIO creates a new websocket ReadWriteCloser wrapper
func (*WebsocketIO) Close ¶ added in v0.3.0
func (w *WebsocketIO) Close() error
Close sends a control message indicating the stream is finished, but it does not actually close the socket.