Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
0646f139
Commit
0646f139
authored
Mar 28, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Allow backup facts to be empty
parent
6194c37c
No related branches found
No related tags found
2 merge requests
!233
Modify restore to call user-defined bindings callback. Add Sent requests to...
,
!231
Revert "Update store to print changes to the partners list"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/ud.go
+22
-8
22 additions, 8 deletions
bindings/ud.go
storage/ud/facts.go
+3
-1
3 additions, 1 deletion
storage/ud/facts.go
with
25 additions
and
9 deletions
bindings/ud.go
+
22
−
8
View file @
0646f139
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
storage/ud/facts.go
+
3
−
1
View file @
0646f139
...
...
@@ -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
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment