Skip to content

Commit

Permalink
fix export v2
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd committed Nov 6, 2023
1 parent 931737e commit f067ec4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/directory/v2/exporter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package v2

import (
dsc2 "github.com/aserto-dev/go-directory/aserto/directory/common/v2"
dsc3 "github.com/aserto-dev/go-directory/aserto/directory/common/v3"
dse2 "github.com/aserto-dev/go-directory/aserto/directory/exporter/v2"
dse3 "github.com/aserto-dev/go-directory/aserto/directory/exporter/v3"
"github.com/aserto-dev/go-directory/pkg/convert"
"github.com/aserto-dev/go-edge-ds/pkg/bdb"
v3 "github.com/aserto-dev/go-edge-ds/pkg/directory/v3"

Expand Down Expand Up @@ -128,15 +129,16 @@ func exportPermissions(store *bdb.BoltDB, stream dse2.Exporter_ExportServer) err
}

func exportObjects(tx *bolt.Tx, stream dse2.Exporter_ExportServer) error {
iter, err := bdb.NewScanIterator[dsc2.Object](stream.Context(), tx, bdb.ObjectsPath)
iter, err := bdb.NewScanIterator[dsc3.Object](stream.Context(), tx, bdb.ObjectsPath)
if err != nil {
return err
}

for iter.Next() {
convert.ObjectToV2(iter.Value())
if err := stream.Send(&dse2.ExportResponse{
Msg: &dse2.ExportResponse_Object{
Object: iter.Value(),
Object: convert.ObjectToV2(iter.Value()),
},
}); err != nil {
return err
Expand All @@ -147,15 +149,15 @@ func exportObjects(tx *bolt.Tx, stream dse2.Exporter_ExportServer) error {
}

func exportRelations(tx *bolt.Tx, stream dse2.Exporter_ExportServer) error {
iter, err := bdb.NewScanIterator[dsc2.Relation](stream.Context(), tx, bdb.RelationsObjPath)
iter, err := bdb.NewScanIterator[dsc3.Relation](stream.Context(), tx, bdb.RelationsObjPath)
if err != nil {
return err
}

for iter.Next() {
if err := stream.Send(&dse2.ExportResponse{
Msg: &dse2.ExportResponse_Relation{
Relation: iter.Value(),
Relation: convert.RelationToV2(iter.Value()),
},
}); err != nil {
return err
Expand Down

0 comments on commit f067ec4

Please sign in to comment.