cli

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2016 License: MIT Imports: 27 Imported by: 2

Documentation

Overview

Package cli implements the Sous Command Line Interface. It is a presentation layer, and contains no core logic.

Index

Constants

This section is empty.

Variables

View Source
var (
	SuccessData       = cmdr.SuccessData
	Successf          = cmdr.Successf
	Success           = cmdr.Success
	UsageErrorf       = cmdr.UsageErrorf
	OSErrorf          = cmdr.OSErrorf
	IOErrorf          = cmdr.IOErrorf
	InternalErrorf    = cmdr.InternalErrorf
	EnsureErrorResult = cmdr.EnsureErrorResult
)

Func aliases, for convenience returning from commands.

View Source
var QuerySubcommands = cmdr.Commands{}
View Source
var TopLevelCommands = cmdr.Commands{}

TopLevelCommands is populated once per command file (beginning sous_) in this directory.

Functions

func AddFlags

func AddFlags(fs *flag.FlagSet, target interface{}, help string) error

AddFlags sniffs out struct fields from target and adds them as var flags to the flag set.

func NewSousCLI

func NewSousCLI(v semv.Version, out, errout io.Writer) (*cmdr.CLI, error)

NewSousCLI creates a new Sous cli app.

func ProduceResult

func ProduceResult(err error) cmdr.Result

ProduceResult converts errors into Results

func SuccessYAML

func SuccessYAML(v interface{}) cmdr.Result

SuccessYAML lets you return YAML on the command line.

Types

type Addable

type Addable interface {
	Add(...interface{})
}

Addable objects are able to receive lists of interface{}, presumably to add them to a DI registry. Abstracts Psyringe's Add()

type BuildFlags

type BuildFlags struct {
	Strict  bool   `flag:"strict"`
	Builder string `flag:"builder"`
}

BuildFlags are CLI flags used to set build options.

type Config

type Config struct {
	// StateLocation is either a file containing a pre-compiled state, or
	// a directory containing the state as a tree.
	StateLocation string `env:"SOUS_STATE_LOCATION"`
	// Server is the location of a Sous Server which this sous instance
	// considers the master. If this is not set, this node is considered
	// to be a master.
	Server string `env:"SOUS_SERVER"`
	// BuildStateLocation is a directory where information about builds
	// performed by this user on this machine are stored.
	BuildStateDir string `env:"SOUS_BUILD_STATE_DIR"`
	// Docker is the Docker configuration.
	Docker docker.Config
}

Config contains the core Sous configuration, shared by both the client and server. The client and server may additionally have their own configuration.

func DefaultConfig

func DefaultConfig() Config

func (*Config) FillDefaults

func (c *Config) FillDefaults() error

type CurrentGDM

type CurrentGDM struct{ sous.Deployments }

CurrentGDM is a snapshot of the GDM at application start. In a CLI context, which this is, that is all we need to simply read the GDM.

type DeployFilterFlags

type DeployFilterFlags struct {
	Repo     string
	Offset   string
	Tag      string
	Revision string
	Cluster  string
	All      bool
}

DeployFilterFlags are CLI flags used to configure the underlying deployments a given command will refer to N.b. that not every command will use every filter

type DeployFlags

type DeployFlags struct {
	Deployer   string `flag:"deployer"`
	DryRun     bool   `flag:"dry-run"`
	ForceClone bool   `flag:"force-clone"`
	Cluster    string `flag:"cluster"`
}

DeployFlags are CLI flags used to set deployment context and options.

type DetectedOTPLDeploySpecs

type DetectedOTPLDeploySpecs struct{ sous.DeploySpecs }

DetectedOTPLDeploySpecs is a set of otpl-deploy configured deployments that have been detected.

type ErrOut

type ErrOut struct{ *cmdr.Output }

ErrOut is an output used for logging from a Command. This should only be used when a Command needs to write a lot of data to stderr, using the formatting options that come with and Output. Usually you should use and ErrorResult to return error messages.

type ErrWriter

type ErrWriter io.Writer

ErrWriter is an alias on io.Writer to disguish "stderr"

type GitSourceContext

type GitSourceContext struct{ *sous.SourceContext }

GitSourceContext is the source context according to the local git repo.

type LocalDockerClient

type LocalDockerClient struct{ docker_registry.Client }

LocalDockerClient is a docker client object

type LocalGitClient

type LocalGitClient struct{ *git.Client }

LocalGitClient is a git client rooted in WorkdirShell.Dir.

type LocalGitRepo

type LocalGitRepo struct{ *git.Repo }

LocalGitRepo is the git repository containing WorkDir.

type LocalSousConfig

type LocalSousConfig struct{ *Config }

LocalSousConfig is the configuration for Sous.

func (*LocalSousConfig) Bytes

func (c *LocalSousConfig) Bytes() []byte

Bytes marshals the config to a []byte

func (*LocalSousConfig) Save

func (c *LocalSousConfig) Save(u *User) error

Save the configuration to the configuration path (by default: $HOME/.config/sous/config)

func (*LocalSousConfig) String

func (c *LocalSousConfig) String() string

type LocalStateReader

type LocalStateReader struct{ StateReader }

LocalStateReader wraps a storage.StateReader, and should be configured to use the current user's local storage.

type LocalStateWriter

type LocalStateWriter struct{ StateWriter }

LocalStateWriter wraps a storage.StateWriter, and should be configured to use the current user's local storage.

type LocalUser

type LocalUser struct{ *User }

LocalUser is the currently logged in user.

type LocalWorkDir

type LocalWorkDir string

LocalWorkDir is the user's current working directory when they invoke Sous.

type LocalWorkDirShell

type LocalWorkDirShell struct{ *shell.Sh }

LocalWorkDirShell is a shell for working in the user's current working directory.

type OTPLFlags

type OTPLFlags struct {
	UseOTPLDeploy    bool `flag:"use-otpl-deploy"`
	IgnoreOTPLDeploy bool `flag:"ignore-otpl-deploy"`
}

OTPLFlags set options for sniffing otpl-deploy configuration during manifest initialisation.

type Out

type Out struct{ *cmdr.Output }

Out is an output used for real data a Command returns. This should only be used when a command needs to write directly to stdout, using the formatting options that come with an output. Usually, you should use a SuccessResult with Data to return data.

type OutWriter

type OutWriter io.Writer

OutWriter is an alias on io.Writer to disguish "stderr"

type PolicyFlags

type PolicyFlags struct {
	ForceClone, Strict bool
}

PolicyFlags capture user intent about the processing of a build

type Registrant

type Registrant interface {
	RegisterOn(Addable)
}

A Registrant is able to add values to an Addable (implicitly: a Psyringe)

type ScratchDirShell

type ScratchDirShell struct{ *shell.Sh }

ScratchDirShell is a shell for working in the scratch area where things like artefacts, and build metadata are stored. It is a new, empty directory, and should be cleaned up eventually.

type Sous

type Sous struct {
	// CLI is a reference to the CLI singleton. We use it here to set global
	// verbosity.
	CLI *cmdr.CLI
	*sous.LogSet
	// Err is the error message stream.
	Err *ErrOut
	// Version is the version of Sous itself.
	Version semv.Version
	// contains filtered or unexported fields
}

Sous is the main sous command.

func (*Sous) AddFlags

func (s *Sous) AddFlags(fs *flag.FlagSet)

AddFlags adds sous' flags.

func (*Sous) Execute

func (s *Sous) Execute(args []string) cmdr.Result

Execute exists to present a helpful error to the user, in the case they just run 'sous' with not subcommand.

func (*Sous) Help

func (*Sous) Help() string

Help returns the top-level help for Sous.

func (*Sous) RegisterOn

func (s *Sous) RegisterOn(psy Addable)

RegisterOn adds the Sous object itself to the Psyringe

func (*Sous) Subcommands

func (s *Sous) Subcommands() cmdr.Commands

Subcommands returns all the top-level sous subcommands.

type SousBuild

type SousBuild struct {
	DeployFilterFlags
	PolicyFlags

	*sous.BuildManager
}

SousBuild is the command description for `sous build` Implements cmdr.Command, cmdr.Executor and cmdr.AddFlags

func (*SousBuild) AddFlags

func (sb *SousBuild) AddFlags(fs *flag.FlagSet)

func (*SousBuild) Execute

func (sb *SousBuild) Execute(args []string) cmdr.Result

Execute fulfills the cmdr.Executor interface

func (*SousBuild) Help

func (*SousBuild) Help() string

Help returns the help string for this command

func (*SousBuild) RegisterOn

func (sb *SousBuild) RegisterOn(psy Addable)

RegisterOn adds the DeploymentConfig to the psyringe to configure the labeller and registrar

type SousCLIGraph

type SousCLIGraph struct{ *psyringe.Psyringe }

SousCLIGraph is a dependency injector used to flesh out Sous commands with their dependencies.

func BuildGraph

func BuildGraph(c *cmdr.CLI, out, err io.Writer) *SousCLIGraph

BuildGraph builds the dependency injection graph, used to populate commands invoked by the user.

type SousConfig

type SousConfig struct {
	User   LocalUser
	Config LocalSousConfig
}

func (*SousConfig) Execute

func (sc *SousConfig) Execute(args []string) cmdr.Result

func (*SousConfig) Help

func (sc *SousConfig) Help() string

type SousContext

type SousContext struct {
	DeployFilterFlags
	*sous.SourceContext
}

SousContext is the 'sous context' command.

func (*SousContext) AddFlags

func (sc *SousContext) AddFlags(fs *flag.FlagSet)

func (*SousContext) Execute

func (sv *SousContext) Execute(args []string) cmdr.Result

Execute prints the detected sous context.

func (*SousContext) Help

func (*SousContext) Help() string

Help provides help for sous context.

func (*SousContext) RegisterOn

func (sc *SousContext) RegisterOn(psy Addable)

RegisterOn adds the DeploymentConfig to the psyringe to configure the labeller and registrar

type SousHarvest

type SousHarvest struct {
	*sous.State
	sous.Registry
	ErrWriter
}

SousHarvest is the description of the `sous query gdm` command

func (*SousHarvest) Execute

func (sh *SousHarvest) Execute(args []string) cmdr.Result

Execute defines the behavior of `sous query gdm`

func (*SousHarvest) Help

func (*SousHarvest) Help() string

Help prints the help

type SousHelp

type SousHelp struct {
	CLI  *cmdr.CLI
	Sous *Sous
}

func (*SousHelp) Execute

func (sh *SousHelp) Execute(args []string) cmdr.Result

func (*SousHelp) Help

func (sh *SousHelp) Help() string

type SousInit

type SousInit struct {
	DeployFilterFlags
	Flags         OTPLFlags
	Target        TargetManifest
	SourceContext *sous.SourceContext
	WD            LocalWorkDirShell
	GDM           CurrentGDM
	State         *sous.State
	StateWriter   LocalStateWriter
}

SousInit is the command description for `sous init`

func (*SousInit) AddFlags

func (si *SousInit) AddFlags(fs *flag.FlagSet)

AddFlags adds the flags for sous init.

func (*SousInit) Execute

func (si *SousInit) Execute(args []string) cmdr.Result

Execute fulfills the cmdr.Executor interface

func (*SousInit) Help

func (si *SousInit) Help() string

Help returns the help string for this command

func (*SousInit) RegisterOn

func (si *SousInit) RegisterOn(psy Addable)

RegisterOn adds flag sets for sous init to the dependency injector.

type SousQuery

type SousQuery struct {
	Sous *Sous
	// contains filtered or unexported fields
}

func (*SousQuery) AddFlags

func (sb *SousQuery) AddFlags(fs *flag.FlagSet)

func (*SousQuery) Execute

func (sb *SousQuery) Execute(args []string) cmdr.Result

func (*SousQuery) Help

func (*SousQuery) Help() string

func (SousQuery) Subcommands

func (SousQuery) Subcommands() cmdr.Commands

type SousQueryAdc

type SousQueryAdc struct {
	Deployer     sous.Deployer
	Config       LocalSousConfig
	DockerClient LocalDockerClient
	GDM          CurrentGDM
	State        *sous.State
	// contains filtered or unexported fields
}

SousQueryAdc is the description of the `sous query adc` command

func (*SousQueryAdc) Execute

func (sb *SousQueryAdc) Execute(args []string) cmdr.Result

Execute defines the behavior of `sous query adc`

func (*SousQueryAdc) Help

func (*SousQueryAdc) Help() string

Help prints the help

