mirror of
https://github.com/zrepl/zrepl.git
synced 2025-02-18 03:11:55 +01:00
config: rename 'pools' section to 'remotes'
This commit is contained in:
parent
e951beaef5
commit
2c13fbe6ec
@ -26,7 +26,7 @@ var (
|
|||||||
JobSectionAutosnap string = "autosnap"
|
JobSectionAutosnap string = "autosnap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pool struct {
|
type Remote struct {
|
||||||
Name string
|
Name string
|
||||||
Transport Transport
|
Transport Transport
|
||||||
}
|
}
|
||||||
@ -51,14 +51,14 @@ type SSHTransport struct {
|
|||||||
|
|
||||||
type Push struct {
|
type Push struct {
|
||||||
JobName string // for use with jobrun package
|
JobName string // for use with jobrun package
|
||||||
To *Pool
|
To *Remote
|
||||||
Filter zfs.DatasetMapping
|
Filter zfs.DatasetMapping
|
||||||
InitialReplPolicy rpc.InitialReplPolicy
|
InitialReplPolicy rpc.InitialReplPolicy
|
||||||
RepeatStrategy jobrun.RepeatStrategy
|
RepeatStrategy jobrun.RepeatStrategy
|
||||||
}
|
}
|
||||||
type Pull struct {
|
type Pull struct {
|
||||||
JobName string // for use with jobrun package
|
JobName string // for use with jobrun package
|
||||||
From *Pool
|
From *Remote
|
||||||
Mapping zfs.DatasetMapping
|
Mapping zfs.DatasetMapping
|
||||||
InitialReplPolicy rpc.InitialReplPolicy
|
InitialReplPolicy rpc.InitialReplPolicy
|
||||||
RepeatStrategy jobrun.RepeatStrategy
|
RepeatStrategy jobrun.RepeatStrategy
|
||||||
@ -84,7 +84,7 @@ type Autosnap struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Pools map[string]*Pool
|
Remotes map[string]*Remote
|
||||||
Pushs map[string]*Push // job name -> job
|
Pushs map[string]*Push // job name -> job
|
||||||
Pulls map[string]*Pull // job name -> job
|
Pulls map[string]*Pull // job name -> job
|
||||||
Sinks map[string]*ClientMapping // client identity -> mapping
|
Sinks map[string]*ClientMapping // client identity -> mapping
|
||||||
@ -111,22 +111,22 @@ func ParseConfig(path string) (config Config, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parseMain(root map[string]interface{}) (c Config, err error) {
|
func parseMain(root map[string]interface{}) (c Config, err error) {
|
||||||
if c.Pools, err = parsePools(root["pools"]); err != nil {
|
if c.Remotes, err = parseRemotes(root["remotes"]); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
poolLookup := func(name string) (pool *Pool, err error) {
|
remoteLookup := func(name string) (remote *Remote, err error) {
|
||||||
pool = c.Pools[name]
|
remote = c.Remotes[name]
|
||||||
if pool == nil {
|
if remote == nil {
|
||||||
err = fmt.Errorf("pool '%s' not defined", name)
|
err = fmt.Errorf("remote '%s' not defined", name)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Pushs, err = parsePushs(root["pushs"], poolLookup); err != nil {
|
if c.Pushs, err = parsePushs(root["pushs"], remoteLookup); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.Pulls, err = parsePulls(root["pulls"], poolLookup); err != nil {
|
if c.Pulls, err = parsePulls(root["pulls"], remoteLookup); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if c.Sinks, err = parseClientMappings(root["sinks"]); err != nil {
|
if c.Sinks, err = parseClientMappings(root["sinks"]); err != nil {
|
||||||
@ -154,7 +154,7 @@ func fullJobName(section, name string) (full string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePools(v interface{}) (pools map[string]*Pool, err error) {
|
func parseRemotes(v interface{}) (remotes map[string]*Remote, err error) {
|
||||||
|
|
||||||
asMap := make(map[string]struct {
|
asMap := make(map[string]struct {
|
||||||
Transport map[string]interface{}
|
Transport map[string]interface{}
|
||||||
@ -163,11 +163,11 @@ func parsePools(v interface{}) (pools map[string]*Pool, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pools = make(map[string]*Pool, len(asMap))
|
remotes = make(map[string]*Remote, len(asMap))
|
||||||
for name, p := range asMap {
|
for name, p := range asMap {
|
||||||
|
|
||||||
if name == rpc.LOCAL_TRANSPORT_IDENTITY {
|
if name == rpc.LOCAL_TRANSPORT_IDENTITY {
|
||||||
err = errors.New(fmt.Sprintf("pool name '%s' reserved for local pulls", rpc.LOCAL_TRANSPORT_IDENTITY))
|
err = errors.New(fmt.Sprintf("remote name '%s' reserved for local pulls", rpc.LOCAL_TRANSPORT_IDENTITY))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ func parsePools(v interface{}) (pools map[string]*Pool, err error) {
|
|||||||
if transport, err = parseTransport(p.Transport); err != nil {
|
if transport, err = parseTransport(p.Transport); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pools[name] = &Pool{
|
remotes[name] = &Remote{
|
||||||
Name: name,
|
Name: name,
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
}
|
}
|
||||||
@ -209,9 +209,9 @@ func parseTransport(it map[string]interface{}) (t Transport, err error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type poolLookup func(name string) (*Pool, error)
|
type remoteLookup func(name string) (*Remote, error)
|
||||||
|
|
||||||
func parsePushs(v interface{}, pl poolLookup) (p map[string]*Push, err error) {
|
func parsePushs(v interface{}, rl remoteLookup) (p map[string]*Push, err error) {
|
||||||
|
|
||||||
asMap := make(map[string]struct {
|
asMap := make(map[string]struct {
|
||||||
To string
|
To string
|
||||||
@ -228,12 +228,12 @@ func parsePushs(v interface{}, pl poolLookup) (p map[string]*Push, err error) {
|
|||||||
|
|
||||||
for name, e := range asMap {
|
for name, e := range asMap {
|
||||||
|
|
||||||
var toPool *Pool
|
var toRemote *Remote
|
||||||
if toPool, err = pl(e.To); err != nil {
|
if toRemote, err = rl(e.To); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
push := &Push{
|
push := &Push{
|
||||||
To: toPool,
|
To: toRemote,
|
||||||
}
|
}
|
||||||
|
|
||||||
if push.JobName, err = fullJobName(JobSectionPush, name); err != nil {
|
if push.JobName, err = fullJobName(JobSectionPush, name); err != nil {
|
||||||
@ -257,7 +257,7 @@ func parsePushs(v interface{}, pl poolLookup) (p map[string]*Push, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePulls(v interface{}, pl poolLookup) (p map[string]*Pull, err error) {
|
func parsePulls(v interface{}, rl remoteLookup) (p map[string]*Pull, err error) {
|
||||||
|
|
||||||
asMap := make(map[string]struct {
|
asMap := make(map[string]struct {
|
||||||
From string
|
From string
|
||||||
@ -275,25 +275,25 @@ func parsePulls(v interface{}, pl poolLookup) (p map[string]*Pull, err error) {
|
|||||||
for name, e := range asMap {
|
for name, e := range asMap {
|
||||||
|
|
||||||
if len(e.From) < 1 {
|
if len(e.From) < 1 {
|
||||||
err = fmt.Errorf("source pool not set (from attribute is empty)")
|
err = fmt.Errorf("source not set ('from' attribute is empty)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var fromPool *Pool
|
var fromRemote *Remote
|
||||||
|
|
||||||
if e.From == rpc.LOCAL_TRANSPORT_IDENTITY {
|
if e.From == rpc.LOCAL_TRANSPORT_IDENTITY {
|
||||||
fromPool = &Pool{
|
fromRemote = &Remote{
|
||||||
Name: rpc.LOCAL_TRANSPORT_IDENTITY,
|
Name: rpc.LOCAL_TRANSPORT_IDENTITY,
|
||||||
Transport: LocalTransport{},
|
Transport: LocalTransport{},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if fromPool, err = pl(e.From); err != nil {
|
if fromRemote, err = rl(e.From); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pull := &Pull{
|
pull := &Pull{
|
||||||
From: fromPool,
|
From: fromRemote,
|
||||||
}
|
}
|
||||||
if pull.JobName, err = fullJobName(JobSectionPull, name); err != nil {
|
if pull.JobName, err = fullJobName(JobSectionPull, name); err != nil {
|
||||||
return
|
return
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pools:
|
remotes:
|
||||||
offsite_backups:
|
offsite_backups:
|
||||||
transport:
|
transport:
|
||||||
ssh:
|
ssh:
|
||||||
|
Loading…
Reference in New Issue
Block a user