diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-22 17:35:49 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-22 17:35:49 -0600 |
| commit | 20ef0d92694465ac86b550df139e8366a0a2b4fa (patch) | |
| tree | 3f14589e1ce6eb9306a3af31c3a1f9e1af5ed637 /vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go | |
| parent | 44e0d272c040cdc53a98b9f1dc58ae7da67752e6 (diff) | |
feat: connect to spicedb
Diffstat (limited to 'vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go')
| -rw-r--r-- | vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go new file mode 100644 index 0000000..8f965a2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go @@ -0,0 +1,55 @@ +package validationfile + +import ( + yamlv3 "gopkg.in/yaml.v3" + + "github.com/authzed/spicedb/pkg/validationfile/blocks" +) + +// DecodeValidationFile decodes the validation file as found in the contents bytes +// and returns it. +func DecodeValidationFile(contents []byte) (*ValidationFile, error) { + p := ValidationFile{} + err := yamlv3.Unmarshal(contents, &p) + if err != nil { + return nil, err + } + return &p, nil +} + +// ValidationFile is a structural representation of the validation file format. +type ValidationFile struct { + // Schema is the schema. + Schema blocks.ParsedSchema `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"` +} + +// ParseAssertionsBlock parses the given contents as an assertions block. +func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error) { + return blocks.ParseAssertionsBlock(contents) +} + +// ParseExpectedRelationsBlock parses the given contents as an expected relations block. +func ParseExpectedRelationsBlock(contents []byte) (*blocks.ParsedExpectedRelations, error) { + return blocks.ParseExpectedRelationsBlock(contents) +} |
