summaryrefslogtreecommitdiff
path: root/pkg/authz
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-23 11:03:07 -0600
committermo khan <mo@mokhan.ca>2025-07-23 11:03:07 -0600
commit8a1b03afb949a5a3be6a78e9b2c88d2e48643f46 (patch)
tree14c2ce237c390460a91b5348bd7e056078128c0f /pkg/authz
parente402cb0283d26fdf33866f5cbbe75bcf47942661 (diff)
refactor: move LoadSchema into authz package
Diffstat (limited to 'pkg/authz')
-rw-r--r--pkg/authz/grpc.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/authz/grpc.go b/pkg/authz/grpc.go
index 234208c..9851db4 100644
--- a/pkg/authz/grpc.go
+++ b/pkg/authz/grpc.go
@@ -4,7 +4,9 @@ import (
"context"
"crypto/x509"
"net"
+ "os"
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/authzed-go/v1"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
"google.golang.org/grpc"
@@ -58,3 +60,13 @@ func credentialsFor(ctx context.Context, host string) credentials.TransportCrede
return credentials.NewClientTLSFromCert(pool, "")
}
+
+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
+}