Documentation ¶
Index ¶
- Variables
- func BackendNames() []string
- func ConfigMap(backendInfo *RegInfo, configName string) (config *configmap.Map)
- func ConfigToEnv(section, name string) string
- func OptionToEnv(name string) string
- func Register(info *RegInfo)
- func ToMap(m interface{}) (map[string]interface{}, error)
- type Backend
- type CommandHelp
- type Commander
- type ConfigInfo
- type FlattenData
- type Instance
- type Model
- type Option
- type OptionExample
- type OptionExamples
- type OptionVisibility
- type Options
- type Printable
- type RegInfo
Constants ¶
This section is empty.
Variables ¶
var ( // Read a value from the config file // // This is a function pointer to decouple the config // implementation from the fs ConfigFileGet = func(section, key string) (string, bool) { return "", false } // Set a value into the config file and persist it // // This is a function pointer to decouple the config // implementation from the fs ConfigFileSet = func(section, key, value string) (err error) { return errors.New("no config file set handler") } )
Global
var ( // Registry Backend registry Registry []*RegInfo )
Functions ¶
func BackendNames ¶
func BackendNames() []string
func ConfigToEnv ¶
ConfigToEnv converts a config section and name, e.g. ("myremote", "ignore-size") into an environment name "HONEY_CONFIG_MYREMOTE_IGNORE_SIZE"
func OptionToEnv ¶
OptionToEnv converts an option name, e.g. "ignore-size" into an environment name "HONEY_IGNORE_SIZE"
Types ¶
type Backend ¶
type Backend interface { Name() string CacheKeyName(pattern string) string List(ctx context.Context, backendName string, pattern string) (Printable, error) }
Backend _
type CommandHelp ¶
type CommandHelp struct { Name string // Name of the command, e.g. "link" Short string // Single line description Long string // Long multi-line description Opts map[string]string // maps option name to a single line help }
CommandHelp describes a single backend Command
These are automatically inserted in the docs
type Commander ¶
type Commander interface { // Command the backend to run a named command // // The command run is name // args may be used to read arguments from // opts may be used to read optional arguments from // // The result should be capable of being JSON encoded // If it is a string or a []string it will be shown to the user // otherwise it will be JSON encoded and shown to the user like that Command(ctx context.Context, name string, arg []string, opt map[string]string) (interface{}, error) }
Commander is an interface to wrap the Command function
type ConfigInfo ¶
type ConfigInfo struct { NoCache bool NoColor bool OutFormat string BackendsString string CacheTTL time.Duration }
ConfigInfo is honey config options
func AddConfig ¶
func AddConfig(ctx context.Context) (context.Context, *ConfigInfo)
AddConfig returns a mutable config structure based on a shallow copy of that found in ctx and returns a new context with that added to it.
func GetConfig ¶
func GetConfig(ctx context.Context) *ConfigInfo
GetConfig returns the global or context sensitive context
func NewConfig ¶
func NewConfig() *ConfigInfo
func (*ConfigInfo) Backends ¶ added in v0.1.8
func (c *ConfigInfo) Backends() ([]string, error)
type FlattenData ¶
func (*FlattenData) Filter ¶
func (d *FlattenData) Filter(keys []string) ([]map[string]interface{}, error)
func (*FlattenData) ToArrayMap ¶ added in v0.1.6
func (d *FlattenData) ToArrayMap() ([]map[string]interface{}, error)
type Model ¶
type Model struct { ID string `json:"id"` BackendName string `json:"backend_name" mapstructure:"backend_name"` Name string `json:"name"` Type string `json:"type"` Status string `json:"status"` PrivateIP string `json:"private_ip" mapstructure:"private_ip"` PublicIP string `json:"public_ip" mapstructure:"public_ip"` }
type Option ¶
type Option struct { Name string // name of the option in snake_case Help string // Help, the first line only is used for the command line help Provider string // Set to filter on provider Default interface{} // default value, nil => "" Value interface{} // value to be set by flags Examples OptionExamples `json:",omitempty"` // config examples ShortOpt string // the short option for this if required Hide OptionVisibility // set this to hide the config from the configurator or the command line Required bool // this option is required IsPassword bool // set if the option is a passwords NoPrefix bool // set if the option for this should not use the backend prefix Advanced bool // set if this is an advanced config option }
Option _
func (*Option) EnvVarName ¶
EnvVarName for the option
type OptionExample ¶
OptionExample describes an example for an Option
type OptionExamples ¶
type OptionExamples []OptionExample
OptionExamples is a slice of examples
func (OptionExamples) Less ¶
func (os OptionExamples) Less(i, j int) bool
Less is part of sort.Interface.
func (OptionExamples) Swap ¶
func (os OptionExamples) Swap(i, j int)
Swap is part of sort.Interface.
type OptionVisibility ¶
type OptionVisibility byte
OptionVisibility controls whether the options are visible in the configurator or the command line.
const ( OptionHideCommandLine OptionVisibility = 1 << iota OptionHideConfigurator OptionHideBoth = OptionHideCommandLine | OptionHideConfigurator )
Constants Option.Hide
type Printable ¶
type Printable []*Instance
func (Printable) FlattenData ¶
func (p Printable) FlattenData() (*FlattenData, error)
type RegInfo ¶
type RegInfo struct { // Name of this backend Name string // Description of this fs - defaults to Name Description string // Prefix for command line flags for this fs - defaults to Name if not set Prefix string NewBackend func(ctx context.Context, config configmap.Mapper) (Backend, error) `json:"-"` // Function to call to help with config Config func(ctx context.Context, name string, config configmap.Mapper) `json:"-"` // Options for the Backend configuration Options Options // The command help, if any CommandHelp []CommandHelp }
RegInfo _