aaa_signerclient

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package aaa_signerclient is an API client to the Choria Aaa_signer agent Version 0.28.0.

Actions:

  • Sign - Signs a RPC Request on behalf of a user

Index

Constants

View Source
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
)
View Source
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

func DDL

func DDL() (*agent.DDL, error)

DDL is a parsed and loaded DDL for the agent

func DDLBytes

func DDLBytes() ([]byte, error)

DDLBytes is the raw JSON encoded DDL file for the agent

Types

type AaaSignerClient

type AaaSignerClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

AaaSignerClient to the aaa_signer agent

func Must

func Must(fw inter.Framework, opts ...InitializationOption) (client *AaaSignerClient)

Must create a new client and panics on error

func New

func New(fw inter.Framework, opts ...InitializationOption) (client *AaaSignerClient, err error)

New creates a new client to the aaa_signer agent

func (*AaaSignerClient) AgentMetadata

func (p *AaaSignerClient) AgentMetadata() *Metadata

AgentMetadata is the agent metadata this client supports

func (*AaaSignerClient) DiscoverNodes

func (p *AaaSignerClient) DiscoverNodes(ctx context.Context) (nodes []string, err error)

DiscoverNodes performs a discovery using the configured filter and node source

func (*AaaSignerClient) OptionAgentFilter

func (p *AaaSignerClient) OptionAgentFilter(a ...string) *AaaSignerClient

OptionAgentFilter adds an agent filter

func (*AaaSignerClient) OptionClassFilter

func (p *AaaSignerClient) OptionClassFilter(f ...string) *AaaSignerClient

OptionClassFilter adds a class filter

func (*AaaSignerClient) OptionCollective

func (p *AaaSignerClient) OptionCollective(c string) *AaaSignerClient

OptionCollective sets the collective to target

func (*AaaSignerClient) OptionCombinedFilter

func (p *AaaSignerClient) OptionCombinedFilter(f ...string) *AaaSignerClient

OptionCombinedFilter adds a combined filter

func (*AaaSignerClient) OptionCompoundFilter

func (p *AaaSignerClient) OptionCompoundFilter(f ...string) *AaaSignerClient

OptionCompoundFilter adds a compound filter

func (*AaaSignerClient) OptionDiscoveryTimeout

func (p *AaaSignerClient) OptionDiscoveryTimeout(t time.Duration) *AaaSignerClient

OptionDiscoveryTimeout configures the request discovery timeout, defaults to configured discovery timeout

func (*AaaSignerClient) OptionExprFilter

func (p *AaaSignerClient) OptionExprFilter(f string) *AaaSignerClient

OptionExprFilter sets a filter expression that will remove results from the result set

func (*AaaSignerClient) OptionFactFilter

func (p *AaaSignerClient) OptionFactFilter(f ...string) *AaaSignerClient

OptionFactFilter adds a fact filter

func (*AaaSignerClient) OptionIdentityFilter

func (p *AaaSignerClient) OptionIdentityFilter(f ...string) *AaaSignerClient

OptionIdentityFilter adds an identity filter

func (*AaaSignerClient) OptionInBatches

func (p *AaaSignerClient) OptionInBatches(size int, sleep int) *AaaSignerClient

OptionInBatches performs requests in batches

func (*AaaSignerClient) OptionLimitMethod

func (p *AaaSignerClient) OptionLimitMethod(m string) *AaaSignerClient

OptionLimitMethod configures the method to use when limiting targets - "random" or "first"

func (*AaaSignerClient) OptionLimitSeed

func (p *AaaSignerClient) OptionLimitSeed(s int64) *AaaSignerClient

OptionLimitSeed sets the random seed used to select targets when limiting and limit method is "random"

func (*AaaSignerClient) OptionLimitSize

func (p *AaaSignerClient) OptionLimitSize(s string) *AaaSignerClient

OptionLimitSize sets limits on the targets, either a number of a percentage like "10%"

func (*AaaSignerClient) OptionReplyTo

func (p *AaaSignerClient) OptionReplyTo(t string) *AaaSignerClient

