Documentation
¶
Overview ¶
Package validationfile contains code to manipulate files accepted by the `zed validate` CLI.
Index ¶
- func CompileSchema(schema compiler.InputSchema, cts *caveattypes.TypeSet) (*compiler.CompiledSchema, error)
- func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error)
- func ParseExpectedRelationsBlock(contents []byte) (*blocks.ParsedExpectedRelations, error)
- type PopulatedValidationFile
- type ValidationFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileSchema ¶ added in v1.43.0
func CompileSchema(schema compiler.InputSchema, cts *caveattypes.TypeSet) (*compiler.CompiledSchema, error)
CompileSchema takes an InputSchema and returns the compiled schema, or else an error. TODO: this is probably the wrong place for this, in part because it's coupling to the compiler implementation.
func ParseAssertionsBlock ¶
func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error)
ParseAssertionsBlock parses the given contents as an assertions block.
func ParseExpectedRelationsBlock ¶ added in v1.5.0
func ParseExpectedRelationsBlock(contents []byte) (*blocks.ParsedExpectedRelations, error)
ParseExpectedRelationsBlock parses the given contents as an expected relations block.
Types ¶
type PopulatedValidationFile ¶ added in v1.5.0
type PopulatedValidationFile struct {
// Schema is the entered schema text, if any.
Schema string
// NamespaceDefinitions are the namespaces defined in the validation file, in either
// direct or compiled from schema form.
NamespaceDefinitions []*core.NamespaceDefinition
// CaveatDefinitions are the caveats defined in the validation file, in either
// direct or compiled from schema form.
CaveatDefinitions []*core.CaveatDefinition
// Relationships are the relationships defined in the validation file, either directly
// or in the relationships block.
Relationships []tuple.Relationship
// ParsedFiles are the underlying parsed validation files.
ParsedFiles []ValidationFile
}
PopulatedValidationFile contains the fully parsed information from a validation file.
func PopulateFromFiles ¶
func PopulateFromFiles(ctx context.Context, ds datastore.Datastore, caveatTypeSet *caveattypes.TypeSet, filePaths []string) (*PopulatedValidationFile, datastore.Revision, error)
PopulateFromFiles populates the given datastore with the namespaces and tuples found in the validation file(s) specified.
func PopulateFromFilesContents ¶ added in v1.11.0
func PopulateFromFilesContents(ctx context.Context, ds datastore.Datastore, caveatTypeSet *caveattypes.TypeSet, filesContents map[string][]byte) (*PopulatedValidationFile, datastore.Revision, error)
PopulateFromFilesContents populates the given datastore with the namespaces and tuples found in the validation file(s) contents specified.
type ValidationFile ¶
type ValidationFile struct {
// Schema is the schema.
Schema blocks.SchemaWithPosition `yaml:"schema"`
// Relationships are the relationships specified in the validation file.
Relationships blocks.ParsedRelationships `yaml:"relationships"`
// Assertions are the assertions defined in the validation file. May be nil
// if no assertions are defined.
Assertions blocks.Assertions `yaml:"assertions"`
// ExpectedRelations is the map of expected relations.
ExpectedRelations blocks.ParsedExpectedRelations `yaml:"validation"`
// NamespaceConfigs are the namespace configuration protos, in text format.
//
// Deprecated: only for internal use. Use `schema`.
NamespaceConfigs []string `yaml:"namespace_configs"`
// ValidationTuples are the validation tuples, in tuple string syntax.
//
// Deprecated: only for internal use. Use `relationships`.
ValidationTuples []string `yaml:"validation_tuples"`
// Schema file represents the path specified for the schema file
SchemaFile string `yaml:"schemaFile"`
}
ValidationFile is a structural representation of the validation file format.
func DecodeValidationFile ¶ added in v1.5.0
func DecodeValidationFile(contents []byte) (*ValidationFile, error)
DecodeValidationFile decodes the validation file as found in the contents bytes and returns it.