config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 LoadFile

func LoadFile(filename string) (*Config, error)

func (*Config) GetDefaultMessage added in v1.4.0

func (c *Config) GetDefaultMessage() TargetMessage

func (*Config) String added in v1.2.0

func (c *Config) String() string

func (*Config) UnmarshalYAML

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

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

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Secret.

func (Secret) MarshalYAML added in v1.2.0

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

MarshalYAML implements the yaml.Marshaler interface for Secret.

func (*Secret) UnmarshalYAML added in v1.2.0

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

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) Copy added in v1.2.0

func (s *SecretURL) Copy() SecretURL

Copy makes a deep-copy of the type

func (SecretURL) MarshalJSON added in v1.2.0

func (s SecretURL) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for SecretURL.

func (SecretURL) MarshalYAML added in v1.2.0

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

MarshalYAML implements the yaml.Marshaler interface for SecretURL.

func (*SecretURL) UnmarshalYAML added in v1.2.0

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

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

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

type TargetMention

type TargetMention struct {
	All     bool     `yaml:"all,omitempty"`
	Mobiles []string `yaml:"mobiles,omitempty"`
}

type TargetMessage

type TargetMessage struct {
	Title string `yaml:"title"`
	Text  string `yaml:"text"`
}

func (*TargetMessage) UnmarshalYAML

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

type URL added in v1.2.0

type URL struct {
	url.URL
}

URL is a custom type that represents an HTTP or HTTPS URL and allows validation at configuration load time.

func ParseURL added in v1.3.0

func ParseURL(s string) (*URL, error)

ParseURL constructs a new URL from url string.

func (*URL) MarshalJSON added in v1.2.0

func (u *URL) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for URL.

func (*URL) MarshalYAML added in v1.2.0

func (u *URL) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for URL.

func (*URL) UnmarshalYAML added in v1.2.0

func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for URL.

Jump to

Keyboard shortcuts

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