import "go.chromium.org/luci/lucicfg/cli/base"
Package base contains code shared by other CLI subpackages.
base.go errors.go generate.go validate.go
CollectErrorMessages traverses err (which can be a MultiError, recursively), and appends all error messages there to 'in', returning the resulting slice.
They are eventually used in JSON output and printed to stderr.
func GenerateConfigs(ctx context.Context, inputFile string, meta, flags *lucicfg.Meta) (lucicfg.ConfigSet, error)
GenerateConfigs executes the Starlark script and assembles final values for meta config.
It is a common part of subcommands that generate configs.
'meta' is initial Meta config with default parameters, it will be mutated in-place to contain the final parameters (based on lucicfg.config(...) calls in Starlark and the config populated via CLI flags, passed as 'flags'). 'flags' are also mutated in-place to rebase ConfigDir onto cwd.
MissingFlagError is CommandLineError about a missing flag.
NewCLIError returns new CommandLineError.
func ValidateConfigs(ctx context.Context, cs lucicfg.ConfigSet, meta *lucicfg.Meta, svc ConfigServiceFactory) (*lucicfg.ValidationResult, error)
ValidateConfigs sends the config set to LUCI Config for validation.
It is a common part of subcommands that validate configs.
Dumps validation errors to the logger. Returns an error if the config set is invalid or the RPC call itself failed.
Assumes caller has already verified ConfigServiceHost and ConfigSet meta fields are set.
type CommandLineError struct {
// contains filtered or unexported fields
}
CommandLineError is used to tag errors related to command line arguments.
Subcommand.Done(..., err) will print the usage string if it finds such error.
ConfigServiceFactory returns LUCI Config RPC client that sends requests to the given host.
This is usually just subcommand.ConfigService.
type Parameters struct { AuthOptions auth.Options // mostly for client ID and client secret ConfigServiceHost string // e.g. "luci-config.appspot.com" }
Parameters can be used to customize CLI defaults.
type Subcommand struct { subcommands.CommandRunBase Meta lucicfg.Meta // meta config settable via CLI flags // contains filtered or unexported fields }
Subcommand is a base of all subcommands.
It defines some common flags, such as logging and JSON output parameters, and some common methods to report errors and dump JSON output.
It's Init() method should be called from within CommandRun to register base flags.
func (c *Subcommand) AddMetaFlags()
AddMetaFlags registers c.Meta in the FlagSet.
Used by subcommands that end up executing Starlark.
func (c *Subcommand) CheckArgs(args []string, minPosCount, maxPosCount int) bool
CheckArgs checks command line args.
It ensures all required positional and flag-like parameters are set. Setting maxPosCount to -1 indicates there is unbounded number of positional arguments allowed.
Returns true if they are, or false (and prints to stderr) if not.
ConfigService returns a wrapper around LUCI Config API.
It is ready for making authenticated RPCs. 'host' is a hostname of the service to hit, e.g. "luci-config.appspot.com".
func (c *Subcommand) DefaultMeta() lucicfg.Meta
DefaultMeta returns Meta values to use by default if not overridden via flags or via lucicfg.config(...).
func (c *Subcommand) Done(result interface{}, err error) int
Done is called as the last step of processing a subcommand.
It dumps the command result (or an error) to the JSON output file, prints the error message and generates the process exit code.
func (c *Subcommand) Init(params Parameters)
Init registers common flags.
ModifyContext implements cli.ContextModificator.
Package base imports 18 packages (graph) and is imported by 4 packages. Updated 2019-02-24. Refresh now. Tools for package owners.