model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePlaybook

func ParsePlaybook(entryFile string, readFile ReadFile, book *Playbook) error

Types

type Action

type Action struct {
	ID     types.ActionID   `json:"id"`
	Name   string           `json:"name"`
	Uses   types.ActionName `json:"uses"`
	Args   ActionArgs       `json:"args"`
	Force  bool             `json:"force"`
	Abort  bool             `json:"abort"`
	Commit []Commit         `json:"commit"`
}

func (Action) Copy

func (x Action) Copy() Action

type ActionArgs

type ActionArgs map[string]any

func (ActionArgs) Parse

func (x ActionArgs) Parse(psr ...ArgParser) error

type ActionLog

type ActionLog struct {
	Seq int `json:"seq"`
	Action
}

type ActionRecord

type ActionRecord struct {
	ID         string            `json:"id"`
	Seq        int               `json:"seq"`
	Uses       string            `json:"uses"`
	Args       []*ArgumentRecord `json:"args"`
	Result     *string           `json:"result,omitempty"`
	Next       []*NextRecord     `json:"next"`
	Error      *string           `json:"error,omitempty"`
	StartedAt  time.Time         `json:"startedAt"`
	FinishedAt time.Time         `json:"finishedAt"`
}

type ActionResult

type ActionResult struct {
	Action
	Result any `json:"result,omitempty"`
	Attrs  Attributes
}

type ActionRunRequest

type ActionRunRequest struct {
	Alert   Alert          `json:"alert"`
	EnvVars types.EnvVars  `json:"env" masq:"secret"`
	Seq     int            `json:"seq"`
	Called  []ActionResult `json:"called"`
}

type ActionRunResponse

type ActionRunResponse struct {
	Runs []Action `json:"run"`
}

type Alert

type Alert struct {
	AlertMetaData
	ID        types.AlertID `json:"id"`
	Schema    types.Schema  `json:"schema"`
	Data      any           `json:"data,omitempty"`
	CreatedAt time.Time     `json:"created_at"`

	// Raw is a JSON string of Data. The field will be redacted by masq because of verbosity.
	Raw string `json:"raw,omitempty" masq:"quiet"`
}

func NewAlert

func NewAlert(meta AlertMetaData, schema types.Schema, data any) Alert

func (Alert) Copy

func (x Alert) Copy() Alert

type AlertMetaData

type AlertMetaData struct {
	Title       string          `json:"title"`
	Description string          `json:"description"`
	Source      string          `json:"source"`
	Namespace   types.Namespace `json:"namespace"`
	Attrs       Attributes      `json:"attrs"`
	Refs        References      `json:"refs"`
}

func (AlertMetaData) Copy

func (x AlertMetaData) Copy() AlertMetaData

type AlertPolicyResult

type AlertPolicyResult struct {
	Alerts []AlertMetaData `json:"alert"`
}

type AlertRecord

type AlertRecord struct {
	ID          types.AlertID      `json:"id"`
	Schema      string             `json:"schema"`
	Data        string             `json:"data"`
	CreatedAt   time.Time          `json:"createdAt"`
	Title       string             `json:"title"`
	Description string             `json:"description"`
	Source      string             `json:"source"`
	Namespace   *string            `json:"namespace,omitempty"`
	InitAttrs   []*AttributeRecord `json:"initAttrs"`
	LastAttrs   []*AttributeRecord `json:"lastAttrs"`
	Refs        []*ReferenceRecord `json:"refs"`
}

type ArgOption

type ArgOption func(*argParserOption)

func ArgOptional

func ArgOptional() ArgOption

type ArgParser

type ArgParser func(args ActionArgs) error

func ArgDef

func ArgDef[T any](key string, dst *T, options ...ArgOption) ArgParser

type ArgumentRecord

type ArgumentRecord struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Attribute

