Documentation ¶
Index ¶
- Constants
- func NewTable(writer io.Writer, header []string) *tablewriter.Table
- type Context
- func (ctx *Context) Args() []string
- func (ctx *Context) Cluster() (*config.Cluster, error)
- func (ctx *Context) Clusters() ([]*config.Cluster, error)
- func (ctx *Context) ConfigManager() (*config.Manager, error)
- func (ctx *Context) DCOSDir() (string, error)
- func (ctx *Context) Deprecated(msg string) error
- func (ctx *Context) EnvLookup(key string) (string, bool)
- func (ctx *Context) ErrOut() io.Writer
- func (ctx *Context) Fs() afero.Fs
- func (ctx *Context) HTTPClient(c *config.Cluster, opts ...httpclient.Option) (*httpclient.Client, error)
- func (ctx *Context) Input() io.Reader
- func (ctx *Context) Logger() *logrus.Logger
- func (ctx *Context) Login(flags *login.Flags, httpClient *httpclient.Client) (string, error)
- func (ctx *Context) Opener() open.Opener
- func (ctx *Context) Out() io.Writer
- func (ctx *Context) PluginManager(cluster *config.Cluster) *plugin.Manager
- func (ctx *Context) Prompt() *prompt.Prompt
- func (ctx *Context) Setup(flags *setup.Flags, clusterURL string, attach bool) (*config.Cluster, error)
- type Environment
- type GlobalFlags
Constants ¶
const ( // EnvStrictDeprecations indicates that the CLI should follow a strict deprecation policy. // If this var is exported, the CLI will fail on obsolete features. If a feature is deprecated // in favor of something else, the CLI will instead rely on the new approach. When this env var // is not exported, the CLI displays warnings when encountering deprecated features. EnvStrictDeprecations = "DCOS_CLI_STRICT_DEPRECATIONS" // EnvDCOSDir can be used to specify a custom directory for the DC/OS CLI data, which defaults to "~/.dcos". EnvDCOSDir = "DCOS_DIR" )
Environment variables for the DC/OS CLI.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context provides an implementation of api.Context. It relies on an Environment and is used to create various objects across the project and is being passed to every command as a constructor argument.
func NewContext ¶
func NewContext(env *Environment) *Context
NewContext creates a new context from a given environment.
func (*Context) ConfigManager ¶
ConfigManager returns the ConfigManager for the context.
func (*Context) DCOSDir ¶
DCOSDir returns the root directory for the DC/OS CLI. It defaults to `~/.dcos` and can be overridden by the `DCOS_DIR` env var.
func (*Context) Deprecated ¶
Deprecated warns that a feature is deprecated. It returns an error when DCOS_CLI_STRICT_DEPRECATIONS=1.
func (*Context) ErrOut ¶
ErrOut returns the writer for CLI errors, logs, and informational messages.
func (*Context) HTTPClient ¶
func (ctx *Context) HTTPClient(c *config.Cluster, opts ...httpclient.Option) (*httpclient.Client, error)
HTTPClient creates an httpclient.Client for a given cluster.
func (*Context) Login ¶
Login initiates a login based on a set of flags and HTTP client. On success it returns an ACS token.
func (*Context) PluginManager ¶
PluginManager returns a plugin manager.
type Environment ¶
type Environment struct { // Args are the command-line arguments, starting by the program name. Args []string // Input is the reader for CLI input. Input io.Reader // Out is the writer for CLI output. Out io.Writer // ErrOut is the writer for CLI errors, logs, and informational messages. ErrOut io.Writer // EnvLookup lookups environment variables. EnvLookup func(key string) (string, bool) // Fs is an abstraction for the filesystem. Fs afero.Fs }
Environment represents the CLI environment. It contains writers for stdout/stderr, functions for environment variables or user lookup, as well as a filesystem abstraction.
func NewOsEnvironment ¶
func NewOsEnvironment() *Environment
NewOsEnvironment returns an environment backed by the os package.
type GlobalFlags ¶
GlobalFlags represents the DC/OS CLI global flags.
func (*GlobalFlags) Parse ¶
func (gf *GlobalFlags) Parse(args []string) []string
Parse parses the DC/OS CLI global flags, it accepts the following:
- `-v`, `-vv`: defines the verbosity level.
- `--log-level=[level]` (deprecated): sets the log-level.
- `--debug` (deprecated): sets the log-level to "debug".
- `--version`: displays the DC/OS CLI and cluster versions.