Skip to content

Commit

Permalink
v1alpha1: re-expose revision hashing functions for downstream software
Browse files Browse the repository at this point in the history
  • Loading branch information
jakedt committed Oct 24, 2022
1 parent 7b8b67a commit f1bbcfd
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions internal/services/v1alpha1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/authzed/spicedb/internal/services/shared"
"github.com/authzed/spicedb/internal/sharederrors"
"github.com/authzed/spicedb/pkg/datastore"
revisions "github.com/authzed/spicedb/pkg/namespace/v1alpha1"
core "github.com/authzed/spicedb/pkg/proto/core/v1"
dispatchv1 "github.com/authzed/spicedb/pkg/proto/dispatch/v1"
"github.com/authzed/spicedb/pkg/schemadsl/compiler"
Expand Down Expand Up @@ -82,7 +83,7 @@ func (ss *schemaServiceServer) ReadSchema(ctx context.Context, in *v1alpha1.Read
DispatchCount: uint32(numRequested),
})

computedRevision, err := ComputeV1Alpha1Revision(createdRevisions)
computedRevision, err := revisions.ComputeV1Alpha1Revision(createdRevisions)
if err != nil {
return nil, rewriteError(ctx, err)
}
Expand Down Expand Up @@ -169,7 +170,7 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
// If a precondition was given, decode it, and verify that none of the namespaces specified
// have changed in any way.
if in.OptionalDefinitionsRevisionPrecondition != "" {
decoded, err := DecodeV1Alpha1Revision(in.OptionalDefinitionsRevisionPrecondition, ds)
decoded, err := revisions.DecodeV1Alpha1Revision(in.OptionalDefinitionsRevisionPrecondition, ds)
if err != nil {
return err
}
Expand Down Expand Up @@ -207,14 +208,14 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
return nil, rewriteError(ctx, err)
}

revisions := make(map[string]datastore.Revision, len(nsdefs))
revs := make(map[string]datastore.Revision, len(nsdefs))
names := make([]string, 0, len(nsdefs))
for _, nsdef := range nsdefs {
names = append(names, nsdef.Name)
revisions[nsdef.Name] = revision
revs[nsdef.Name] = revision
}

computedRevision, err := ComputeV1Alpha1Revision(revisions)
computedRevision, err := revisions.ComputeV1Alpha1Revision(revs)
if err != nil {
return nil, rewriteError(ctx, err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/v1alpha1/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"google.golang.org/grpc/codes"

"github.com/authzed/spicedb/internal/datastore/memdb"
revisions "github.com/authzed/spicedb/internal/services/v1alpha1"
"github.com/authzed/spicedb/internal/testfixtures"
"github.com/authzed/spicedb/internal/testserver"
"github.com/authzed/spicedb/pkg/datastore"
revisions "github.com/authzed/spicedb/pkg/namespace/v1alpha1"
"github.com/authzed/spicedb/pkg/spiceerrors"
"github.com/authzed/spicedb/pkg/tuple"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/shopspring/decimal"
"github.com/stretchr/testify/require"

rev "github.com/authzed/spicedb/internal/services/v1alpha1"
"github.com/authzed/spicedb/pkg/datastore"
"github.com/authzed/spicedb/pkg/datastore/revision"
rev "github.com/authzed/spicedb/pkg/namespace/v1alpha1"
)

func TestHashingSame(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/shopspring/decimal"
"github.com/stretchr/testify/require"

rev "github.com/authzed/spicedb/internal/services/v1alpha1"
"github.com/authzed/spicedb/pkg/datastore"
"github.com/authzed/spicedb/pkg/datastore/revision"
rev "github.com/authzed/spicedb/pkg/namespace/v1alpha1"
)

var decoder revision.DecimalDecoder
Expand Down
File renamed without changes.

0 comments on commit f1bbcfd

Please sign in to comment.