Skip to content

Commit 110d9ad

Browse files
authored
Merge pull request #314 from sdcio/Visitors-1
Visitors 1
2 parents 78df0ac + af72e2f commit 110d9ad

File tree

12 files changed

+417
-131
lines changed

12 files changed

+417
-131
lines changed

mocks/mocktreeentry/entry.go

Lines changed: 220 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/datastore/datastore_rpc.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,15 @@ func (d *Datastore) BlameConfig(ctx context.Context, includeDefaults bool) (*sdc
465465
if err != nil {
466466
return nil, err
467467
}
468+
468469
// calculate the Blame
469-
bte, err := root.BlameConfig(includeDefaults)
470+
bcv := tree.NewBlameConfigVisitor(includeDefaults)
471+
err = root.Walk(ctx, bcv)
470472
if err != nil {
471473
return nil, err
472474
}
475+
bte := bcv.GetResult()
476+
473477
// set the root level elements name to the target name
474478
bte.Name = d.config.Name
475479
return bte, nil

pkg/datastore/transaction_rpc.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ func (d *Datastore) lowlevelTransactionSet(ctx context.Context, transaction *typ
209209

210210
oldIntentContent := lvs.ToUpdateSlice()
211211

212-
root.MarkOwnerDelete(intent.GetName(), intent.GetOnlyIntended())
212+
marksOwnerDeleteVisitor := tree.NewMarkOwnerDeleteVisitor(intent.GetName(), intent.GetOnlyIntended())
213+
err := root.Walk(ctx, marksOwnerDeleteVisitor)
214+
if err != nil {
215+
return nil, err
216+
}
213217

214218
// store the old intent content in the transaction as the old intent.
215219
err = transaction.AddIntentContent(intent.GetName(), types.TransactionIntentOld, oldIntentContent.GetFirstPriorityValue(), oldIntentContent)

pkg/datastore/tree_operation_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,11 @@ func TestDatastore_populateTree(t *testing.T) {
807807
t.Error(err)
808808
}
809809

810-
root.MarkOwnerDelete(tt.intentName, false)
810+
marksOwnerDeleteVisitor := tree.NewMarkOwnerDeleteVisitor(tt.intentName, false)
811+
err = root.Walk(ctx, marksOwnerDeleteVisitor)
812+
if err != nil {
813+
t.Error(err)
814+
}
811815

812816
newFlag := types.NewUpdateInsertFlags().SetNewFlag()
813817

0 commit comments

Comments
 (0)