type SousQueryArtifacts

type SousQueryArtifacts struct {
	*sous.RegistryDumper
	ErrWriter
}

SousQueryArtifacts is the description of the `sous query gdm` command

func (*SousQueryArtifacts) Execute

func (sqa *SousQueryArtifacts) Execute(args []string) cmdr.Result

Execute defines the behavior of `sous query gdm`

func (*SousQueryArtifacts) Help

func (*SousQueryArtifacts) Help() string

Help prints the help

type SousQueryGDM

type SousQueryGDM struct {
	GDM CurrentGDM
	// contains filtered or unexported fields
}

SousQueryGDM is the description of the `sous query gdm` command

func (*SousQueryGDM) Execute

func (sb *SousQueryGDM) Execute(args []string) cmdr.Result

Execute defines the behavior of `sous query gdm`

func (*SousQueryGDM) Help

func (*SousQueryGDM) Help() string

Help prints the help

type SousRectify

type SousRectify struct {
	Config       LocalSousConfig
	DockerClient LocalDockerClient
	Deployer     sous.Deployer
	Registry     sous.Registry
	State        *sous.State
	GDM          CurrentGDM
	SourceFlags  DeployFilterFlags
	// contains filtered or unexported fields
}

SousRectify is the injectable command object used for `sous rectify`

func (*SousRectify) AddFlags

func (sr *SousRectify) AddFlags(fs *flag.FlagSet)

AddFlags adds flags for sous rectify

func (*SousRectify) Execute

func (sr *SousRectify) Execute(args []string) cmdr.Result

Execute fulfils the cmdr.Executor interface

func (*SousRectify) Help

func (*SousRectify) Help() string

Help returns the help string

type SousUpdate

type SousUpdate struct {
	DeployFilterFlags
	OTPLFlags
	Manifest TargetManifest
	*sous.SourceContext
	WD          LocalWorkDirShell
	GDM         CurrentGDM
	State       *sous.State
	StateWriter LocalStateWriter
	StateReader LocalStateReader
}

SousUpdate is the command description for `sous update`

func (*SousUpdate) AddFlags

func (su *SousUpdate) AddFlags(fs *flag.FlagSet)

AddFlags adds the flags for sous init.

func (*SousUpdate) Execute

func (su *SousUpdate) Execute(args []string) cmdr.Result

Execute fulfills the cmdr.Executor interface.

func (*SousUpdate) Help

func (su *SousUpdate) Help() string

Help returns the help string for this command

func (*SousUpdate) RegisterOn

func (su *SousUpdate) RegisterOn(psy Addable)

RegisterOn adds the DeploymentConfig to the psyringe to configure the labeller and registrar

type SousVersion

type SousVersion struct {
	Sous *Sous
}

func (*SousVersion) Execute

func (sv *SousVersion) Execute(args []string) cmdr.Result

func (*SousVersion) Help

func (*SousVersion) Help() string

type StateReader

type StateReader interface {
	ReadState() (*sous.State, error)
}

StateReader knows how to read state.

type StateWriter

type StateWriter interface {
	WriteState(*sous.State) error
}

StateWriter know how to write state.

type TargetManifest

type TargetManifest struct{ *sous.Manifest }

TargetManifest is a specific manifest for the current SourceLocation. If the named manifest does not exist, it is created.

type TargetSourceLocation

type TargetSourceLocation sous.SourceLocation

TargetSourceLocation is the source location being targeted, after resolving all context and flags.

type User

type User struct {
	*user.User
}

User represents the user environment of the account running Sous

func (*User) ConfigDir

func (u *User) ConfigDir() string

ConfigDir returns the directory we should use to store Sous configuration data

func (*User) ConfigFile

func (u *User) ConfigFile() string

ConfigFile returns the path to the local Sous config file

func (*User) DefaultConfig

func (u *User) DefaultConfig() Config

DefaultConfig builds a default configuration for this user

type UserSelectedOTPLDeploySpecs

type UserSelectedOTPLDeploySpecs struct{ sous.DeploySpecs }

UserSelectedOTPLDeploySpecs is a set of otpl-deploy configured deploy specs that the user has explicitly selected. (May be empty.)

type Version

type Version struct{ semv.Version }

Version represents a version of Sous.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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