pluginswatcher

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: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PublicKey allows a public key to be compiled in to the binary during CI while using a standard
	// compiled in machine.yaml, effectively this is equivalent to setting the public_key property
	PublicKey = ""
)

Functions

func ChoriaPlugin

func ChoriaPlugin() *plugin.WatcherPlugin

func New

func New(machine model.Machine, name string, states []string, failEvent string, successEvent string, interval string, ai time.Duration, rawprop map[string]any) (any, error)

Types

type ManagedPlugin

type ManagedPlugin struct {
	Name                     string `json:"name" yaml:"name"`
	NamePrefix               string `json:"-" yaml:"-"`
	Source                   string `json:"source" yaml:"source"`
	Username                 string `json:"username,omitempty" yaml:"username"`
	Password                 string `json:"password,omitempty" yaml:"password"`
	ContentChecksumsChecksum string `json:"verify_checksum" yaml:"verify_checksum" mapstructure:"verify_checksum"`
	ArchiveChecksum          string `json:"checksum" yaml:"checksum" mapstructure:"checksum"`
	Matcher                  string `json:"match,omitempty" yaml:"match" mapstructure:"match"`
	Governor                 string `json:"governor,omitempty" yaml:"governor" mapstructure:"governor"`

	Interval string `json:"-"`
	Target   string `json:"-"`
}

type Properties

type Properties struct {
	// DataItem is the data item key to get ManagedPlugin from, typically sourced from Key-Value store
	DataItem string `mapstructure:"data_item"`
	// PurgeUnknown will remove plugins not declared in DataItem
	PurgeUnknown bool `mapstructure:"purge_unknown"`
	// PluginManageInterval is the interval that created management machines will use to manage their archives
	PluginManageInterval time.Duration `mapstructure:"plugin_manage_interval"`
	// PublicKey is the optional ed25519 public key used to sign the specification, when set
	// the specification received will be validated and any invalid specification will be discarded
	PublicKey string `mapstructure:"public_key"`
	// Directory sets the directory where plugins are being deployed into, when empty defaults to plugins directory like /etc/choria/machines
	Directory string `mapstructure:"plugins_directory"`
	// ManagerMachinePrefix the prefix used in constructing names for the management machines
	ManagerMachinePrefix string `mapstructure:"manager_machine_prefix"`
}

type Specification

type Specification struct {
	Plugins   string `json:"plugins"`
	Signature string `json:"signature,omitempty"`
}

Specification holds []ManagedPlugin marshaled to JSON with an optional ed25519 signature

func (*Specification) Encode

func (s *Specification) Encode(key string) ([]byte, error)

Encode sets the signature and Marshals the specification to JSON, if key is empty signature is not made

func (*Specification) VerifySignature

func (s *Specification) VerifySignature(key ed25519.PublicKey) (bool, error)

VerifySignature verifies that the data is signed using the supplied key

type State

type State int
const (
	Unknown State = iota
	Skipped
	Error
	Updated
	Unchanged
)

type StateNotification

type StateNotification struct {
	event.Event

	PreviousManagedPlugins []string `json:"plugins"`
	PreviousOutcome        string   `json:"previous_outcome"`
	PreviousRunTime        int64    `json:"previous_run_time"`
}

StateNotification describes the current state of the watcher described by io.choria.machine.watcher.exec.v1.state

func (*StateNotification) CloudEvent

func (s *StateNotification) CloudEvent() cloudevents.Event

CloudEvent creates a CloudEvent from the state notification

func (*StateNotification) JSON

func (s *StateNotification) JSON() ([]byte, error)

JSON creates a JSON representation of the notification

func (*StateNotification) String

func (s *StateNotification) String() string

String is a string representation of the notification suitable for printing

type Watcher

type Watcher struct {
	*watcher.Watcher
	// contains filtered or unexported fields
}

func (*Watcher) CurrentState

func (w *Watcher) CurrentState() any

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context, wg *sync.WaitGroup)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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