OptionReplyTo sets a custom reply target

func (*AaaSignerClient) OptionReset

func (p *AaaSignerClient) OptionReset() *AaaSignerClient

OptionReset resets the client options to use across requests to an empty list

func (*AaaSignerClient) OptionTargets

func (p *AaaSignerClient) OptionTargets(t []string) *AaaSignerClient

OptionTargets sets specific node targets which would avoid discovery for all action calls until reset

func (*AaaSignerClient) OptionWorkers

func (p *AaaSignerClient) OptionWorkers(w int) *AaaSignerClient

OptionWorkers sets how many worker connections should be started to the broker

func (*AaaSignerClient) Sign

func (p *AaaSignerClient) Sign(inputRequest string, inputSignature string, inputToken string) *SignRequester

Sign performs the sign action

Description: Signs a RPC Request on behalf of a user

Required Inputs:

  • request (string) - The request to sign
  • signature (string) - A signature produced using the ed25519 seed of the request, hex encoded
  • token (string) - The JWT token authenticating the user

type BroadcastNS

type BroadcastNS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (*BroadcastNS) Reset

func (b *BroadcastNS) Reset()

Reset resets the internal node cache

type DisplayMode

type DisplayMode uint8

DisplayMode overrides the DDL display hints

type ExternalNS

type ExternalNS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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)

func (*ExternalNS) Reset

func (p *ExternalNS) Reset()

Reset resets the internal node cache

type FilterFunc

type FilterFunc func(f *protocol.Filter) error

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

Logger sets the logger to use else one is made via the Choria framework

func Progress

func Progress() InitializationOption

Progress enables displaying a progress bar

type Log

type Log interface {
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
	Panicf(format string, args ...any)
}

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 inter.Framework, _ []FilterFunc) ([]string, error)

Discover performs the discovery of nodes against the Choria Network.

func (*MetaNS) Reset

func (p *MetaNS) Reset()

Reset resets the internal node cache

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 inter.Framework, filters []FilterFunc) ([]string, error)
}

NodeSource discovers nodes

type PuppetDBNS

type PuppetDBNS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func (*PuppetDBNS) Reset

func (p *PuppetDBNS) Reset()

Reset resets the internal node cache

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 renders only the request summary statistics
	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 SignOutput

type SignOutput struct {
	// contains filtered or unexported fields
}

SignOutput is the output from the sign action

func (*SignOutput) HashMap

func (d *SignOutput) HashMap() map[string]any

HashMap is the raw output data

func (*SignOutput) JSON

func (d *SignOutput) JSON() ([]byte, error)

JSON is the JSON representation of the output data

func (*SignOutput) ParseSignOutput

func (d *SignOutput) ParseSignOutput(target any) error

ParseSignOutput parses the result value from the Sign action into target

func (*SignOutput) ResultDetails

func (d *SignOutput) ResultDetails() *ResultDetails

ResultDetails is the details about the request

func (*SignOutput) SecureRequest

func (d *SignOutput) SecureRequest() string

SecureRequest is the value of the secure_request output

Description: The signed Secure Request

type SignRequester

type SignRequester struct {
	// contains filtered or unexported fields
}

SignRequester performs a RPC request to aaa_signer#sign

func (*SignRequester) Do

func (d *SignRequester) Do(ctx context.Context) (*SignResult, error)

Do performs the request

type SignResult

type SignResult struct {
	// contains filtered or unexported fields
}

SignResult is the result from a sign action

func (*SignResult) AllOutputs added in v0.26.0

func (d *SignResult) AllOutputs() []*SignOutput

AllOutputs provide access to all outputs

func (*SignResult) EachOutput

func (d *SignResult) EachOutput(h func(r *SignOutput))

EachOutput iterates over all results received

func (*SignResult) RenderResults

func (d *SignResult) RenderResults(w io.Writer, format RenderFormat, displayMode DisplayMode, verbose bool, silent bool, colorize bool, log Log) error

func (*SignResult) Stats

func (d *SignResult) Stats() Stats

Stats is the rpc request stats

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL