All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #1
27 lines
402 B
Go
27 lines
402 B
Go
package scenario
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
func Get(file string) (*Object, error) {
|
|
var obj Object
|
|
yamlFile, err := os.ReadFile(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = yaml.Unmarshal(yamlFile, &obj)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := validator.New().Struct(obj); err != nil {
|
|
return nil, err
|
|
}
|
|
return &obj, nil
|
|
}
|