event

package
v0.0.0-...-d137978 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = map[*regexp.Regexp]func() Event{
	regexp.MustCompile(`minion/refresh/(?P<id>[^/]+)`):      New[MinionRefresh],
	regexp.MustCompile(`salt/auth`):                         New[MinionAuth],
	regexp.MustCompile(`salt/beacon/[^/]+/(?P<name>[^/]+)`): New[MinionBeacon],
	regexp.MustCompile(`salt/job/\d+/new`):                  New[JobNew],
	regexp.MustCompile(`salt/job/\d+/ret`):                  New[JobReturn],
	regexp.MustCompile(`salt/key`):                          New[MinionKey],
	regexp.MustCompile(`salt/minion/[^/]+/start`):           New[MinionStart],
	regexp.MustCompile(`salt/presence/change`):              New[PresenceChange],
	regexp.MustCompile(`salt/presence/present`):             New[PresencePresent],
}

https://docs.saltstack.com/en/latest/topics/event/master_events.html

Functions

This section is empty.

Types

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

type Event

type Event any

Event represents a parsed event.

func New

func New[T any]() Event

New returns a new event of the specified type.

type HighStateResult

type HighStateResult struct {
	Changes  map[string]any `json:"changes"`
	Comment  string         `json:"comment"`
	Duration Duration       `json:"duration"`
	Function string         `json:"function"`
	ID       string         `json:"__id__"`
	Name     string         `json:"name"`
	Order    int            `json:"__run_num__"`
	Result   bool           `json:"result"`
	SLS      string         `json:"__sls__"`
}

type JobNew

type JobNew struct {
	Arguments  []any         `json:"arg"`
	Function   string        `json:"fun"`
	Job        string        `json:"jid"`
	Minions    []string      `json:"minions"`
	Target     salt.Response `json:"tgt"`
	TargetType string        `json:"tgt_type"`
	Time       Time          `json:"_stamp"`
	User       string        `json:"user"`
}

type JobReturn

type JobReturn struct {
	Arguments  []any         `json:"fun_args"`
	Command    string        `json:"cmd"`
	Function   string        `json:"fun"`
	Job        string        `json:"jid"`
	Minion     string        `json:"id"`
	Output     string        `json:"out"`
	Return     salt.Response `json:"return"`
	ReturnCode int           `json:"retcode"`
	Success    bool          `json:"success"`
	Time       Time          `json:"_stamp"`
}

func (*JobReturn) HighState

func (e *JobReturn) HighState() ([]HighStateResult, error)

HighState parses the job return as a highstate return.

type MinionAuth

type MinionAuth struct {
	Key    string `json:"pub"`
	Minion string `json:"id"`
	Result bool   `json:"result"`
	Status string `json:"act"`
	Time   Time   `json:"_stamp"`
}

type MinionBeacon

type MinionBeacon struct {
	Data   salt.Response `json:"data"`
	Minion string        `json:"id"`
	Name   string        `name:"name"`
	Time   Time          `json:"_stamp"`
}

type MinionKey

type MinionKey struct {
	Minion string `json:"id"`
	Result bool   `json:"result"`
	Status string `json:"act"`
	Time   Time   `json:"_stamp"`
}

type MinionRefresh

type MinionRefresh struct {
	Minion string `name:"id"`
	Time   Time   `json:"_stamp"`
}

type MinionStart

type MinionStart struct {
	Minion string `json:"id"`
	Time   Time   `json:"_stamp"`
}

type Parser

type Parser struct {
	Buffer struct {
		Data salt.Response `json:"data"`
		Tag  string        `json:"tag"`
	}
}

Parser represents an event parser.

func NewParser

func NewParser() *Parser

NewParser returns a new event parser.

func (*Parser) Parse

func (p *Parser) Parse(r salt.Response) (Event, error)

Parse returns the event parsed from the Salt response. If the tag is not registered, then the event will be nil.

type PresenceChange

type PresenceChange struct {
	Lost []string `json:"lost"`
	New  []string `json:"new"`
	Time Time     `json:"_stamp"`
}

type PresencePresent

type PresencePresent struct {
	Minions []string `json:"present"`
	Time    Time     `json:"_stamp"`
}

type Time

type Time struct {
	time.Time
}

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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