aboutsummaryrefslogtreecommitdiff
path: root/internal/service/mirror.go
blob: b399e9fdff938676c9c1f5f90c59679c18ab9690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package service

import (
	"bytes"

	"git.server.ky/slackcoder/mirror/internal"
	"github.com/BurntSushi/toml"
)

type Mirror struct {
	Method      string        `toml:"method,omitempty"`
	From        *internal.URL `toml:"from,omitempty"`
	To          *internal.URL `toml:"to,omitempty"`
	Description string        `toml:"description,omitempty"`
	// See global configuration.
	MaxInterval *Duration `toml:"max-interval"`
	// See global configuration.
	MinInterval *Duration `toml:"min-interval"`
	// See global configuration.
	StagingMethod string `toml:"staging-method,omitempty"`
	// See global configuration.
	StagingPath string `toml:"staging-path,omitempty"`
	// See global configuration.
	Verify string `toml:"verify,omitempty"`
}

func (m *Mirror) Equal(arg *Mirror) bool {
	return m.Method == arg.Method && m.From.String() == arg.From.String() && m.To.String() == arg.To.String()
}

func (m *Mirror) String() string {
	var buf bytes.Buffer

	toml.NewEncoder(&buf).Encode(m)

	return buf.String()
}