Skip to content

Commit

Permalink
Add dispatching support for intersection arrows
Browse files Browse the repository at this point in the history
Fixes #597
  • Loading branch information
josephschorr committed Jun 27, 2024
1 parent 7aa3232 commit 263823b
Show file tree
Hide file tree
Showing 21 changed files with 2,258 additions and 123 deletions.
20 changes: 20 additions & 0 deletions internal/caveats/builder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package caveats

import (
"google.golang.org/protobuf/types/known/structpb"

core "github.com/authzed/spicedb/pkg/proto/core/v1"
)

Expand Down Expand Up @@ -34,6 +36,24 @@ func CaveatExprForTesting(name string) *core.CaveatExpression {
}
}

// CaveatExprForTesting returns a CaveatExpression referencing a caveat with the given name and
// empty context.
func MustCaveatExprForTestingWithContext(name string, context map[string]any) *core.CaveatExpression {
contextStruct, err := structpb.NewStruct(context)
if err != nil {
panic(err)
}

return &core.CaveatExpression{
OperationOrCaveat: &core.CaveatExpression_Caveat{
Caveat: &core.ContextualizedCaveat{
CaveatName: name,
Context: contextStruct,
},
},
}
}

// ShortcircuitedOr combines two caveat expressions via an `||`. If one of the expressions is nil,
// then the entire expression is *short-circuited*, and a nil is returned.
func ShortcircuitedOr(first *core.CaveatExpression, second *core.CaveatExpression) *core.CaveatExpression {
Expand Down
Loading

0 comments on commit 263823b

Please sign in to comment.