command

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: MPL-2.0 Imports: 31 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// DefaultAppfile is the default filename for the Appfile
	DefaultAppfile = "Appfile"

	// DefaultLocalDataDir is the default path to the local data
	// directory.
	DefaultLocalDataDir         = "~/.otto.d"
	DefaultLocalDataDetectorDir = "detect"
	DefaultLocalDataPluginsDir  = "plugins"

	// DefaultOutputDir is the default filename for the output directory
	DefaultOutputDir                = ".otto"
	DefaultOutputDirCompiledAppfile = "appfile"
	DefaultOutputDirCompiledData    = "compiled"
	DefaultOutputDirLocalData       = "data"

	// DefaultDataDir is the default directory for the directory
	// data if a directory in the Appfile isn't specified.
	DefaultDataDir = "otto-data"
)
View Source
const PluginGlob = "otto-plugin-*"

PluginGlob is the glob pattern used to find plugins.

Variables

View Source
var (
	// AltAppfiles is the list of alternative names for an Appfile that Otto can
	// detect and load automatically
	AltAppfiles = []string{"appfile.hcl"}
)

Functions

func NewUi

func NewUi(raw cli.Ui) ui.Ui

NewUi returns a new otto Ui implementation for use around the given CLI Ui implementation.

Types

type BuildCommand

type BuildCommand struct {
	Meta
}

BuildCommand is the command that builds a deployable artifact for this version of the app.

func (*BuildCommand) Help

func (c *BuildCommand) Help() string

func (*BuildCommand) Run

func (c *BuildCommand) Run(args []string) int

func (*BuildCommand) Synopsis

func (c *BuildCommand) Synopsis() string

type CompileCommand

type CompileCommand struct {
	Meta

	// Detectors to use for compilation. These will be overridden by any
	// plugins.
	Detectors []*detect.Detector
}

CompileCommand is the command that is responsible for "compiling" the Appfile into a set of data that is used by the other commands for execution.

func (*CompileCommand) Help

func (c *CompileCommand) Help() string

func (*CompileCommand) Run

func (c *CompileCommand) Run(args []string) int

func (*CompileCommand) Synopsis

func (c *CompileCommand) Synopsis() string

type DeployCommand

type DeployCommand struct {
	Meta
}

DeployCommand is the command that deploys the app once it is built.

func (*DeployCommand) Help

func (c *DeployCommand) Help() string

func (*DeployCommand) Run

func (c *DeployCommand) Run(args []string) int

func (*DeployCommand) Synopsis

func (c *DeployCommand) Synopsis() string

type DevCommand

type DevCommand struct {
	Meta
}

DevCommand is the command that manages (starts, stops, etc.) the development environment for an Appfile.

func (*DevCommand) Help

func (c *DevCommand) Help() string

func (*DevCommand) Run

func (c *DevCommand) Run(args []string) int

func (*DevCommand) Synopsis

func (c *DevCommand) Synopsis() string

type FlagSetFlags

type FlagSetFlags uint

FlagSetFlags is an enum to define what flags are present in the default FlagSet returned by Meta.FlagSet

const (
	FlagSetNone FlagSetFlags = 0
)

type HelpCommand added in v0.1.2

type HelpCommand struct {
	Meta
}

HelpCommand is not a real command. It just shows help output for people expecting `otto help` to work.

func (*HelpCommand) Help added in v0.1.2

func (c *HelpCommand) Help() string

func (*HelpCommand) Run added in v0.1.2

func (c *HelpCommand) Run(args []string) int

func (*HelpCommand) Synopsis added in v0.1.2

func (c *HelpCommand) Synopsis() string

type InfraCommand

type InfraCommand struct {
	Meta
}

InfraCommand is the command that sets up the infrastructure for an Appfile.

func (*InfraCommand) Help

func (c *InfraCommand) Help() string

func (*InfraCommand) Run

func (c *InfraCommand) Run(args []string) int

func (*InfraCommand) Synopsis

func (c *InfraCommand) Synopsis() string

type Meta

type Meta struct {
	CoreConfig *otto.CoreConfig
	Ui         cli.Ui
	PluginMap  plugin.ServeMuxMap
	// contains filtered or unexported fields
}

Meta are the meta-options that are available on all or most commands.

func (*Meta) Appfile

func (m *Meta) Appfile() (*appfile.Compiled, error)

Appfile loads the compiled Appfile. If the Appfile isn't compiled yet, then an error will be returned.

func (*Meta) AppfilePluginsPath added in v0.2.0

func (m *Meta) AppfilePluginsPath(f *appfile.Compiled) (string, error)

AppfilePluginsPath returns the path where the used plugins data should be stored based on an Appfile.

func (*Meta) Core

func (m *Meta) Core(f *appfile.Compiled) (*otto.Core, error)

Core returns the core for the given Appfile. The file where the Appfile was loaded from should be set in appfile.File.Path. This root appfile path will be used as the default output directory for Otto.

func (*Meta) DataDir

func (m *Meta) DataDir() (string, error)

DataDir returns the user-local data directory for Otto.

func (*Meta) Directory

func (m *Meta) Directory(config *otto.CoreConfig) (directory.Backend, error)

Directory returns the Otto directory backend for the given Appfile. If no directory backend is specified, a local folder will be used.

func (*Meta) FlagSet

func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet

FlagSet returns a FlagSet with the common flags that every command implements. The exact behavior of FlagSet can be configured using the flags as the second parameter.

