package entry
import "github.com/purpleidea/mgmt/entry"
Package entry provides an API to kicking off the initial binary execution. The functions and data structures in this library can be used to package your own custom entry point as a custom application. TODO: Should this be nested inside of lang/ or can it be used for all GAPI's?
Index ¶
- func Register(name string, data *Data)
- type Customizable
- type Data
- type Init
- type Initable
- type Runner
Functions ¶
func Register ¶
Register takes a data struct and stores a reference to it in our entry system along with a name. Future lookups to that name will pull out that data. Register is commonly called in the init() method of the module that defined it, which happens at program startup. Build flags should be used to determine which Register functions should run. Multiple entry data struct can be registered at a time. There is no matching Unregister function at this time.
Types ¶
type Customizable ¶
type Customizable interface { // Customize takes in the full parsed struct, and returns the RunArgs // that we should use for the run operation. // TODO: should the input type be *cli.RunArgs instead? Customize(runArgs interface{}) (*cli.RunArgs, error) }
Customizable is an additional API you can implement to have tighter control over how the entry executes mgmt. TODO: add an API with: func(arg.Config) (*arg.Parser, error) ?
type Data ¶
type Data struct { // Program is the name of this program, usually set at compile time. Program string // Version is the version of this program, usually set at compile time. Version string // Debug represents if we're running in debug mode or not. Debug bool // Logf is a logger which should be used. Logf func(format string, v ...interface{}) // Args is the CLI struct to use. This takes the format of the go-arg // API. Keep in mind that these values will be added on to the normal // run subcommand with frontend that is chosen. Make sure you don't add // anything that would conflict with that. Of note, a new subcommand is // probably not what you want. To do more complicated things, you will // need to implement a different custom API with Customizable. Args interface{} // Frontend is the name of the GAPI to run. Frontend string // Top is the initial input or code to run. Top []byte // Customizable is an additional API you can implement to have tighter // control over how the entry executes mgmt. Custom Customizable }
Data is what a prospective standalone entry program must specify to our API.
func (*Data) Validate ¶
Validate verifies that the structure has acceptable data stored within.
type Init ¶
type Init struct { // Data is the original data that we get from the core compilation. Data *cliUtil.Data Debug bool Logf func(format string, v ...interface{}) }
Init is some data and handles to pass in.
type Initable ¶
type Initable interface { Customizable // Init passes in some data and handles. Init(*Init) error }
Initable lets us have a way to pass in some data and handles if the struct wants them. Implementing this is optional.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner implements the complex plumbing that kicks off the run. The top-level main function should call our Run method. This is all private because it should only get returned by the Lookup method and used as-is.
func Lookup ¶
Lookup takes a name and returns the runner that implements the complex plumbing to kick off the run. If one has not been registered under that name, then this will error.
func (*Runner) CLI ¶
CLI is the entry point for using any embedded package from the CLI. It is used as the main entry point from the top-level main function and kicks-off the CLI parser.
XXX: This function is analogous to the cli/cli.go:CLI() function. Could it be shared with what's there already or extended to get used for the method too?
func (*Runner) Name ¶
Name returns the name of the program, which should match the argv[1] of what we want to use to call this from the top-level main.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 4 days ago –
Tools for package owners.