notification

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const FileName = "notifications.toml"
View Source
const WebBaseDirRoutePrefix = "/_basedir/"

WebBaseDirRoutePrefix is the Web UI path prefix that serves one basedir as WebBaseDirRoutePrefix + WebBaseDirID(baseDir) + "/".

Variables

This section is empty.

Functions

func AvailableFields

func AvailableFields() []string

func FormatValue

func FormatValue(value any) string

func Marshal

func Marshal(settings Settings) ([]byte, error)

func Template

func Template() []byte

func Validate

func Validate(settings Settings) error

func WebBaseDirID added in v0.1.21

func WebBaseDirID(baseDir string) string

WebBaseDirID returns the Web UI route ID of baseDir, an absolute, clean path.

Types

type Batch

type Batch struct {
	SchemaVersion int     `json:"schema_version"`
	CreatedAt     string  `json:"created_at"`
	Project       string  `json:"project"`
	RunID         string  `json:"run_id"`
	RunName       string  `json:"run_name,omitempty"`
	Events        []Event `json:"events"`
	OmittedJobs   int     `json:"omitted_jobs,omitempty"`
}

func NewBatch

func NewBatch(events []Event, settings ChannelSettings, createdAt time.Time) Batch

func (Batch) Empty

func (batch Batch) Empty() bool

type ChannelSettings

type ChannelSettings struct {
	JobFailure bool     `json:"job_failure"`
	JobSuccess bool     `json:"job_success"`
	RunFailure bool     `json:"run_failure"`
	RunSuccess bool     `json:"run_success"`
	Fields     []string `json:"fields"`
	MaxJobs    int      `json:"max_jobs"`
}

func (ChannelSettings) Includes

func (settings ChannelSettings) Includes(event Event) bool

type Event

type Event struct {
	Kind              EventKind        `json:"event"`
	OccurredAt        string           `json:"occurred_at"`
	Project           string           `json:"project,omitempty"`
	RunID             string           `json:"run_id,omitempty"`
	RunName           string           `json:"run_name,omitempty"`
	RunStatus         string           `json:"run_status,omitempty"`
	JobStatus         string           `json:"job_status,omitempty"`
	ExitCode          int              `json:"exit_code,omitempty"`
	Successes         int              `json:"success_count,omitempty"`
	Failures          int              `json:"failure_count,omitempty"`
	DiagnosisOutdated bool             `json:"diagnosis_outdated,omitempty"`
	Job               *model.JobSpec   `json:"job,omitempty"`
	Result            *model.JobResult `json:"result,omitempty"`
	StartedAt         string           `json:"started_at,omitempty"`
	FinishedAt        string           `json:"finished_at,omitempty"`
}

func NewJobEvent

func NewJobEvent(project, runID, runName string, job model.JobSpec, result model.JobResult, occurredAt time.Time) Event

func NewRunEvent

func NewRunEvent(project string, summary model.RunSummary, occurredAt time.Time) Event

func (*Event) SetDiagnosisOutdated

func (event *Event) SetDiagnosisOutdated(outdated bool)

func (*Event) SetTimestamps

func (event *Event) SetTimestamps(startedAt, finishedAt string)

type EventKind

type EventKind string
const (
	JobFinished EventKind = "job.finished"
	RunFinished EventKind = "run.finished"
)

type Field

type Field struct {
	Name  string `json:"name"`
	Value any    `json:"value"`
}

type Loaded

type Loaded struct {
	Settings Settings
	Path     string
}

func Load

func Load(baseDir, projectName string) (Loaded, error)

type Payload

type Payload struct {
	SchemaVersion int            `json:"schema_version"`
	CreatedAt     string         `json:"created_at"`
	Events        []PayloadEvent `json:"events"`
	OmittedJobs   int            `json:"omitted_jobs,omitempty"`
}

func NewPayload

func NewPayload(batch Batch, selected []string, webURL, baseDir string) Payload

NewPayload builds the webhook payload for batch. webURL is the root of the rotari web server; links open the run under baseDir's route because one notifications.toml can serve runs of any basedir.

type PayloadEvent

type PayloadEvent struct {
	Event  EventKind `json:"event"`
	Fields []Field   `json:"fields"`
}

type Settings

type Settings struct {
	Webhook WebhookSettings `json:"webhook"`
	Browser ChannelSettings `json:"browser"`
}

func Defaults

func Defaults() Settings

func Parse

func Parse(data []byte) (Settings, error)

type WebhookSettings

type WebhookSettings struct {
	ChannelSettings
	URL    string `json:"url,omitempty"`
	WebURL string `json:"web_url,omitempty"`
	Format string `json:"format"`
}

Jump to

Keyboard shortcuts

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