func (*Meta) OttoUi

func (m *Meta) OttoUi() ui.Ui

OttoUi returns the ui.Ui object.

func (*Meta) PluginManager added in v0.2.0

func (m *Meta) PluginManager() (*PluginManager, error)

PluginManager returns the PluginManager configured with the proper directories for this command invocation.

This is a singleton for each Meta, so multiple calls will return the same object.

func (*Meta) RootDir

func (m *Meta) RootDir(startDir string) (string, error)

RootDir finds the "root" directory. This is the working directory of the Appfile and Otto itself. To find the root directory, we traverse upwards until we find the ".otto" directory and assume that is where it is.

type Plugin added in v0.2.0

type Plugin struct {
	// Path and Args are the method used to invocate this plugin.
	// These are the only two values that need to be set manually. Once
	// these are set, call Load to load the plugin.
	Path string   `json:"path,omitempty"`
	Args []string `json:"args"`

	// Builtin will be set to true by the PluginManager if this plugin
	// represents a built-in plugin. If it does, then Path above has
	// no affect, we always use the current executable.
	Builtin bool `json:"builtin"`

	// The fields below are loaded as part of the Load() call and should
	// not be set manually, but can be accessed after Load.
	App     app.Factory `json:"-"`
	AppMeta *app.Meta   `json:"-"`
	// contains filtered or unexported fields
}

Plugin is a single plugin that has been loaded.

func (*Plugin) Load added in v0.2.0

func (p *Plugin) Load() error

Load loads the plugin specified by the Path and instantiates the other fields on this structure.

func (*Plugin) String added in v0.2.0

func (p *Plugin) String() string

func (*Plugin) Used added in v0.2.0

func (p *Plugin) Used() bool

Used tracks whether or not this plugin was used or not. You can call this after compilation on each plugin to determine what plugin was used.

type PluginBuiltinCommand added in v0.2.0

type PluginBuiltinCommand struct {
	Meta
}

PluginBuiltinCommand is a command for serving our internal plugins. This is not a command we expect users to call directly.

func (*PluginBuiltinCommand) Help added in v0.2.0

func (c *PluginBuiltinCommand) Help() string

func (*PluginBuiltinCommand) Run added in v0.2.0

func (c *PluginBuiltinCommand) Run(args []string) int

func (*PluginBuiltinCommand) Synopsis added in v0.2.0

func (c *PluginBuiltinCommand) Synopsis() string

type PluginManager added in v0.2.0

type PluginManager struct {
	// PluginDirs are the directories where plugins can be found.
	// Any plugins with the same types found later (higher index) will
	// override earlier (lower index) directories.
	PluginDirs []string

	// PluginMap is the map of availabile built-in plugins
	PluginMap plugin.ServeMuxMap
	// contains filtered or unexported fields
}

PluginManager is responsible for discovering and starting plugins.

Plugin cleanup is done out in the main package: we just defer plugin.CleanupClients in main itself.

func (*PluginManager) ConfigureCore added in v0.2.0

func (m *PluginManager) ConfigureCore(core *otto.CoreConfig) error

ConfigureCore configures the Otto core configuration with the loaded plugin data.

func (*PluginManager) Discover added in v0.2.0

func (m *PluginManager) Discover() error

Discover will find all the available plugin binaries. Each time this is called it will override any previously discovered plugins.

func (*PluginManager) LoadAll added in v0.2.0

func (m *PluginManager) LoadAll() error

LoadAll will launch every plugin and add it to the CoreConfig given.

func (*PluginManager) LoadUsed added in v0.2.0

func (m *PluginManager) LoadUsed(path string) error

LoadUsed will load the plugins in the given used file that was saved with StoreUsed.

func (*PluginManager) Plugins added in v0.2.0

func (m *PluginManager) Plugins() []*Plugin

Plugins returns the loaded plugins.

func (*PluginManager) StoreUsed added in v0.2.0

func (m *PluginManager) StoreUsed(path string) error

StoreUsed will persist the used plugins into a file. LoadUsed can then be called to load the plugins that were used only, making plugin loading much more efficient.

type StatusCommand

type StatusCommand struct {
	Meta
}

StatusCommand is the command that shows the status of the various stages of this application.

func (*StatusCommand) Help

func (c *StatusCommand) Help() string

func (*StatusCommand) Run

func (c *StatusCommand) Run(args []string) int

func (*StatusCommand) Synopsis

func (c *StatusCommand) Synopsis() string

type VersionCheckFunc

type VersionCheckFunc func() (VersionCheckInfo, error)

VersionCheckFunc is the callback called by the Version command to check if there is a new version of Otto.

type VersionCheckInfo

type VersionCheckInfo struct {
	Outdated bool
	Latest   string
	Alerts   []string
}

VersionCheckInfo is the return value for the VersionCheckFunc callback and tells the Version command information about the latest version of Otto.

type VersionCommand

type VersionCommand struct {
	Meta

	Revision          string
	Version           string
	VersionPrerelease string
	CheckFunc         VersionCheckFunc
}

VersionCommand is a Command implementation prints the version.

func (*VersionCommand) Help

func (c *VersionCommand) Help() string

func (*VersionCommand) Run

func (c *VersionCommand) Run(args []string) int

func (*VersionCommand) Synopsis

func (c *VersionCommand) Synopsis() string

Jump to

Keyboard shortcuts

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