Skip to content

Commit

Permalink
revert parser
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <[email protected]>
  • Loading branch information
kartikaysaxena committed Jan 14, 2025
1 parent 328174a commit d9c38c1
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions pkg/validationfile/fileformat.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
package validationfile

import (
"errors"

yamlv3 "gopkg.in/yaml.v3"

"github.com/ccoveille/go-safecast"

"github.com/authzed/spicedb/pkg/spiceerrors"
"github.com/authzed/spicedb/pkg/validationfile/blocks"
)

Expand Down Expand Up @@ -48,36 +43,6 @@ type ValidationFile struct {
SchemaFile string `yaml:"schemaFile"`
}

func (vf *ValidationFile) UnmarshalYAML(node *yamlv3.Node) error {
type alias ValidationFile // To avoid recursion during decoding
temp := &alias{}
if err := node.Decode(temp); err != nil {
return err
}

*vf = ValidationFile(*temp)

// Enforce either one of schema or schemaFile is set.
if vf.Schema == (blocks.ParsedSchema{}) && temp.SchemaFile == "" {
line, err := safecast.ToUint64(node.Line)
if err != nil {
return err
}
column, err := safecast.ToUint64(node.Column)
if err != nil {
return err
}

return spiceerrors.NewWithSourceError(
errors.New("validation file must specify either 'schema' or 'schemaFile'"),
"validation file",
line,
column,
)
}
return nil
}

// ParseAssertionsBlock parses the given contents as an assertions block.
func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error) {
return blocks.ParseAssertionsBlock(contents)
Expand Down

0 comments on commit d9c38c1

Please sign in to comment.