Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion struct { // RelationshipString is the string form of the assertion. RelationshipString string // Relationship is the parsed relationship on which the assertion is being // run. Relationship *v1.Relationship // SourcePosition is the position of the assertion in the file. SourcePosition SourcePosition }
Assertion is a parsed assertion.
type Assertions ¶
type Assertions struct { // AssertTrue is the set of relationships to assert true. AssertTrue []Assertion `yaml:"assertTrue"` // AssertFalse is the set of relationships to assert false. AssertFalse []Assertion `yaml:"assertFalse"` // SourcePosition is the position of the assertions in the file. SourcePosition SourcePosition }
Assertions represents assertions defined in the validation file.
func ParseAssertionsBlock ¶
func ParseAssertionsBlock(contents []byte) (*Assertions, error)
ParseAssertionsBlock parses the given contents as an assertions block.
func (*Assertions) UnmarshalYAML ¶
func (a *Assertions) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type ErrorWithSource ¶
type ErrorWithSource struct { // Source is the source text for the error. Source string // LineNumber is the (1-indexed) line number of the error, or 0 if unknown. LineNumber uint64 // ColumnPosition is the (1-indexed) column position of the error, or 0 if // unknown. ColumnPosition uint64 // contains filtered or unexported fields }
ErrorWithSource is an error that includes the source text and position information.
type ExpectedSubject ¶
type ExpectedSubject struct { // ValidationString holds a validation string containing a Subject and one or // more Relations to the parent Object. // Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>` ValidationString ValidationString // Subject is the subject expected. SubjectWithExceptions *SubjectWithExceptions // Resources are the resources under which the subject is found. Resources []*v0.ObjectAndRelation // SourcePosition is the position of the expected subject in the file. SourcePosition SourcePosition }
ExpectedSubject is a subject expected for the ObjectAndRelation.
func (*ExpectedSubject) UnmarshalYAML ¶
func (es *ExpectedSubject) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type ObjectRelation ¶
type ObjectRelation struct { // ObjectRelationString is the string form of the object relation. ObjectRelationString string // ObjectAndRelation is the parsed object and relation. ObjectAndRelation *v0.ObjectAndRelation // SourcePosition is the position of the expected relations in the file. SourcePosition SourcePosition }
ObjectRelation represents an ONR defined as a string in the key for the ValidationMap.
func (*ObjectRelation) UnmarshalYAML ¶
func (ors *ObjectRelation) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type ParsedExpectedRelations ¶
type ParsedExpectedRelations struct { // ValidationMap is the parsed expected relations validation map. ValidationMap ValidationMap // SourcePosition is the position of the expected relations in the file. SourcePosition SourcePosition }
ParsedExpectedRelations represents the expected relations defined in the validation file.
func ParseExpectedRelationsBlock ¶
func ParseExpectedRelationsBlock(contents []byte) (*ParsedExpectedRelations, error)
ParseExpectedRelationsBlock parses the given contents as an expected relations block.
func (*ParsedExpectedRelations) UnmarshalYAML ¶
func (per *ParsedExpectedRelations) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type ParsedRelationships ¶
type ParsedRelationships struct { // RelationshipsString is the found string of newline-separated relationships. RelationshipsString string // SourcePosition is the position of the schema in the file. SourcePosition SourcePosition // Relationships are the fully parsed relationships. Relationships []*v1.Relationship }
ParsedRelationships is the parsed relationships in a validationfile.
func (*ParsedRelationships) UnmarshalYAML ¶
func (pr *ParsedRelationships) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type ParsedSchema ¶
type ParsedSchema struct { // Schema is the schema found. Schema string // SourcePosition is the position of the schema in the file. SourcePosition SourcePosition // Definitions are the compiled definitions for the schema. Definitions []*v0.NamespaceDefinition }
ParsedSchema is the parsed schema in a validationfile.
func (*ParsedSchema) UnmarshalYAML ¶
func (ps *ParsedSchema) UnmarshalYAML(node *yamlv3.Node) error
UnmarshalYAML is a custom unmarshaller.
type SourcePosition ¶
type SourcePosition struct { // LineNumber is the 1-indexed line number in the input source. LineNumber int // ColumnPosition is the 1-indexed column position in the input source. ColumnPosition int }
SourcePosition is a position in the input source.
type SubjectWithExceptions ¶
type SubjectWithExceptions struct { // Subject is the subject found. Subject *v0.ObjectAndRelation // Exceptions are those subjects removed from the subject, if it is a wildcard. Exceptions []*v0.ObjectAndRelation }
SubjectWithExceptions returns the subject found in a validation string, along with any exceptions.
type ValidationMap ¶
type ValidationMap map[ObjectRelation][]ExpectedSubject
ValidationMap is a map from an Object Relation (as a Relationship) to the validation strings containing the Subjects for that Object Relation.
type ValidationString ¶
type ValidationString string
ValidationString holds a validation string containing a Subject and one or more Relations to the parent Object. Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>`
func (ValidationString) ONRS ¶
func (vs ValidationString) ONRS() ([]*v0.ObjectAndRelation, *ErrorWithSource)
ONRS returns the subject ONRs in the ValidationString, if any.
func (ValidationString) ONRStrings ¶
func (vs ValidationString) ONRStrings() []string
ONRStrings returns the ONRs contained in the ValidationString, if any.
func (ValidationString) Subject ¶
func (vs ValidationString) Subject() (*SubjectWithExceptions, *ErrorWithSource)
Subject returns the subject contained in the ValidationString, if any. If none, returns nil.
func (ValidationString) SubjectString ¶
func (vs ValidationString) SubjectString() (string, bool)
SubjectString returns the subject contained in the ValidationString, if any.