type Attribute struct {
	ID      types.AttrID    `json:"id" firestore:"id"`
	Key     types.AttrKey   `json:"key" firestore:"key"`
	Value   types.AttrValue `json:"value" firestore:"value"`
	Type    types.AttrType  `json:"type" firestore:"type"`
	Persist bool            `json:"persist" firestore:"persist"`
	TTL     int             `json:"ttl" firestore:"ttl"`
}

type AttributeRecord

type AttributeRecord struct {
	ID      string  `json:"id"`
	Key     string  `json:"key"`
	Value   string  `json:"value"`
	Type    *string `json:"type,omitempty"`
	Persist bool    `json:"persist"`
	TTL     int     `json:"ttl"`
}

type Attributes

type Attributes []Attribute

func (Attributes) Copy

func (x Attributes) Copy() Attributes

func (Attributes) Tidy

func (x Attributes) Tidy() Attributes

type Clock

type Clock func() time.Time

type Commit

type Commit struct {
	Attribute
	Path string `json:"path"`
}

func (*Commit) ToAttr

func (x *Commit) ToAttr(data any) (*Attribute, error)

type Event

type Event struct {
	Input   any                        `json:"input"`
	Schema  types.Schema               `json:"schema"`
	Actions map[types.ActionName][]any `json:"actions"`
	// contains filtered or unexported fields
}

func (*Event) GetResult

func (x *Event) GetResult(actionName types.ActionName) any

func (*Event) Validate

func (x *Event) Validate() error

type NextRecord

type NextRecord struct {
	Abort bool               `json:"abort"`
	Attrs []*AttributeRecord `json:"attrs"`
}

type PlayLog

type PlayLog struct {
	Alert Alert `json:"alert"`

	Actions []*ActionLog `json:"actions"`
}

type Playbook

type Playbook struct {
	Scenarios []*Scenario `json:"scenarios"`
}

func (*Playbook) Validate

func (x *Playbook) Validate() error

type PubSubMessage

type PubSubMessage struct {
	Attributes  map[string]string `json:"attributes"`
	Data        []byte            `json:"data"`
	MessageID   string            `json:"message_id"`
	PublishTime string            `json:"publish_time"`
}

type PubSubRequest

type PubSubRequest struct {
	DeliveryAttempt int64         `json:"deliveryAttempt"`
	Message         PubSubMessage `json:"message"`
	Subscription    string        `json:"subscription"`
}

type Query added in v0.1.1

type Query struct {
}

type ReadFile

type ReadFile func(name string) ([]byte, error)

type Reference

type Reference struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

func (Reference) Copy

func (r Reference) Copy() Reference

type ReferenceRecord

type ReferenceRecord struct {
	Title *string `json:"title,omitempty"`
	URL   *string `json:"url,omitempty"`
}

type References

type References []Reference

func (References) Copy

func (refs References) Copy() References

type Scenario

type Scenario struct {
	ID     types.ScenarioID    `json:"id"`
	Title  types.ScenarioTitle `json:"title"`
	Events []Event             `json:"events"`
	Env    types.EnvVars       `json:"env"`
}

func ParseScenario

func ParseScenario(entryFile string, readFile ReadFile) (*Scenario, error)

func (*Scenario) ToLog

func (x *Scenario) ToLog() ScenarioLog

func (*Scenario) Validate

func (x *Scenario) Validate() error

type ScenarioLog

type ScenarioLog struct {
	ID    types.ScenarioID    `json:"id"`
	Title types.ScenarioTitle `json:"title"`

	Results []*PlayLog `json:"results,omitempty"`
	Error   string     `json:"error,omitempty"`
}

type WorkflowRecord

type WorkflowRecord struct {
	ID        types.WorkflowID `json:"id"`
	CreatedAt time.Time        `json:"createdAt"`
	Alert     *AlertRecord     `json:"alert"`
	Actions   []*ActionRecord  `json:"actions"`
}

Jump to

Keyboard shortcuts

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