development

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 29 Imported by: 3

Documentation

Index

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL