config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFeedOptions = Options{
	Body:        "default",
	MinFreq:     1,
	InclImages:  true,
	EmbedImages: false,
	IgnHash:     false,
	AlwaysNew:   false,
	Disable:     false,
	NoTLS:       false,
}

Default feed options

View Source
var DefaultGlobalOptions = GlobalOptions{
	Timeout:      30,
	MaxFailures:  10,
	DefaultEmail: username() + "@" + Hostname(),
	Target:       "",
	Parts:        []string{"text", "html"},
}

Default global options

Functions

func Hostname

func Hostname() (hostname string)

Hostname returns the current hostname, or 'localhost' if it cannot be determined

func TypeError

func TypeError(format string, v ...interface{}) *yaml.TypeError

Types

type Body

type Body string

func (*Body) UnmarshalYAML

func (b *Body) UnmarshalYAML(node *yaml.Node) error

type Config

type Config struct {
	GlobalOptions `yaml:",inline"`
	FeedOptions   Options `yaml:"options"`
	Feeds         Feeds   `yaml:"-"`
}

Config holds the global configuration options and the configured feeds

func Load

func Load(path string) (*Config, error)

Load configuration from file

func WithDefault

func WithDefault() *Config

WithDefault returns a configuration initialized with default values.

func (*Config) Validate

func (cfg *Config) Validate() error

Validates the configuration against common mistakes

type Feed

type Feed struct {
	Name   string
	Target []string
	Url    string
	Options
}

One stored feed

type Feeds

type Feeds map[string]*Feed

Convenience type for all feeds

type GlobalOptions

type GlobalOptions struct {
	Timeout      int      `yaml:"timeout"`
	DefaultEmail string   `yaml:"default-email"`
	Target       string   `yaml:"target"`
	Parts        []string `yaml:"parts"`
	MaxFailures  int      `yaml:"max-failures"`
}

Global options, not feed specific

func (GlobalOptions) WithPartHtml

func (opt GlobalOptions) WithPartHtml() bool

Marks whether 'html' part should be included in mails

func (GlobalOptions) WithPartText

func (opt GlobalOptions) WithPartText() bool

Marks whether 'text' part should be included in mails

type Map

type Map map[string]interface{}

Convenience type for the non-mapped configuration options Mostly used for legacy options

type Options

type Options struct {
	MinFreq     int  `yaml:"min-frequency"`
	InclImages  bool `yaml:"include-images"`
	EmbedImages bool `yaml:"embed-images"`
	Disable     bool `yaml:"disable"`
	IgnHash     bool `yaml:"ignore-hash"`
	AlwaysNew   bool `yaml:"always-new"`
	Reupload    bool `yaml:"reupload-if-updated"`
	NoTLS       bool `yaml:"tls-no-verify"`
	Body        Body `yaml:"body"`
}

Per feed options NB: Always specify a yaml name, as it is later used in processing

Jump to

Keyboard shortcuts

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