Documentation
¶
Overview ¶
Package cli implements the Sous Command Line Interface. It is a presentation layer, and contains no core logic.
Index ¶
- Variables
- func AddFlags(fs *flag.FlagSet, target interface{}, help string) error
- func NewSousCLI(v semv.Version, out, errout io.Writer) (*cmdr.CLI, error)
- func ProduceResult(err error) cmdr.Result
- func SuccessYAML(v interface{}) cmdr.Result
- type Addable
- type BuildFlags
- type Config
- type CurrentGDM
- type DeployFilterFlags
- type DeployFlags
- type DetectedOTPLDeploySpecs
- type ErrOut
- type ErrWriter
- type GitSourceContext
- type LocalDockerClient
- type LocalGitClient
- type LocalGitRepo
- type LocalSousConfig
- type LocalStateReader
- type LocalStateWriter
- type LocalUser
- type LocalWorkDir
- type LocalWorkDirShell
- type OTPLFlags
- type Out
- type OutWriter
- type PolicyFlags
- type Registrant
- type ScratchDirShell
- type Sous
- type SousBuild
- type SousCLIGraph
- type SousConfig
- type SousContext
- type SousHarvest
- type SousHelp
- type SousInit
- type SousQuery
- type SousQueryAdc
- type SousQueryArtifacts
- type SousQueryGDM
- type SousRectify
- type SousUpdate
- type SousVersion
- type StateReader
- type StateWriter
- type TargetManifest
- type TargetSourceLocation
- type User
- type UserSelectedOTPLDeploySpecs
- type Version
Constants ¶
This section is empty.
Variables ¶
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.
var QuerySubcommands = cmdr.Commands{}
var TopLevelCommands = cmdr.Commands{}
TopLevelCommands is populated once per command file (beginning sous_) in this directory.
Functions ¶
func AddFlags ¶
AddFlags sniffs out struct fields from target and adds them as var flags to the flag set.
func NewSousCLI ¶
NewSousCLI creates a new Sous cli app.
func ProduceResult ¶
ProduceResult converts errors into Results
func SuccessYAML ¶
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 ¶
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 ¶
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 ¶
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 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 ¶
LocalGitClient is a git client rooted in WorkdirShell.Dir.
type LocalGitRepo ¶
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 LocalWorkDir ¶
type LocalWorkDir string
LocalWorkDir is the user's current working directory when they invoke Sous.
type LocalWorkDirShell ¶
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 ¶
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 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 ¶
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) Execute ¶
Execute exists to present a helpful error to the user, in the case they just run 'sous' with not subcommand.
func (*Sous) RegisterOn ¶
RegisterOn adds the Sous object itself to the Psyringe
func (*Sous) Subcommands ¶
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) RegisterOn ¶
RegisterOn adds the DeploymentConfig to the psyringe to configure the labeller and registrar
type SousCLIGraph ¶
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) 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) 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
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) RegisterOn ¶
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) Subcommands ¶
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
type SousQueryArtifacts ¶
type SousQueryArtifacts struct {
*sous.RegistryDumper
ErrWriter
}
SousQueryArtifacts is the description of the `sous query gdm` command
type SousQueryGDM ¶
type SousQueryGDM struct {
GDM CurrentGDM
// contains filtered or unexported fields
}
SousQueryGDM is the description of the `sous query gdm` command
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
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) 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 ¶
User represents the user environment of the account running Sous
func (*User) ConfigDir ¶
ConfigDir returns the directory we should use to store Sous configuration data
func (*User) ConfigFile ¶
ConfigFile returns the path to the local Sous config file
func (*User) DefaultConfig ¶
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.)
Source Files
¶
- add_flags.go
- cli.go
- config.go
- flags.go
- flags_otpl.go
- flags_source.go
- graph.go
- graph_sourcecontext.go
- graph_targetmanifest.go
- local_config.go
- sous.go
- sous_build.go
- sous_config.go
- sous_context.go
- sous_harvest.go
- sous_help.go
- sous_init.go
- sous_query.go
- sous_query_adc.go
- sous_query_artifacts.go
- sous_query_gdm.go
- sous_rectify.go
- sous_update.go
- sous_version.go
- user.go