Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ toolchain go1.26.4

require (
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/hashicorp/go-multierror v1.1.1
github.com/mattn/go-isatty v0.0.22
github.com/muesli/mango-cobra v1.3.0
github.com/muesli/roff v0.1.0
github.com/nwidger/jsoncolor v0.3.2
github.com/oklog/ulid/v2 v2.1.1
github.com/openfga/api/proto v0.0.0-20260319214821-f153694bfc20
github.com/openfga/go-sdk v0.8.2
github.com/openfga/language/pkg/go v0.2.1
github.com/openfga/language/pkg/go v0.3.0
github.com/openfga/openfga v1.17.1
github.com/rung/go-safecast v1.0.1
github.com/schollz/progressbar/v3 v3.19.0
Expand Down Expand Up @@ -48,7 +47,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,8 @@ github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 h1:B+8ClL/kCQkRiU82d9xajR
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3/go.mod h1:NbCUVmiS4foBGBHOYlCT25+YmGpJ32dZPi75pGEUpj4=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-retryablehttp v0.7.8 h1:ylXZWnqa7Lhqpk0L1P1LzDtGcCR0rPVUrx/c8Unxc48=
github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3iS0jrZ7LvzFGFmuKbw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand Down Expand Up @@ -184,8 +179,8 @@ github.com/openfga/api/proto v0.0.0-20260319214821-f153694bfc20 h1:xdVG0EDz9Z9Uh
github.com/openfga/api/proto v0.0.0-20260319214821-f153694bfc20/go.mod h1:XDX4qYNBUM2Rsa2AbKPh+oocZc2zgme+EF2fFC6amVU=
github.com/openfga/go-sdk v0.8.2 h1:eX2RJ7RD9sbxC4Oe8ZAFDZu6n/qYuO9SDrk7XAOE0Fg=
github.com/openfga/go-sdk v0.8.2/go.mod h1:epiUE6IfG7Ezr3cYLepiUbCasChNowgP8AtJsN4HSpI=
github.com/openfga/language/pkg/go v0.2.1 h1:nmVJTPfjvaJC2EWGcy8HrUyL15KkIfjjnmB3VFVeCts=
github.com/openfga/language/pkg/go v0.2.1/go.mod h1:wg+EuPmYIaM855F2uPygT1hJoWcoUxAoecgYC5akXsw=
github.com/openfga/language/pkg/go v0.3.0 h1:Ln0Cd3H/ych9YLErp5YlYNwf3PiQDfu0u+GjdpiSAyU=
github.com/openfga/language/pkg/go v0.3.0/go.mod h1:7ctT4Q7erZ9RBzSsICUV94EUMdDEynomgG0Y9etTicI=
github.com/openfga/openfga v1.17.1 h1:80sT4P5EYAKaRnbFqr4Wr6Cz5MI1WyT+Ss6kAAh1xD4=
github.com/openfga/openfga v1.17.1/go.mod h1:ZKAbAaqcijZuOT0AfCVjqtK3FiOFwZZh0pE8nlLuElA=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down
14 changes: 8 additions & 6 deletions internal/authorizationmodel/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ package authorizationmodel

import (
"encoding/json"
"errors"
"fmt"
"os"
"path"
"time"

"github.com/hashicorp/go-multierror"
"github.com/oklog/ulid/v2"
pb "github.com/openfga/api/proto/openfga/v1"
openfga "github.com/openfga/go-sdk"
Expand Down Expand Up @@ -207,16 +207,18 @@ func (model *AuthzModel) ReadModelFromModFGA(modFile string) error {
}

moduleFiles := []language.ModuleFile{}
fileReadErrors := multierror.Error{}

var fileReadErrors []error

directory := path.Dir(modFile)

for _, fileName := range parsedModFile.Contents.Value {
filePath := path.Join(directory, fileName.Value)

fileContents, err := os.ReadFile(filePath)
if err != nil {
fileReadErrors = *multierror.Append(
&fileReadErrors,
fileReadErrors = append(
fileReadErrors,
fmt.Errorf("failed to read module file %s due to %w", fileName.Value, err),
)

Expand All @@ -229,8 +231,8 @@ func (model *AuthzModel) ReadModelFromModFGA(modFile string) error {
})
}

if len(fileReadErrors.Errors) != 0 {
return &fileReadErrors
if len(fileReadErrors) != 0 {
return errors.Join(fileReadErrors...)
}

parsedAuthModel, err := language.TransformModuleFilesToModel(moduleFiles, parsedModFile.Schema.Value)
Expand Down