Documentation ¶
Overview ¶
Package cmd contains helper abstractions for working with the CLI parser.
Index ¶
- func Content(flagval string) string
- func GetActiveVersion(vs []*fastly.Version) (*fastly.Version, error)
- func GetSpecifiedVersion(vs []*fastly.Version, version string) (*fastly.Version, error)
- func IntToBool(i int) bool
- func ServiceDetails(opts ServiceDetailsOpts) (serviceID string, serviceVersion *fastly.Version, err error)
- type AutoCloneFlagOpts
- type Base
- type Command
- type Globals
- type Optional
- type OptionalAutoClone
- type OptionalBool
- type OptionalInt
- type OptionalServiceVersion
- type OptionalString
- type OptionalStringSlice
- type OptionalUint
- type OptionalUint8
- type Registerer
- type ServiceDetailsOpts
- type ServiceVersionFlagOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Content ¶ added in v0.32.0
Content determines if the given flag value is a file path, and if so read the contents from disk, otherwise presume the given value is the content.
func GetActiveVersion ¶ added in v0.32.0
GetActiveVersion returns the active service version.
func GetSpecifiedVersion ¶ added in v0.32.0
GetSpecifiedVersion returns the specified service version.
func ServiceDetails ¶
func ServiceDetails(opts ServiceDetailsOpts) (serviceID string, serviceVersion *fastly.Version, err error)
ServiceDetails returns the Service ID and Service Version.
Types ¶
type AutoCloneFlagOpts ¶
AutoCloneFlagOpts enables easy configuration of the --autoclone flag defined via the RegisterAutoCloneFlag constructor.
type Base ¶
Base is stuff that should be included in every concrete command.
func (Base) Name ¶
Name implements the Command interface, and returns the FullCommand from the kingpin.Command that's used to select which command to actually run.
func (Base) RegisterAutoCloneFlag ¶ added in v0.32.0
func (b Base) RegisterAutoCloneFlag(opts AutoCloneFlagOpts)
RegisterAutoCloneFlag defines a --autoclone flag that will cause a clone of the identified service version if it's found to be active or locked.
func (Base) RegisterServiceIDFlag ¶ added in v0.32.0
RegisterServiceIDFlag defines a --service-id flag that will attempt to acquire the Service ID from multiple sources.
See: manifest.Data.ServiceID() for the sources.
func (Base) RegisterServiceVersionFlag ¶ added in v0.32.0
func (b Base) RegisterServiceVersionFlag(opts ServiceVersionFlagOpts)
RegisterServiceVersionFlag defines a --version flag that accepts multiple values such as 'latest', 'active' and numerical values which are then converted into the appropriate service version.
type Command ¶
Command is an interface that abstracts over all of the concrete command structs. The Name method lets us select which command should be run, and the Exec method invokes whatever business logic the command should do.
type Globals ¶
Globals are flags and other stuff that's useful to every command. Globals are passed to each concrete command's constructor as a pointer, and are populated after a call to Parse. A concrete command's Exec method can use any of the information in the globals.
type Optional ¶
type Optional struct {
WasSet bool
}
Optional models an optional type that consumers can use to assert whether the inner value has been set and is therefore valid for use.
func (*Optional) Set ¶
func (o *Optional) Set(e *kingpin.ParseElement, c *kingpin.ParseContext) error
Set implements kingpin.Action and is used as callback to set that the optional inner value is valid.
type OptionalAutoClone ¶
type OptionalAutoClone struct {
OptionalBool
}
OptionalAutoClone defines a method set for abstracting the logic required to identify if a given service version needs to be cloned.
func (*OptionalAutoClone) Parse ¶
func (ac *OptionalAutoClone) Parse(v *fastly.Version, sid string, verbose bool, out io.Writer, client api.Interface) (*fastly.Version, error)
Parse returns a service version.
The returned version is either the same as the input argument `v` or it's a cloned version if the input argument was either active or locked.
type OptionalBool ¶
OptionalBool models an optional boolean flag value.
type OptionalInt ¶
OptionalInt models an optional int flag value.
type OptionalServiceVersion ¶
type OptionalServiceVersion struct {
OptionalString
}
OptionalServiceVersion represents a Fastly service version.
type OptionalString ¶
OptionalString models an optional string flag value.
type OptionalStringSlice ¶
OptionalStringSlice models an optional string slice flag value.
type OptionalUint ¶
OptionalUint models an optional uint flag value.
type OptionalUint8 ¶
OptionalUint8 models an optional unit8 flag value.
type Registerer ¶
Registerer abstracts over a kingpin.App and kingpin.CmdClause. We pass it to each concrete command struct's constructor as the "parent" into which the command should install itself.
type ServiceDetailsOpts ¶
type ServiceDetailsOpts struct { AllowActiveLocked bool AutoCloneFlag OptionalAutoClone Client api.Interface Manifest manifest.Data Out io.Writer ServiceVersionFlag OptionalServiceVersion VerboseMode bool }
ServiceDetailsOpts provides data and behaviours required by the ServiceDetails function.
type ServiceVersionFlagOpts ¶
ServiceVersionFlagOpts enables easy configuration of the --version flag defined via the RegisterServiceVersionFlag constructor.
NOTE: The reason we define an 'optional' field rather than a 'required' field is because 99% of the use cases where --version is defined the flag will be required, and so we cater for the common case. Meaning only those subcommands that have --version as optional will need to set that field.