Documentation ¶
Index ¶
- func CompileSchema(schema string) (*compiler.CompiledSchema, *devinterface.DeveloperError, error)
- func DistinguishGraphError(devContext *DevContext, dispatchError error, ...) (*devinterface.DeveloperError, error)
- func GenerateValidation(membershipSet *membership.Set) (string, error)
- func ParseAssertionsYAML(assertionsYaml string) (*blocks.Assertions, *devinterface.DeveloperError)
- func ParseExpectedRelationsYAML(expectedRelationsYaml string) (*blocks.ParsedExpectedRelations, *devinterface.DeveloperError)
- func RunAllAssertions(devContext *DevContext, assertions *blocks.Assertions) ([]*devinterface.DeveloperError, error)
- func RunCheck(devContext *DevContext, resource *core.ObjectAndRelation, ...) (v1.ResourceCheckResult_Membership, error)
- func RunValidation(devContext *DevContext, validation *blocks.ParsedExpectedRelations) (*membership.Set, []*devinterface.DeveloperError, error)
- type DevContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileSchema ¶
func CompileSchema(schema string) (*compiler.CompiledSchema, *devinterface.DeveloperError, error)
CompileSchema compiles a schema into its caveat and namespace definition(s), returning a developer error if the schema could not be compiled. The non-developer error is returned only if an internal errors occurred.
func DistinguishGraphError ¶
func DistinguishGraphError(devContext *DevContext, dispatchError error, source devinterface.DeveloperError_Source, line uint32, column uint32, context string) (*devinterface.DeveloperError, error)
DistinguishGraphError turns an error from a dispatch call into either a user-facing DeveloperError or an internal error, based on the error raised by the dispatcher.
func GenerateValidation ¶
func GenerateValidation(membershipSet *membership.Set) (string, error)
GenerateValidation generates the validation block based on a membership set.
func ParseAssertionsYAML ¶
func ParseAssertionsYAML(assertionsYaml string) (*blocks.Assertions, *devinterface.DeveloperError)
ParseAssertionsYAML parses the YAML form of an assertions block.
func ParseExpectedRelationsYAML ¶
func ParseExpectedRelationsYAML(expectedRelationsYaml string) (*blocks.ParsedExpectedRelations, *devinterface.DeveloperError)
ParseExpectedRelationsYAML parses the YAML form of an expected relations block.
func RunAllAssertions ¶
func RunAllAssertions(devContext *DevContext, assertions *blocks.Assertions) ([]*devinterface.DeveloperError, error)
RunAllAssertions runs all assertions found in the given assertions block against the developer context, returning whether any errors occurred.
func RunCheck ¶
func RunCheck(devContext *DevContext, resource *core.ObjectAndRelation, subject *core.ObjectAndRelation) (v1.ResourceCheckResult_Membership, error)
RunCheck performs a check against the data in the development context.
Note that it is up to the caller to call DistinguishGraphError on the error if they want to distinguish between user errors and internal errors.
func RunValidation ¶
func RunValidation(devContext *DevContext, validation *blocks.ParsedExpectedRelations) (*membership.Set, []*devinterface.DeveloperError, error)
RunValidation runs the parsed validation block against the data in the dev context.
Types ¶
type DevContext ¶
type DevContext struct { Ctx context.Context Datastore datastore.Datastore Revision datastore.Revision CompiledSchema *compiler.CompiledSchema Dispatcher dispatch.Dispatcher }
DevContext holds the various helper types for running the developer calls.
func NewDevContext ¶
func NewDevContext(ctx context.Context, requestContext *devinterface.RequestContext) (*DevContext, *devinterface.DeveloperErrors, error)
NewDevContext creates a new DevContext from the specified request context, parsing and populating the datastore as needed.
func (*DevContext) Dispose ¶
func (dc *DevContext) Dispose()
Dispose disposes of the DevContext and its underlying datastore.