Skip to content

Commit

Permalink
Renamed to internal package tag
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Aug 23, 2023
1 parent 2c229ec commit 5f20de9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions internal/openfga/openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ func (o *OFGAClient) getRelatedObjects(ctx context.Context, tuple Tuple, pageSiz
// must NOT include the ID, i.e.,
//
// - "group:" vs "group:mygroup", where "mygroup" is the ID and the correct objType would be "group".
func (o *OFGAClient) listObjects(ctx context.Context, user string, relation string, objType string, contextualTuples []Tuple) (objectIds []cofga.Entity, err error) {
func (o *OFGAClient) listObjects(ctx context.Context, user string, relation string, objType string, contextualTuples []Tuple) (objectIds []Tag, err error) {
userEntity, err := cofga.ParseEntity(user)
if err != nil {
return nil, err
}
entities, err := o.cofgaClient.FindAccessibleObjectsByRelation(ctx, Tuple{
Object: &userEntity,
Relation: cofga.Relation(relation),
Target: &cofga.Entity{Kind: cofga.Kind(objType)},
Target: &Tag{Kind: cofga.Kind(objType)},
}, contextualTuples...)
if err != nil {
return nil, err
Expand All @@ -107,7 +107,7 @@ func (o *OFGAClient) RemoveRelation(ctx context.Context, tuples ...Tuple) error
}

// ListObjects returns all object IDs of <objType> that a user has the relation <relation> to.
func (o *OFGAClient) ListObjects(ctx context.Context, user string, relation string, objType string, contextualTuples []Tuple) ([]cofga.Entity, error) {
func (o *OFGAClient) ListObjects(ctx context.Context, user string, relation string, objType string, contextualTuples []Tuple) ([]Tag, error) {
return o.listObjects(ctx, user, relation, objType, contextualTuples)
}

Expand Down
12 changes: 6 additions & 6 deletions internal/openfga/openfga_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ func (s *openFGATestSuite) TestListObjectsWithContextualTuples(c *gc.C) {
"30000000-0000-0000-0000-000000000000",
}

expected := make([]cofga.Entity, len(modelUUIDs))
expected := make([]openfga.Tag, len(modelUUIDs))
for i, v := range modelUUIDs {
expected[i] = cofga.Entity{
expected[i] = openfga.Tag{
Kind: "model",
ID: v,
}
Expand Down Expand Up @@ -477,7 +477,7 @@ func (s *openFGATestSuite) TestListObjectsWithContextualTuples(c *gc.C) {
c.Assert(cmp.Equal(
ids,
expected,
cmpopts.SortSlices(func(want cofga.Entity, expected cofga.Entity) bool {
cmpopts.SortSlices(func(want openfga.Tag, expected openfga.Tag) bool {
return want.ID < expected.ID
}),
), gc.Equals, true)
Expand All @@ -492,9 +492,9 @@ func (s *openFGATestSuite) TestListObjectsWithPeristedTuples(c *gc.C) {
"30000000-0000-0000-0000-000000000000",
}

expected := make([]cofga.Entity, len(modelUUIDs))
expected := make([]openfga.Tag, len(modelUUIDs))
for i, v := range modelUUIDs {
expected[i] = cofga.Entity{
expected[i] = openfga.Tag{
Kind: "model",
ID: v,
}
Expand Down Expand Up @@ -537,7 +537,7 @@ func (s *openFGATestSuite) TestListObjectsWithPeristedTuples(c *gc.C) {
c.Assert(cmp.Equal(
ids,
expected,
cmpopts.SortSlices(func(want cofga.Entity, expected cofga.Entity) bool {
cmpopts.SortSlices(func(want openfga.Tag, expected openfga.Tag) bool {
return want.ID < expected.ID
}),
), gc.Equals, true)
Expand Down

0 comments on commit 5f20de9

Please sign in to comment.