templates

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMessageTitleEmbed = `{{ template "default.title" . }}`
	DefaultMessageEmbed      = `{{ template "default.message" . }}`
)
View Source
const TemplateForTestsString = `` /* 1571-byte string literal not displayed */

TemplateForTestsString is the template used for unit tests and integration tests. We have it separate from above default template because any tiny change in the template will require updating almost all channel tests (15+ files) and it's very time consuming.

Variables

View Source
var (
	DefaultFuncs = template.DefaultFuncs
)
View Source
var DefaultTemplateString = `` /* 2530-byte string literal not displayed */
View Source
var FromGlobs = template.FromGlobs

Functions

func TopTemplates

func TopTemplates(tmpl *template.Template) ([]string, error)

TopTemplates returns the name of all templates in tmpl that are not executed from a {{ template "name" }} block.

All templates in text/template have a name and some text. In most cases, the name is set when the template is created using template.New(name) and the text is parsed when calling tmpl.Parse(text). This text can include actions for the template called "name", but also define other named templates using either {{ block "name" pipeline }}{{ end }} or {{ define "name" }}{{ end }}. TopTemplates returns the names of all such templates, including the template "name", that are not executed from a {{ template "name" }} block and "name" if name contains text other than just template definitions.

Types

type Data

type Data = template.Data

type ExtendedAlert

type ExtendedAlert struct {
	Status        string             `json:"status"`
	Labels        KV                 `json:"labels"`
	Annotations   KV                 `json:"annotations"`
	StartsAt      time.Time          `json:"startsAt"`
	EndsAt        time.Time          `json:"endsAt"`
	GeneratorURL  string             `json:"generatorURL"`
	Fingerprint   string             `json:"fingerprint"`
	SilenceURL    string             `json:"silenceURL"`
	DashboardURL  string             `json:"dashboardURL"`
	PanelURL      string             `json:"panelURL"`
	Values        map[string]float64 `json:"values"`
	ValueString   string             `json:"valueString"` // TODO: Remove in Grafana 10
	ImageURL      string             `json:"imageURL,omitempty"`
	EmbeddedImage string             `json:"embeddedImage,omitempty"`
}

type ExtendedAlerts

type ExtendedAlerts []ExtendedAlert

func (ExtendedAlerts) Firing

func (as ExtendedAlerts) Firing() []ExtendedAlert

Firing returns the subset of alerts that are firing.

func (ExtendedAlerts) Resolved

func (as ExtendedAlerts) Resolved() []ExtendedAlert

Resolved returns the subset of alerts that are resolved.

type ExtendedData

type ExtendedData struct {
	Receiver string         `json:"receiver"`
	Status   string         `json:"status"`
	Alerts   ExtendedAlerts `json:"alerts"`

	GroupLabels       KV `json:"groupLabels"`
	CommonLabels      KV `json:"commonLabels"`
	CommonAnnotations KV `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

func ExtendData

func ExtendData(data *Data, logger log.Logger) *ExtendedData

func TmplText

func TmplText(ctx context.Context, tmpl *Template, alerts []*types.Alert, l log.Logger, tmplErr *error) (func(string) string, *ExtendedData)

type KV

type KV = template.KV

type Template

type Template = template.Template

func ForTests

func ForTests(t *testing.T) *Template

Jump to

Keyboard shortcuts

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