diff --git a/go.mod b/go.mod index c27a95a..65f3238 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/Masterminds/semver v1.5.0 github.com/aserto-dev/azm v0.0.6 github.com/aserto-dev/errors v0.0.6 - github.com/aserto-dev/go-directory v0.21.8-0.20231015213014-2bac9fa0ff01 + github.com/aserto-dev/go-directory v0.21.8-0.20231024193431-4f1633502744 github.com/bufbuild/protovalidate-go v0.3.4 github.com/gonvenience/ytbx v1.4.4 github.com/google/uuid v1.3.1 diff --git a/go.sum b/go.sum index 141aac1..455175b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230914171853-63dfe56cc2c4.1 h1:2gmp+PRca1fqQHf/WMKOgu9inVb0R0N07TucgY3QZCQ= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230914171853-63dfe56cc2c4.1/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20231017183020-0de7443d03cf.2 h1:t3Bq7+sq30Ga31zuUZVk02meAYwhiZ9SGMRVQPJJgqs= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20231017183020-0de7443d03cf.2/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -14,8 +12,8 @@ github.com/aserto-dev/azm v0.0.6 h1:96pTpT9n7pX//9Pt/47VboxmEz1dYYuJUatXDmeGoH4= github.com/aserto-dev/azm v0.0.6/go.mod h1:GeMRu6I7JMpByppqflZcusgbMZyXCGnYEdDW6x4qgX4= github.com/aserto-dev/errors v0.0.6 h1:iH5fkJwBGFPbcdS4B8mwvNdwODlhDEXXPduZtjLh6vo= github.com/aserto-dev/errors v0.0.6/go.mod h1:kenI1gamsemaR2wS+M2un0kXIJ9exTrmeRT/fCFwlWc= -github.com/aserto-dev/go-directory v0.21.8-0.20231015213014-2bac9fa0ff01 h1:glYqVO35wG+iRZ3wBnvm0YNh+ZaK1pDE3BUtZlA3U8M= -github.com/aserto-dev/go-directory v0.21.8-0.20231015213014-2bac9fa0ff01/go.mod h1:xkZFWZ0u0RcYRBkJLTqantIG/jnVxYhzd2+kIQf8PnU= +github.com/aserto-dev/go-directory v0.21.8-0.20231024193431-4f1633502744 h1:AYkAgLjuKOslF/Da6D+VE4OLct8yqw+BlDNAMH/G4AU= +github.com/aserto-dev/go-directory v0.21.8-0.20231024193431-4f1633502744/go.mod h1:xkZFWZ0u0RcYRBkJLTqantIG/jnVxYhzd2+kIQf8PnU= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bufbuild/protovalidate-go v0.3.4 h1:FrHcBBShspitvmC9Nkwu7BNs/EXWjkEQqrgFnWxYH60= github.com/bufbuild/protovalidate-go v0.3.4/go.mod h1:Au57xmLypglbQAF0GzuDDYbYIct7SZ9QnwJlaPolyFw= @@ -102,6 +100,7 @@ github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4 github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/nsf/jsondiff v0.0.0-20230430225905-43f6cf3098c1 h1:dOYG7LS/WK00RWZc8XGgcUTlTxpp3mKhdR2Q9z9HbXM= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= github.com/onsi/gomega v1.28.0 h1:i2rg/p9n/UqIDAMFUJ6qIUUMcsqOuUHgbpbu235Vr1c= @@ -214,16 +213,10 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20231009173412-8bfb1ae86b6c h1:ml3TAUoIIzQUtX88s/icpXCFW9lV5VwsuIuS1htNjKY= -google.golang.org/genproto v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:MugzuwC+GYOxyF0XUGQvsT97bOgWCV7MM1XMc5FZv8E= google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a h1:fwgW9j3vHirt4ObdHoYNwuO24BEZjSzbh+zPaNWoiY8= google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:EMfReVxb80Dq1hhioy0sOsY9jCE46YDgHlJ7fWVUWRE= -google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a h1:myvhA4is3vrit1a6NZCWBIwN0kNEnX21DJOJX/NvIfI= -google.golang.org/genproto/googleapis/api v0.0.0-20231012201019-e917dd12ba7a/go.mod h1:SUBoKXbI1Efip18FClrQVGjWcyd0QZd8KkvdP34t7ww= google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k= google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -242,6 +235,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/pkg/bdb/migrate/mig003/migrate.go b/pkg/bdb/migrate/mig003/migrate.go index 76bb9e6..c09fc05 100644 --- a/pkg/bdb/migrate/mig003/migrate.go +++ b/pkg/bdb/migrate/mig003/migrate.go @@ -11,9 +11,9 @@ import ( dsc2 "github.com/aserto-dev/go-directory/aserto/directory/common/v2" dsc3 "github.com/aserto-dev/go-directory/aserto/directory/common/v3" dsm3 "github.com/aserto-dev/go-directory/aserto/directory/model/v3" + "github.com/aserto-dev/go-directory/pkg/convert" "github.com/aserto-dev/go-edge-ds/pkg/bdb" "github.com/aserto-dev/go-edge-ds/pkg/bdb/migrate/mig" - "github.com/aserto-dev/go-edge-ds/pkg/convert" "github.com/aserto-dev/go-edge-ds/pkg/ds" "github.com/pkg/errors" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/pkg/convert/convert.go b/pkg/convert/convert.go deleted file mode 100644 index 9bf43a1..0000000 --- a/pkg/convert/convert.go +++ /dev/null @@ -1,185 +0,0 @@ -package convert - -import ( - dsc2 "github.com/aserto-dev/go-directory/aserto/directory/common/v2" - dsc3 "github.com/aserto-dev/go-directory/aserto/directory/common/v3" - "github.com/aserto-dev/go-edge-ds/pkg/pb" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/structpb" -) - -func ObjectIdentifierToV2(i *dsc3.ObjectIdentifier) *dsc2.ObjectIdentifier { - return &dsc2.ObjectIdentifier{ - Type: &i.ObjectType, - Key: &i.ObjectId, - } -} - -func ObjectIdentifierArrayToV2(in []*dsc3.ObjectIdentifier) []*dsc2.ObjectIdentifier { - result := make([]*dsc2.ObjectIdentifier, len(in)) - for i := 0; i < len(in); i++ { - result[i] = ObjectIdentifierToV2(in[i]) - } - return result -} - -func ObjectIdentifierToV3(i *dsc2.ObjectIdentifier) *dsc3.ObjectIdentifier { - return &dsc3.ObjectIdentifier{ - ObjectType: i.GetType(), - ObjectId: i.GetKey(), - } -} - -func ObjectIdentifierArrayToV3(in []*dsc2.ObjectIdentifier) []*dsc3.ObjectIdentifier { - result := make([]*dsc3.ObjectIdentifier, len(in)) - for i := 0; i < len(in); i++ { - result[i] = ObjectIdentifierToV3(in[i]) - } - return result -} - -func ObjectToV2(in *dsc3.Object) *dsc2.Object { - if in.Properties == nil { - in.Properties = pb.NewStruct() - } - p := proto.Clone(in.Properties).(*structpb.Struct) - - return &dsc2.Object{ - Type: in.GetType(), - Key: in.GetId(), - DisplayName: in.GetDisplayName(), - Properties: p, - CreatedAt: in.GetCreatedAt(), - UpdatedAt: in.GetUpdatedAt(), - Hash: in.GetEtag(), - } -} - -func ObjectArrayToV2(in []*dsc3.Object) []*dsc2.Object { - result := make([]*dsc2.Object, len(in)) - for i := 0; i < len(in); i++ { - result[i] = ObjectToV2(in[i]) - } - return result -} - -func ObjectMapToV2(in map[string]*dsc3.Object) map[string]*dsc2.Object { - result := make(map[string]*dsc2.Object, len(in)) - for k, v := range in { - result[k] = ObjectToV2(v) - } - return result -} - -func ObjectToV3(in *dsc2.Object) *dsc3.Object { - if in.Properties == nil { - in.Properties = pb.NewStruct() - } - p := proto.Clone(in.Properties).(*structpb.Struct) - - return &dsc3.Object{ - Type: in.GetType(), - Id: in.GetKey(), - DisplayName: in.GetDisplayName(), - Properties: p, - CreatedAt: in.GetCreatedAt(), - UpdatedAt: in.GetUpdatedAt(), - Etag: in.GetHash(), - } -} - -func ObjectArrayToV3(in []*dsc2.Object) []*dsc3.Object { - result := make([]*dsc3.Object, len(in)) - for i := 0; i < len(in); i++ { - result[i] = ObjectToV3(in[i]) - } - return result -} - -func ObjectDependencyToV3(in *dsc2.ObjectDependency) *dsc3.ObjectDependency { - return &dsc3.ObjectDependency{ - ObjectType: in.GetObjectType(), - ObjectId: in.GetObjectKey(), - Relation: in.GetRelation(), - SubjectType: in.GetSubjectType(), - SubjectId: in.GetSubjectKey(), - Depth: in.GetDepth(), - IsCycle: in.GetIsCycle(), - Path: in.GetPath(), - } -} - -func ObjectDependencyArrayToV3(in []*dsc2.ObjectDependency) []*dsc3.ObjectDependency { - result := make([]*dsc3.ObjectDependency, len(in)) - for i := 0; i < len(in); i++ { - result[i] = ObjectDependencyToV3(in[i]) - } - return result -} - -func RelationToV2(in *dsc3.Relation) *dsc2.Relation { - return &dsc2.Relation{ - Object: &dsc2.ObjectIdentifier{ - Type: &in.ObjectType, - Key: &in.ObjectId, - }, - Relation: in.Relation, - Subject: &dsc2.ObjectIdentifier{ - Type: &in.SubjectType, - Key: &in.SubjectId, - }, - CreatedAt: in.CreatedAt, - UpdatedAt: in.UpdatedAt, - Hash: in.Etag, - } -} - -func RelationArrayToV2(in []*dsc3.Relation) []*dsc2.Relation { - result := make([]*dsc2.Relation, len(in)) - for i := 0; i < len(in); i++ { - result[i] = RelationToV2(in[i]) - } - return result -} - -func RelationToV3(in *dsc2.Relation) *dsc3.Relation { - return &dsc3.Relation{ - ObjectType: in.GetObject().GetType(), - ObjectId: in.GetObject().GetKey(), - Relation: in.GetRelation(), - SubjectType: in.GetSubject().GetType(), - SubjectId: in.GetSubject().GetKey(), - CreatedAt: in.GetCreatedAt(), - UpdatedAt: in.GetUpdatedAt(), - Etag: in.GetHash(), - } -} - -func RelationArrayToV3(in []*dsc2.Relation) []*dsc3.Relation { - result := make([]*dsc3.Relation, len(in)) - for i := 0; i < len(in); i++ { - result[i] = RelationToV3(in[i]) - } - return result -} - -func PaginationRequestToV3(in *dsc2.PaginationRequest) *dsc3.PaginationRequest { - if in == nil { - return &dsc3.PaginationRequest{Size: 100, Token: ""} - } - - return &dsc3.PaginationRequest{ - Size: in.Size, - Token: in.Token, - } -} - -func PaginationResponseToV2(in *dsc3.PaginationResponse) *dsc2.PaginationResponse { - if in == nil { - return &dsc2.PaginationResponse{NextToken: ""} - } - - return &dsc2.PaginationResponse{ - NextToken: in.NextToken, - } -} diff --git a/pkg/directory/v2/importer.go b/pkg/directory/v2/importer.go index 4bb851d..ea8d425 100644 --- a/pkg/directory/v2/importer.go +++ b/pkg/directory/v2/importer.go @@ -8,9 +8,9 @@ import ( dsc3 "github.com/aserto-dev/go-directory/aserto/directory/common/v3" dsi2 "github.com/aserto-dev/go-directory/aserto/directory/importer/v2" dsi3 "github.com/aserto-dev/go-directory/aserto/directory/importer/v3" + "github.com/aserto-dev/go-directory/pkg/convert" "github.com/aserto-dev/go-directory/pkg/derr" "github.com/aserto-dev/go-edge-ds/pkg/bdb" - "github.com/aserto-dev/go-edge-ds/pkg/convert" v3 "github.com/aserto-dev/go-edge-ds/pkg/directory/v3" "github.com/aserto-dev/go-edge-ds/pkg/ds" "github.com/aserto-dev/go-edge-ds/pkg/session" diff --git a/pkg/directory/v2/reader.go b/pkg/directory/v2/reader.go index 429d686..08bb470 100644 --- a/pkg/directory/v2/reader.go +++ b/pkg/directory/v2/reader.go @@ -7,8 +7,8 @@ import ( dsc3 "github.com/aserto-dev/go-directory/aserto/directory/common/v3" dsr2 "github.com/aserto-dev/go-directory/aserto/directory/reader/v2" dsr3 "github.com/aserto-dev/go-directory/aserto/directory/reader/v3" + "github.com/aserto-dev/go-directory/pkg/convert" "github.com/aserto-dev/go-edge-ds/pkg/bdb" - "github.com/aserto-dev/go-edge-ds/pkg/convert" v3 "github.com/aserto-dev/go-edge-ds/pkg/directory/v3" "google.golang.org/protobuf/proto" diff --git a/pkg/directory/v2/writer.go b/pkg/directory/v2/writer.go index 26e5f86..da1f99d 100644 --- a/pkg/directory/v2/writer.go +++ b/pkg/directory/v2/writer.go @@ -5,8 +5,8 @@ import ( dsw2 "github.com/aserto-dev/go-directory/aserto/directory/writer/v2" dsw3 "github.com/aserto-dev/go-directory/aserto/directory/writer/v3" + "github.com/aserto-dev/go-directory/pkg/convert" "github.com/aserto-dev/go-edge-ds/pkg/bdb" - "github.com/aserto-dev/go-edge-ds/pkg/convert" v3 "github.com/aserto-dev/go-edge-ds/pkg/directory/v3" "github.com/rs/zerolog"