store

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSubscription = errors.New("no subscription in the provided context")

ErrNoSubscription indicates that the subscription in the provided context was not found.

Functions

func Evaluate

func Evaluate(v lib.Vars, data EvalData) (lib.Vars, error)

Evaluate evaluates the final values of each variable.

func PutSubscription

func PutSubscription(ctx context.Context, wh Subscription) context.Context

PutSubscription puts the provided subscription information to the given context. Should not be used out of tests outside of subscription package.

Types

type Action

type Action struct {
	Name     string   `yaml:"action"`
	With     lib.Vars `yaml:"with"`
	Detached bool     `yaml:"detached"` // means, that the action could be run asynchronously
}

Action describes a single call to the tracker's method.

func (Action) Path

func (a Action) Path() (tracker, method string)

Path parses the action name to the tracker name and its method.

type Content

type Content struct {
	Body   string       `json:"body"`
	Title  string       `json:"title"`
	Fields TicketFields `json:"fields"`
}

Content contains the data in the task itself.

type EvalData added in v0.2.0

type EvalData struct {
	Ticket Ticket
	Update Update
}

EvalData combines all the possible data to evaluate the template/expression..

type If

type If struct {
	Condition string   `yaml:"if"`
	Actions   Sequence `yaml:"do"`
}

If describes a conditional flow.

func (If) Eval

func (i If) Eval(upd Update) (bool, error)

Eval evaluates a predicate.

type Job

type Job struct {
	Name        string   `yaml:"name"`
	TriggerName string   `yaml:"on"`
	Actions     Sequence `yaml:"do"`
}

Job describes a control sequence.

type Locator

type Locator struct {
	Tracker string `json:"tracker"`
	ID      string `json:"id"`
}

Locator describes the path to the entity in the specific tracker.

func (Locator) Empty

func (l Locator) Empty() bool

Empty returns true if the locator is not specified.

func (Locator) String

func (l Locator) String() string

String returns the location of the task in string representation.

type Sequence

type Sequence []Step

Sequence is a set of actions

func (*Sequence) UnmarshalYAML

func (s *Sequence) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface

type Step

type Step interface{}

Step is a single step in a sequence.

type Subscription

type Subscription struct {
	ID string `json:"id"`

	TrackerRef string `json:"tracker_ref"`

	TrackerName string `json:"tracker_name"`
	TriggerName string `json:"trigger_name"`

	BaseURL string `json:"base_url"`
}

Subscription describes configuration for subscription in trackers.

func GetSubscription

func GetSubscription(ctx context.Context) (Subscription, error)

GetSubscription extracts a subscription from the given context.

func (Subscription) URL

func (s Subscription) URL() string

URL composes webhook URL from the subscription data.

type Task added in v0.2.0

type Task struct {
	ID string `json:"ID"`
	Content
}

Task represents a variation of the Ticket in a particular task tracker.

type Ticket

type Ticket struct {
	ID         string     `json:"id"`
	Variations Variations `json:"variations"` // map[tracker name]Task
}

Ticket describes a basic task/ticket in task tracker.

func (*Ticket) Patch

func (t *Ticket) Patch(upd Update)

Patch updates ticket fields with given update values.

type TicketFields

type TicketFields map[string]string

TicketFields is an alias for a map of fields in form of map[fieldName]fieldValue.

type Tracker

type Tracker struct {
	Name   string   `yaml:"name"`
	Driver string   `yaml:"driver"`
	With   lib.Vars `yaml:"with"`
}

Tracker describes a connection parameters to the certain tracker.

type Trigger

type Trigger struct {
	Name    string   `yaml:"name"`
	Tracker string   `yaml:"in"`
	With    lib.Vars `yaml:"with"`
}

Trigger describes an action, which has to appear to trigger a control flow.

type Update

type Update struct {
	ReceivedFrom Locator `json:"received_from"`
	URL          string  `json:"url"`
	Content
}

Update describes a ticket update.

type Variations added in v0.2.0

type Variations map[string]Task

Variations is a set of Ticket variations in task trackers.

func (Variations) Get added in v0.2.0

func (v Variations) Get(tracker string) Task

Get returns the task for the given tracker.

func (Variations) Has added in v0.2.0

func (v Variations) Has(tracker string) bool

Has returns true if the given tracker is present in the variations of ticket.

func (Variations) Locators added in v0.2.0

func (v Variations) Locators() []Locator

Locators returns the task tracker and task ID of the ticket in each registered task tracker.

func (*Variations) Set added in v0.2.0

func (v *Variations) Set(tracker string, task Task)

Set sets the task in the ticket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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