config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "jiralert_requests_total",
			Help: "Requests processed, by receiver and status code.",
		},
		[]string{"receiver", "code"},
	)
	RequestError = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "jiralert_requests_error",
			Help: "Requests processed, by receiver response error.",
		},
		[]string{"type", "code"})
)

Functions

This section is empty.

Types

type AutoResolve

type AutoResolve struct {
	State string `yaml:"state"`
}

AutoResolve is the struct used for defining jira resolution state when alert is resolved.

type Config

type Config struct {
	Defaults  *ReceiverConfig   `yaml:"defaults,omitempty"`
	Receivers []*ReceiverConfig `yaml:"receivers,omitempty"`
	Template  string            `yaml:"template"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-"`
}

Config is the top-level configuration for JIRAlert's config file.

func Load

func Load(s []byte) (*Config, error)

Load parses the YAML input into a Config.

func LoadFile

func LoadFile(filename string) (*Config, []byte, error)

parses the given YAML file into a Config.

func (*Config) ReceiverByName

func (c *Config) ReceiverByName(ctx context.Context, name string) *ReceiverConfig

ReceiverByName loops the receiver list and returns the first instance with that name

func (Config) String

func (c Config) String() string

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Duration

type Duration time.Duration

func ParseDuration

func ParseDuration(durationStr string) (Duration, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

type ReceiverConfig

type ReceiverConfig struct {
	Name string `yaml:"name" json:"name"`

	// API access fields
	APIURL              string `yaml:"api_url,omitempty" json:"apiurl,omitempty"`
	User                string `yaml:"user,omitempty" json:"user,omitempty"`
	Password            Secret `yaml:"password,omitempty" json:"password,omitempty"`
	PersonalAccessToken Secret `yaml:"personal_access_token" json:"personal_access_token,omitempty"`

	// Required issue fields
	Project        string    `yaml:"project,omitempty" json:"project,omitempty"`
	IssueType      string    `yaml:"issue_type,omitempty" json:"issue_type,omitempty"`
	Summary        string    `yaml:"summary,omitempty" json:"summary,omitempty"`
	ReopenState    string    `yaml:"reopen_state,omitempty" json:"reopen_state,omitempty"`
	ReopenDuration *Duration `yaml:"reopen_duration,omitempty" json:"reopen_duration,omitempty"`

	// Optional issue fields
	Priority          string `yaml:"priority,omitempty" json:"priority,omitempty"`
	Description       string `yaml:"description" json:"description,omitempty"`
	WontFixResolution string `yaml:"wont_fix_resolution,omitempty" json:"wont_fix_resolution,omitempty"`

	Fields     map[string]interface{} `yaml:"fields" json:"fields,omitempty"`
	Components []string               `yaml:"components" json:"components,omitempty"`

	// Label copy settings
	AddGroupLabels bool `yaml:"add_group_labels" json:"add_group_labels" json:"add_group_labels,omitempty"`

	// Flag to auto-resolve opened issue when the alert is resolved.
	AutoResolve *AutoResolve `yaml:"auto_resolve" json:"auto_resolve" json:"auto_resolve,omitempty"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline" json:"-" json:"xxx,omitempty"`
}

ReceiverConfig is the configuration for one receiver. It has a unique name and includes API access fields (url and auth) and issue fields (required -- e.g. project, issue type -- and optional -- e.g. priority).

func (*ReceiverConfig) UnmarshalYAML

func (rc *ReceiverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Secret

type Secret string

Secret is a string that must not be revealed on marshaling.

func (Secret) MarshalYAML

func (s Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Secret) UnmarshalYAML

func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets.

Jump to

Keyboard shortcuts

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