summaryrefslogtreecommitdiff
path: root/cmd/authzd/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/authzd/main.go')
-rw-r--r--cmd/authzd/main.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/authzd/main.go b/cmd/authzd/main.go
index a68d16c..2de44d3 100644
--- a/cmd/authzd/main.go
+++ b/cmd/authzd/main.go
@@ -7,6 +7,8 @@ import (
"os/signal"
"syscall"
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
+ "github.com/authzed/authzed-go/v1"
"github.com/xlgmokha/x/pkg/env"
"github.com/xlgmokha/x/pkg/log"
"github.com/xlgmokha/x/pkg/x"
@@ -27,6 +29,10 @@ func main() {
env.Fetch("ZED_TOKEN", "secret"),
)
defer client.Close()
+ err := loadSpiceSchema(ctx, client)
+ if err != nil {
+ pls.LogErrorNow(ctx, err)
+ }
ctx = authz.Connection.With(ctx, connection)
ctx = authz.Client.With(ctx, client)
@@ -45,3 +51,13 @@ func main() {
socket := x.Must(net.Listen("tcp", ":10003"))
pls.LogErrorNow(ctx, server.Serve(socket))
}
+
+func loadSpiceSchema(ctx context.Context, client *authzed.Client) error {
+ content, err := os.ReadFile("./etc/authzd/schema.zed")
+ _, err = client.WriteSchema(ctx, &v1.WriteSchemaRequest{Schema: string(content)})
+ if err != nil {
+ return err
+ }
+
+ return nil
+}