Skip to content

Commit

Permalink
Create a top level openfga package
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jun 14, 2024
1 parent e62081b commit 9f95ca6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/jimmtest/openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"sync"

Expand All @@ -16,6 +15,7 @@ import (

"github.com/canonical/jimm/internal/errors"
"github.com/canonical/jimm/internal/openfga"
auth_model "github.com/canonical/jimm/openfga"
)

var (
Expand All @@ -35,13 +35,8 @@ type testSetup struct {
}

func getAuthModelDefinition() (*sdk.AuthorizationModel, error) {
b, err := os.ReadFile("../../openfga/authorisation_model.json")
if err != nil {
return nil, err
}

authModel := sdk.AuthorizationModel{}
err = json.Unmarshal(b, &authModel)
err := json.Unmarshal(auth_model.AuthModelFile, &authModel)
if err != nil {
return nil, err
}
Expand Down
8 changes: 8 additions & 0 deletions openfga/auth_model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package openfga

import (
_ "embed"
)

//go:embed authorisation_model.json
var AuthModelFile []byte
2 changes: 2 additions & 0 deletions openfga/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This folder/package exists to hold JIMM's OpenFGA authorisation model.
auth_model.go provides embeds the auth model and provides it for tests.

0 comments on commit 9f95ca6

Please sign in to comment.