cli

package
v2.5.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 17 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogLevel

func SetLogLevel(logLevel string)

SetLogLevel sets the logrus logging level

func UserAgent

func UserAgent() string

UserAgent returns the user agent string used for making API requests

Types

type AgentCli

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

func NewAgentCli

func NewAgentCli(ops ...AgentCliOption) (*AgentCli, error)

NewAgentCli returns a AgentCli instance with all operators applied on it. It applies by default the standard streams.

func (*AgentCli) Apply

func (cli *AgentCli) Apply(ops ...AgentCliOption) error

Apply all the operation on the cli

func (*AgentCli) Client

func (cli *AgentCli) Client() client.APIClient

Client returns the APIClient

func (*AgentCli) ClientInfo

func (cli *AgentCli) ClientInfo() ClientInfo

func (*AgentCli) DefaultVersion

func (cli *AgentCli) DefaultVersion() string

func (*AgentCli) Err

func (cli *AgentCli) Err() io.Writer

func (*AgentCli) In

func (cli *AgentCli) In() *streams.In

func (*AgentCli) Initialize

func (cli *AgentCli) Initialize(opts *ClientOptions, ops ...InitializeOpt) error

Initialize the agentCli runs initialization that must happen after command line flags are parsed.

func (*AgentCli) KVProtoBroker

func (cli *AgentCli) KVProtoBroker() (keyval.ProtoBroker, error)

func (*AgentCli) Out

func (cli *AgentCli) Out() *streams.Out

func (*AgentCli) ServerInfo

func (cli *AgentCli) ServerInfo() ServerInfo

func (*AgentCli) SetIn

func (cli *AgentCli) SetIn(in *streams.In)

type AgentCliOption

type AgentCliOption func(cli *AgentCli) error

AgentCliOption applies a modification on a AgentCli.

func WithClient

func WithClient(c client.APIClient) AgentCliOption

WithClient sets an APIClient.

func WithCombinedStreams

func WithCombinedStreams(combined io.Writer) AgentCliOption

WithCombinedStreams uses the same stream for the output and error streams.

func WithErrorStream

func WithErrorStream(err io.Writer) AgentCliOption

WithErrorStream sets a cli error stream.

func WithInputStream

func WithInputStream(in io.ReadCloser) AgentCliOption

WithInputStream sets a cli input stream.

func WithOutputStream

func WithOutputStream(out io.Writer) AgentCliOption

WithOutputStream sets a cli output stream.

func WithStandardStreams

func WithStandardStreams() AgentCliOption

WithStandardStreams sets a cli in, out and err streams with the standard streams.

type Cli

type Cli interface {
	Client() client.APIClient
	KVProtoBroker() (keyval.ProtoBroker, error)

	Out() *streams.Out
	Err() io.Writer
	In() *streams.In
	SetIn(in *streams.In)
	Apply(ops ...AgentCliOption) error
	ServerInfo() ServerInfo
	ClientInfo() ClientInfo
	DefaultVersion() string
}

Cli represents the agent command line client.

type ClientInfo

type ClientInfo struct {
	DefaultVersion string
}

ClientInfo stores details about the supported features of the client

type ClientOptions

type ClientOptions struct {
	Debug    bool
	LogLevel string

	AgentHost    string
	PortGRPC     int
	PortHTTP     int
	ServiceLabel string
	Endpoints    []string

	// TODO: support TLS
	TLS        bool
	TLSVerify  bool
	TLSOptions *tlsconfig.Options
}

ClientOptions define options for the client.

func NewClientOptions

func NewClientOptions() *ClientOptions

NewClientOptions returns a new ClientOptions

func (*ClientOptions) InstallFlags

func (opts *ClientOptions) InstallFlags(flags *pflag.FlagSet)

InstallFlags adds flags for the common options on the FlagSet

func (*ClientOptions) SetDefaultOptions

func (opts *ClientOptions) SetDefaultOptions(flags *pflag.FlagSet)

SetDefaultOptions sets default values for options after flag parsing is complete

type InitializeOpt

type InitializeOpt func(agentCli *AgentCli) error

InitializeOpt is the type of the functional options passed to AgentCli.Initialize

type ServerInfo

type ServerInfo struct {
	OSType string
}

ServerInfo stores details about the supported features and platform of the server

Jump to

Keyboard shortcuts

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