Documentation ¶
Overview ¶
Package choria_registryclient is an API client to the Choria Choria_registry agent Version 0.29.1.
Actions:
- Names - List of all known DDLs for a specific plugin type
- Ddl - Retrieve the DDL for a specific plugin
Index ¶
- Constants
- func DDL() (*agent.DDL, error)
- func DDLBytes() ([]byte, error)
- type BroadcastNS
- 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) Names(inputPluginType string) *NamesRequester
- 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]any
- func (d *DdlOutput) JSON() ([]byte, error)
- func (d *DdlOutput) Name() string
- func (d *DdlOutput) ParseDdlOutput(target any) 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 NamesOutput
- type NamesRequester
- type NamesResult
- 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 inter.Framework, filters []FilterFunc) ([]string, error)
Discover performs the discovery of nodes against the Choria Network
type ChoriaRegistryClient ¶
ChoriaRegistryClient to the choria_registry agent
func Must ¶
func Must(fw inter.Framework, opts ...InitializationOption) (client *ChoriaRegistryClient)
Must create a new client and panics on error
func New ¶
func New(fw inter.Framework, 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) Names ¶ added in v0.25.0
func (p *ChoriaRegistryClient) Names(inputPluginType string) *NamesRequester
Names performs the names action
Description: List of all known DDLs for a specific plugin type
Required Inputs:
- plugin_type (string) - The type of plugin
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) AllOutputs ¶ added in v0.26.0
AllOutputs provide access to all outputs
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 inter.Framework, 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
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 NamesOutput ¶ added in v0.25.0
type NamesOutput struct {
// contains filtered or unexported fields
}
NamesOutput is the output from the names action
func (*NamesOutput) HashMap ¶ added in v0.25.0
func (d *NamesOutput) HashMap() map[string]any
HashMap is the raw output data
func (*NamesOutput) JSON ¶ added in v0.25.0
func (d *NamesOutput) JSON() ([]byte, error)
JSON is the JSON representation of the output data
func (*NamesOutput) Names ¶ added in v0.25.0
func (d *NamesOutput) Names() []any
Names is the value of the names output
Description: The names of all known DDL files
func (*NamesOutput) ParseNamesOutput ¶ added in v0.25.0
func (d *NamesOutput) ParseNamesOutput(target any) error
ParseNamesOutput parses the result value from the Names action into target
func (*NamesOutput) PluginType ¶ added in v0.25.0
func (d *NamesOutput) PluginType() string
PluginType is the value of the plugin_type output
Description: The type of plugin
func (*NamesOutput) ResultDetails ¶ added in v0.25.0
func (d *NamesOutput) ResultDetails() *ResultDetails
ResultDetails is the details about the request
type NamesRequester ¶ added in v0.25.0
type NamesRequester struct {
// contains filtered or unexported fields
}
NamesRequester performs a RPC request to choria_registry#names
func (*NamesRequester) Do ¶ added in v0.25.0
func (d *NamesRequester) Do(ctx context.Context) (*NamesResult, error)
Do performs the request
type NamesResult ¶ added in v0.25.0
type NamesResult struct {
// contains filtered or unexported fields
}
NamesResult is the result from a names action
func (*NamesResult) AllOutputs ¶ added in v0.26.0
func (d *NamesResult) AllOutputs() []*NamesOutput
AllOutputs provide access to all outputs
func (*NamesResult) EachOutput ¶ added in v0.25.0
func (d *NamesResult) EachOutput(h func(r *NamesOutput))
EachOutput iterates over all results received
func (*NamesResult) RenderResults ¶ added in v0.25.0
func (d *NamesResult) RenderResults(w io.Writer, format RenderFormat, displayMode DisplayMode, verbose bool, silent bool, colorize bool, log Log) error
func (*NamesResult) Stats ¶ added in v0.25.0
func (d *NamesResult) Stats() Stats
Stats is the rpc request stats
type NodeSource ¶
type NodeSource interface { Reset() Discover(ctx context.Context, fw inter.Framework, 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 inter.Framework, 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