config

package
v0.0.0-test-multiarch Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEmailBody = `` /* 818-byte string literal not displayed */
View Source
const DefaultEmailSubject = `Smart Core Meter Readings {{.Now.Format "Jan 02, 2006"}}`

Variables

View Source
var (
	DefaultSendTime = jsontypes.MustParseSchedule("0 0 * * 1")
)

Functions

This section is empty.

Types

type AttachmentCfg

type AttachmentCfg struct {
	AttachmentName string
	Attachment     []byte
}

func (*AttachmentCfg) AttachFile

func (d *AttachmentCfg) AttachFile(name string, b []byte)

type Destination

type Destination struct {
	Host     string `json:"host,omitempty"`
	Port     int    `json:"port,omitempty"`
	Username string `json:"username,omitempty"` // defaults to From.Address
	jsontypes.Password

	From string   `json:"from,omitempty"` // RFC 5322 address, the address part used for auth against Host
	To   []string `json:"to,omitempty"`   // RFC 5322 address

	SendTime *jsontypes.Schedule `json:"sendTime,omitempty"` // defaults to midnight on Monday mornings: "0 0 * * 1"

	Parsed *ParsedDestination `json:"-"`
}

func (Destination) Addr

func (d Destination) Addr() string

Addr returns the combination of Host and Port, taking defaults into account. Suitable for smtp.Dial.

func (Destination) Parse

func (d Destination) Parse(cfg Root) (*ParsedDestination, error)

type ParsedDestination

type ParsedDestination struct {
	Addr            string
	Username        string
	Password        string
	From            *mail.Address
	To              []*mail.Address
	SubjectTemplate *template.Template
	BodyTemplate    *template.Template
}

type Root

type Root struct {
	auto.Config
	// Configuration information for how to send the email.
	Destination    Destination      `json:"destination,omitempty"`
	Source         Source           `json:"source,omitempty"`
	Now            func() time.Time `json:"-"`
	ElectricMeters []string         `json:"electricMeters,omitempty"`
	WaterMeters    []string         `json:"waterMeters,omitempty"`
	Timing         Timing           `json:"timing,omitempty"`
	TemplateArgs   TemplateArgs     `json:"templateArgs,omitempty"`
}

func ReadBytes

func ReadBytes(data []byte) (cfg Root, err error)

func (Root) ReadBodyTemplate added in v0.2024.5

func (c Root) ReadBodyTemplate() (*template.Template, error)

func (Root) ReadSubjectTemplate added in v0.2024.5

func (c Root) ReadSubjectTemplate() (*template.Template, error)

type Source

type Source struct {
	Name      string `json:"name,omitempty"`
	Title     string `json:"title,omitempty"`
	Floor     string `json:"floor,omitempty"`
	Zone      string `json:"zone,omitempty"`
	Subsystem string `json:"subsystem,omitempty"`
}

type TemplateArgs added in v0.2024.5

type TemplateArgs struct {
	BodyTemplate    jsontypes.String `json:"bodyTemplate,omitempty"`
	EmailTitle      string           `json:"emailTitle,omitempty"`
	SubjectTemplate jsontypes.String `json:"subjectTemplate,omitempty"`
}

type Timing added in v0.2024.5

type Timing struct {
	Timeout      jsontypes.Duration `json:"timeout,omitempty"`
	BackoffStart jsontypes.Duration `json:"backoffStart,omitempty"`
	BackoffMax   jsontypes.Duration `json:"backoffMax,omitempty"`
	NumRetries   int                `json:"numRetries,omitempty"`
}

Jump to

Keyboard shortcuts

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