Skip to content
Snippets Groups Projects
Commit 0646f139 authored by Josh Brooks's avatar Josh Brooks
Browse files

Allow backup facts to be empty

parent 6194c37c
No related branches found
No related tags found
2 merge requests!233Modify restore to call user-defined bindings callback. Add Sent requests to...,!231Revert "Update store to print changes to the partners list"
......@@ -9,6 +9,7 @@ package bindings
import (
"fmt"
jww "github.com/spf13/jwalterweatherman"
"time"
"github.com/pkg/errors"
......@@ -62,23 +63,36 @@ func NewUserDiscoveryFromBackup(client *Client,
if err != nil {
return nil, errors.WithMessage(err, "Failed to create User Discovery Manager")
}
// Parse username as a fact, which should not be empty
userFact, err := fact.NewFact(fact.Username, username)
if err != nil {
return nil, errors.WithMessagef(err, "Failed to parse "+
"stringified username fact %q", username)
}
emailFact, err := fact.NewFact(fact.Email, email)
var emailFact, phoneFact fact.Fact
// Parse email as a fact, if it exists
if email != "" {
emailFact, err = fact.NewFact(fact.Email, email)
if err != nil {
return nil, errors.WithMessagef(err, "Failed to parse "+
"stringified email fact %q", email)
}
} else {
jww.WARN.Printf("Loading manager without a registered email")
}
phoneFact, err := fact.NewFact(fact.Phone, phone)
// Parse phone number as a fact, if it exists
if phone != "" {
phoneFact, err = fact.NewFact(fact.Phone, phone)
if err != nil {
return nil, errors.WithMessagef(err, "Failed to parse "+
"stringified phone fact %q", phone)
}
} else {
jww.WARN.Printf("Loading manager without a registered phone number")
}
m, err := ud.NewManagerFromBackup(&client.api, single, fact.FactList{userFact, emailFact, phoneFact})
if err != nil {
......
......@@ -62,8 +62,10 @@ func (s *Store) RestoreFromBackUp(backupData fact.FactList) error {
}
for _, f := range backupData {
if !isFactZero(f) {
s.confirmedFacts[f] = struct{}{}
}
}
return s.save()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment