Documentation
¶
Overview ¶
Package choria_registryclient is an API client to the Choria Choria_registry agent Version 0.23.0.
Actions:
- Ddl - Retrieve the DDL for a specific plugin
Index ¶
- Constants
- func DDL() (*agent.DDL, error)
- func DDLBytes() ([]byte, error)
- type BroadcastNS
- type ChoriaFramework
- type ChoriaRegistryClient
- func (p *ChoriaRegistryClient) AgentMetadata() *Metadata
- func (p *ChoriaRegistryClient) Ddl(inputName string, inputPluginType string) *DdlRequester
- func (p *ChoriaRegistryClient) DiscoverNodes(ctx context.Context) (nodes []string, err error)
- func (p *ChoriaRegistryClient) OptionAgentFilter(a ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionClassFilter(f ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionCollective(c string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionCombinedFilter(f ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionCompoundFilter(f ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionDiscoveryTimeout(t time.Duration) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionExprFilter(f string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionFactFilter(f ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionIdentityFilter(f ...string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionInBatches(size int, sleep int) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionLimitMethod(m string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionLimitSeed(s int64) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionLimitSize(s string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionReplyTo(t string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionReset() *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionTargets(t []string) *ChoriaRegistryClient
- func (p *ChoriaRegistryClient) OptionWorkers(w int) *ChoriaRegistryClient
- type DdlOutput
- func (d *DdlOutput) Ddl() string
- func (d *DdlOutput) HashMap() map[string]interface{}
- func (d *DdlOutput) JSON() ([]byte, error)
- func (d *DdlOutput) Name() string
- func (d *DdlOutput) ParseDdlOutput(target interface{}) error
- func (d *DdlOutput) PluginType() string
- func (d *DdlOutput) ResultDetails() *ResultDetails
- func (d *DdlOutput) Version() string
- type DdlRequester
- type DdlResult
- type DisplayMode
- type ExternalNS
- type FilterFunc
- type InitializationOption
- type Log
- type MetaNS
- type Metadata
- type NodeSource
- type PuppetDBNS
- type RenderFormat
- type ResultDetails
- type Stats
- type StatusCode
Constants ¶
const ( // DisplayDDL shows results based on the configuration in the DDL file DisplayDDL = DisplayMode(iota) // DisplayOK shows only passing results DisplayOK // DisplayFailed shows only failed results DisplayFailed // DisplayAll shows all results DisplayAll // DisplayNone shows no results DisplayNone )
const ( // OK is the reply status when all worked OK = StatusCode(iota) // Aborted is status for when the action could not run, most failures in an action should set this Aborted // UnknownAction is the status for unknown actions requested UnknownAction // MissingData is the status for missing input data MissingData // InvalidData is the status for invalid input data InvalidData // UnknownError is the status general failures in agents should set when things go bad UnknownError )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BroadcastNS ¶
BroadcastNS is a NodeSource that uses the Choria network broadcast method to discover nodes
func (*BroadcastNS) Discover ¶
func (b *BroadcastNS) Discover(ctx context.Context, fw ChoriaFramework, filters []FilterFunc) ([]string, error)
Discover performs the discovery of nodes against the Choria Network
type ChoriaFramework ¶
type ChoriaFramework interface { Logger(string) *logrus.Entry SetLogger(*logrus.Logger) Configuration() *config.Config NewMessage(payload string, agent string, collective string, msgType string, request inter.Message) (msg inter.Message, err error) NewReplyFromTransportJSON(payload []byte, skipvalidate bool) (msg protocol.Reply, err error) NewTransportFromJSON(data string) (message protocol.TransportMessage, err error) MiddlewareServers() (servers srvcache.Servers, err error) NewConnector(ctx context.Context, servers func() (srvcache.Servers, error), name string, logger *logrus.Entry) (conn inter.Connector, err error) NewRequestID() (string, error) Certname() string PQLQueryCertNames(query string) ([]string, error) Colorize(c string, format string, a ...interface{}) string ProgressWidth() int }
ChoriaFramework is the Choria framework
type ChoriaRegistryClient ¶
ChoriaRegistryClient to the choria_registry agent
func Must ¶
func Must(fw ChoriaFramework, opts ...InitializationOption) (client *ChoriaRegistryClient)
Must create a new client and panics on error
func New ¶
func New(fw ChoriaFramework, opts ...InitializationOption) (client *ChoriaRegistryClient, err error)
New creates a new client to the choria_registry agent
func (*ChoriaRegistryClient) AgentMetadata ¶
func (p *ChoriaRegistryClient) AgentMetadata() *Metadata
AgentMetadata is the agent metadata this client supports
func (*ChoriaRegistryClient) Ddl ¶
func (p *ChoriaRegistryClient) Ddl(inputName string, inputPluginType string) *DdlRequester
Ddl performs the ddl action
Description: Retrieve the DDL for a specific plugin
Required Inputs:
- name (string) - The name of the plugin
- plugin_type (string) - The type of plugin
Optional Inputs:
- format (string) - The result format the plugin should be retrieved in
func (*ChoriaRegistryClient) DiscoverNodes ¶
func (p *ChoriaRegistryClient) DiscoverNodes(ctx context.Context) (nodes []string, err error)
DiscoverNodes performs a discovery using the configured filter and node source
func (*ChoriaRegistryClient) OptionAgentFilter ¶
func (p *ChoriaRegistryClient) OptionAgentFilter(a ...string) *ChoriaRegistryClient
OptionAgentFilter adds an agent filter
func (*ChoriaRegistryClient) OptionClassFilter ¶
func (p *ChoriaRegistryClient) OptionClassFilter(f ...string) *ChoriaRegistryClient
OptionClassFilter adds a class filter
func (*ChoriaRegistryClient) OptionCollective ¶
func (p *ChoriaRegistryClient) OptionCollective(c string) *ChoriaRegistryClient
OptionCollective sets the collective to target
func (*ChoriaRegistryClient) OptionCombinedFilter ¶
func (p *ChoriaRegistryClient) OptionCombinedFilter(f ...string) *ChoriaRegistryClient
OptionCombinedFilter adds a combined filter
func (*ChoriaRegistryClient) OptionCompoundFilter ¶
func (p *ChoriaRegistryClient) OptionCompoundFilter(f ...string) *ChoriaRegistryClient
OptionCompoundFilter adds a compound filter
func (*ChoriaRegistryClient) OptionDiscoveryTimeout ¶
func (p *ChoriaRegistryClient) OptionDiscoveryTimeout(t time.Duration) *ChoriaRegistryClient
OptionDiscoveryTimeout configures the request discovery timeout, defaults to configured discovery timeout
func (*ChoriaRegistryClient) OptionExprFilter ¶
func (p *ChoriaRegistryClient) OptionExprFilter(f string) *ChoriaRegistryClient
OptionExprFilter sets a filter expression that will remove results from the result set
func (*ChoriaRegistryClient) OptionFactFilter ¶
func (p *ChoriaRegistryClient) OptionFactFilter(f ...string) *ChoriaRegistryClient
OptionFactFilter adds a fact filter
func (*ChoriaRegistryClient) OptionIdentityFilter ¶
func (p *ChoriaRegistryClient) OptionIdentityFilter(f ...string) *ChoriaRegistryClient
OptionIdentityFilter adds an identity filter
func (*ChoriaRegistryClient) OptionInBatches ¶
func (p *ChoriaRegistryClient) OptionInBatches(size int, sleep int) *ChoriaRegistryClient
OptionInBatches performs requests in batches
func (*ChoriaRegistryClient) OptionLimitMethod ¶
func (p *ChoriaRegistryClient) OptionLimitMethod(m string) *ChoriaRegistryClient
OptionLimitMethod configures the method to use when limiting targets - "random" or "first"
func (*ChoriaRegistryClient) OptionLimitSeed ¶
func (p *ChoriaRegistryClient) OptionLimitSeed(s int64) *ChoriaRegistryClient
OptionLimitSeed sets the random seed used to select targets when limiting and limit method is "random"
func (*ChoriaRegistryClient) OptionLimitSize ¶
func (p *ChoriaRegistryClient) OptionLimitSize(s string) *ChoriaRegistryClient
OptionLimitSize sets limits on the targets, either a number of a percentage like "10%"
func (*ChoriaRegistryClient) OptionReplyTo ¶
func (p *ChoriaRegistryClient) OptionReplyTo(t string) *ChoriaRegistryClient
OptionReplyTo sets a custom reply target
func (*ChoriaRegistryClient) OptionReset ¶
func (p *ChoriaRegistryClient) OptionReset() *ChoriaRegistryClient
OptionReset resets the client options to use across requests to an empty list
func (*ChoriaRegistryClient) OptionTargets ¶
func (p *ChoriaRegistryClient) OptionTargets(t []string) *ChoriaRegistryClient
OptionTargets sets specific node targets which would avoid discovery for all action calls until reset
func (*ChoriaRegistryClient) OptionWorkers ¶
func (p *ChoriaRegistryClient) OptionWorkers(w int) *ChoriaRegistryClient
OptionWorkers sets how many worker connections should be started to the broker
type DdlOutput ¶
type DdlOutput struct {
// contains filtered or unexported fields
}
DdlOutput is the output from the ddl action
func (*DdlOutput) Ddl ¶
Ddl is the value of the ddl output
Description: The plugin DDL in the requested format
func (*DdlOutput) ParseDdlOutput ¶
ParseDdlOutput parses the result value from the Ddl action into target
func (*DdlOutput) PluginType ¶
PluginType is the value of the plugin_type output
Description: The type of plugin
func (*DdlOutput) ResultDetails ¶
func (d *DdlOutput) ResultDetails() *ResultDetails
ResultDetails is the details about the request
type DdlRequester ¶
type DdlRequester struct {
// contains filtered or unexported fields
}
DdlRequester performs a RPC request to choria_registry#ddl
func (*DdlRequester) Do ¶
func (d *DdlRequester) Do(ctx context.Context) (*DdlResult, error)
Do performs the request
func (*DdlRequester) Format ¶
func (d *DdlRequester) Format(v string) *DdlRequester
Format is an optional input to the ddl action
Description: The result format the plugin should be retrieved in
type DdlResult ¶
type DdlResult struct {
// contains filtered or unexported fields
}
DdlResult is the result from a ddl action
func (*DdlResult) EachOutput ¶
EachOutput iterates over all results received
func (*DdlResult) RenderResults ¶
func (d *DdlResult) RenderResults(w io.Writer, format RenderFormat, displayMode DisplayMode, verbose bool, silent bool, colorize bool, log Log) error
type ExternalNS ¶
ExternalNS is a NodeSource that calls an external command for discovery
func (*ExternalNS) Discover ¶
func (p *ExternalNS) Discover(ctx context.Context, fw ChoriaFramework, filters []FilterFunc) ([]string, error)
type FilterFunc ¶
FilterFunc can generate a Choria filter
type InitializationOption ¶
type InitializationOption func(opts *initOptions)
InitializationOption is an optional setting used to initialize the client
func Discovery ¶
func Discovery(ns NodeSource) InitializationOption
Discovery sets the NodeSource to use when finding nodes to manage
func DiscoveryMethod ¶
func DiscoveryMethod(m string) InitializationOption
DiscoveryMethod accepts a discovery method name as supplied from the CLI and configures the correct NodeSource reverts to broadcast method if an unsupported method is supplied, custom node sources can be set using Discovery()
func DiscoveryTimeout ¶
func DiscoveryTimeout(t time.Duration) InitializationOption
DiscoveryTimeout sets a timeout for discovery for those methods that support it
func Logger ¶
func Logger(l *logrus.Entry) InitializationOption
Logger sets the logger to use else one is made via the Choria framework
type MetaNS ¶
type MetaNS struct { // Options is the CLI options to discover based on Options *discovery.StandardOptions // Agent should be the agent the request is targeted at Agent string // DisablePipedDiscovery prevents the STDIN being used as a discovery source DisablePipedDiscovery bool sync.Mutex // contains filtered or unexported fields }
MetaNS is a NodeSource that assists CLI tools in creating Choria standard command line based discovery.
func NewMetaNS ¶
func NewMetaNS(opts *discovery.StandardOptions, enablePipeMode bool) *MetaNS
NewMetaNS creates a new meta discovery node source
func (*MetaNS) Discover ¶
func (p *MetaNS) Discover(ctx context.Context, fw ChoriaFramework, _ []FilterFunc) ([]string, error)
Discover performs the discovery of nodes against the Choria Network.
type Metadata ¶
type Metadata struct { License string `json:"license"` Author string `json:"author"` Timeout int `json:"timeout"` Name string `json:"name"` Version string `json:"version"` URL string `json:"url"` Description string `json:"description"` }
Metadata is the agent metadata
type NodeSource ¶
type NodeSource interface { Reset() Discover(ctx context.Context, fw ChoriaFramework, filters []FilterFunc) ([]string, error) }
NodeSource discovers nodes
type PuppetDBNS ¶
PuppetDBNS is a NodeSource that uses the PuppetDB PQL Queries to discover nodes
func (*PuppetDBNS) Discover ¶
func (p *PuppetDBNS) Discover(ctx context.Context, fw ChoriaFramework, filters []FilterFunc) ([]string, error)
Discover performs the discovery of nodes against the Choria Network
type RenderFormat ¶
type RenderFormat int
RenderFormat is the format used by the RenderResults helper
const ( // JSONFormat renders the results as a JSON document JSONFormat RenderFormat = iota // TextFormat renders the results as a Choria typical result set in line with choria req output TextFormat // TableFormat renders all successful responses in a table TableFormat TXTFooter )
type ResultDetails ¶
type ResultDetails struct {
// contains filtered or unexported fields
}
ResultDetails is the details about a result
func (*ResultDetails) OK ¶
func (d *ResultDetails) OK() bool
OK determines if the request was successful
func (*ResultDetails) Sender ¶
func (d *ResultDetails) Sender() string
Sender is the identity of the remote that produced the message
func (*ResultDetails) StatusCode ¶
func (d *ResultDetails) StatusCode() StatusCode
StatusCode is the status code produced by the remote
func (*ResultDetails) StatusMessage ¶
func (d *ResultDetails) StatusMessage() string
StatusMessage is the status message produced by the remote
type Stats ¶
type Stats interface { Agent() string Action() string All() bool NoResponseFrom() []string UnexpectedResponseFrom() []string DiscoveredCount() int DiscoveredNodes() *[]string FailCount() int OKCount() int ResponsesCount() int PublishDuration() (time.Duration, error) RequestDuration() (time.Duration, error) DiscoveryDuration() (time.Duration, error) OverrideDiscoveryTime(start time.Time, end time.Time) UniqueRequestID() string }
Stats are the statistics for a request
type StatusCode ¶
type StatusCode uint8
StatusCode is a reply status as defined by MCollective SimpleRPC - integers 0 to 5
See the constants OK, RPCAborted, UnknownRPCAction, MissingRPCData, InvalidRPCData and UnknownRPCError