development

package
v1.25.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 39 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 *developmentmembership.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 RunValidation

RunValidation runs the parsed validation block against the data in the dev context.

Types

type CheckResult added in v1.16.0

type CheckResult struct {
	Permissionship      v1dispatch.ResourceCheckResult_Membership
	MissingCaveatFields []string
	DispatchDebugInfo   *v1dispatch.DebugInformation
	V1DebugInfo         *v1api.DebugInformation
}

CheckResult is the result of a RunCheck operation.

func RunCheck

func RunCheck(devContext *DevContext, resource *core.ObjectAndRelation, subject *core.ObjectAndRelation, caveatContext map[string]any) (CheckResult, 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.

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.

func (*DevContext) RunV1InMemoryService added in v1.16.0

func (dc *DevContext) RunV1InMemoryService() (*grpc.ClientConn, func(), error)

RunV1InMemoryService runs a V1 server in-memory on a buffconn over the given development context and returns a client connection and a function to shutdown the server. It is the responsibility of the caller to call the function to close the server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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