api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 10 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	// Args returns the command-line arguments, starting with the program name.
	Args() []string

	// Input returns the reader for CLI input.
	Input() io.Reader

	// Out returns a writer for CLI output.
	Out() io.Writer

	// ErrOut returns a writer for CLI errors, logs, and informational messages.
	ErrOut() io.Writer

	// EnvLookup lookups environment variables.
	EnvLookup(key string) (string, bool)

	// Fs returns the filesystem.
	Fs() afero.Fs

	// Logger returns the CLI logger.
	Logger() *logrus.Logger

	// Deprecated warns that a feature is deprecated.
	// It returns an error when DCOS_CLI_FAIL_ON_DEPRECATION=1.
	Deprecated(msg string) error

	// DCOSDir returns the root directory for the DC/OS CLI.
	DCOSDir() (string, error)

	// ConfigManager returns the ConfigManager for the context.
	ConfigManager() (*config.Manager, error)

	// Cluster returns the current cluster.
	Cluster() (*config.Cluster, error)

	// Clusters returns the configured clusters.
	Clusters() ([]*config.Cluster, error)

	// HTTPClient creates an httpclient.Client for a given cluster.
	HTTPClient(c *config.Cluster, opts ...httpclient.Option) (*httpclient.Client, error)

	// Prompt returns a *prompt.Prompt.
	Prompt() *prompt.Prompt

	// Opener returns an open.Opener.
	Opener() open.Opener

	// PluginManager returns a plugin manager.
	PluginManager(*config.Cluster) *plugin.Manager

	// Login initiates a login based on a set of flags and HTTP client. On success it returns an ACS token.
	Login(flags *login.Flags, httpClient *httpclient.Client) (string, error)

	// Setup configures a given cluster based on its URL and setup flags.
	Setup(flags *setup.Flags, clusterURL string, attach bool) (*config.Cluster, error)
}

Context contains abstractions for stdout/stderr, the filesystem, and the CLI environment in general. It also acts as a factory/helper for various objects across the project. It has quite wide scope so in the future it might be refined or interfaces might be introduced for subsets of its functionalities.

Jump to

Keyboard shortcuts

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