Skip to content

Commit

Permalink
Merge pull request #1937 from josephschorr/intersection-arrow
Browse files Browse the repository at this point in the history
Initial support for Intersection arrow
  • Loading branch information
josephschorr authored Jun 28, 2024
2 parents 8d1d3f6 + 263823b commit 42b739f
Show file tree
Hide file tree
Showing 40 changed files with 4,287 additions and 424 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 42b739f

Please sign in to comment.