summaryrefslogtreecommitdiff
path: root/pkg/authz/spice.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-24 08:52:13 -0600
committermo khan <mo@mokhan.ca>2025-07-24 08:52:13 -0600
commitd2ba49adfc03f7f6e30f60c8915f7409b66222c0 (patch)
treeae1af94f4dc86c01dc90a851ec994946f14cc10e /pkg/authz/spice.go
parent4e83caaf7608c355970dbba4a76213db4cd55501 (diff)
refactor: move function to spice.go
Diffstat (limited to 'pkg/authz/spice.go')
-rw-r--r--pkg/authz/spice.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/authz/spice.go b/pkg/authz/spice.go
index cd534a1..97adbd4 100644
--- a/pkg/authz/spice.go
+++ b/pkg/authz/spice.go
@@ -2,6 +2,7 @@ package authz
import (
"context"
+ "os"
v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/authzed-go/v1"
@@ -24,3 +25,13 @@ func NewSpiceDBClient(ctx context.Context, host string, presharedKey string) *au
type CheckPermissionService interface {
CheckPermission(ctx context.Context, in *v1.CheckPermissionRequest, opts ...grpc.CallOption) (*v1.CheckPermissionResponse, error)
}
+
+func LoadSpiceSchema(ctx context.Context, client *authzed.Client, path string) error {
+ content, err := os.ReadFile(path)
+ _, err = client.WriteSchema(ctx, &v1.WriteSchemaRequest{Schema: string(content)})
+ if err != nil {
+ return err
+ }
+
+ return nil
+}