Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefaultConfig = Config{ Timeout: 5 * time.Second, } DefaultTarget = Target{} DefaultTargetMessage = TargetMessage{ Title: `{{ template "ding.link.title" . }}`, Text: `{{ template "ding.link.content" . }}`, } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Template string `yaml:"template,omitempty"` Templates []string `yaml:"templates,omitempty"` DefaultMessage *TargetMessage `yaml:"default_message,omitempty"` Timeout time.Duration `yaml:"timeout"` Targets map[string]Target `yaml:"targets"` }
func (*Config) GetDefaultMessage ¶ added in v1.4.0
func (c *Config) GetDefaultMessage() TargetMessage
func (*Config) UnmarshalYAML ¶
type Coordinator ¶ added in v1.2.0
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator coordinates configurations beyond the lifetime of a single configuration.
func NewCoordinator ¶ added in v1.2.0
func NewCoordinator(configFilePath string, frozenConfig *Config, l log.Logger) *Coordinator
NewCoordinator returns a new coordinator with the given configuration file path. It does not yet load the configuration from file. This is done in `Reload()`.
func (*Coordinator) Reload ¶ added in v1.2.0
func (c *Coordinator) Reload() error
Reload triggers a configuration reload from file and notifies all configuration change subscribers.
func (*Coordinator) Subscribe ¶ added in v1.2.0
func (c *Coordinator) Subscribe(ss ...func(*Config) error)
Subscribe subscribes the given Subscribers to configuration changes.
type Secret ¶ added in v1.2.0
type Secret string
Secret is a string that must not be revealed on marshaling.
func (Secret) MarshalJSON ¶ added in v1.2.0
MarshalJSON implements the json.Marshaler interface for Secret.
func (Secret) MarshalYAML ¶ added in v1.2.0
MarshalYAML implements the yaml.Marshaler interface for Secret.
func (*Secret) UnmarshalYAML ¶ added in v1.2.0
UnmarshalYAML implements the yaml.Unmarshaler interface for Secret.
type SecretURL ¶ added in v1.2.0
type SecretURL URL
SecretURL is a URL that must not be revealed on marshaling.
func (SecretURL) MarshalJSON ¶ added in v1.2.0
MarshalJSON implements the json.Marshaler interface for SecretURL.
func (SecretURL) MarshalYAML ¶ added in v1.2.0
MarshalYAML implements the yaml.Marshaler interface for SecretURL.
func (*SecretURL) UnmarshalYAML ¶ added in v1.2.0
UnmarshalYAML implements the yaml.Unmarshaler interface for SecretURL.
type Target ¶
type Target struct { URL *SecretURL `yaml:"url,omitempty"` Secret Secret `yaml:"secret,omitempty"` Mention *TargetMention `yaml:"mention,omitempty"` Message *TargetMessage `yaml:"message,omitempty"` }
func (*Target) UnmarshalYAML ¶
type TargetMention ¶
type TargetMessage ¶
func (*TargetMessage) UnmarshalYAML ¶
func (c *TargetMessage) UnmarshalYAML(unmarshal func(interface{}) error) error
type URL ¶ added in v1.2.0
URL is a custom type that represents an HTTP or HTTPS URL and allows validation at configuration load time.
func (*URL) MarshalJSON ¶ added in v1.2.0
MarshalJSON implements the json.Marshaler interface for URL.
func (*URL) MarshalYAML ¶ added in v1.2.0
MarshalYAML implements the yaml.Marshaler interface for URL.
func (*URL) UnmarshalYAML ¶ added in v1.2.0
UnmarshalYAML implements the yaml.Unmarshaler interface for URL.