| 112 | } |
| 113 | |
| 114 | func (c *Development) Run(ctx context.Context, shape map[string]interface{}) (errors []Error) { |
| 115 | // Marshal the shape map into YAML format |
| 116 | out, err := yaml.Marshal(shape) |
| 117 | if err != nil { |
| 118 | errors = append(errors, Error{ |
| 119 | Type: "file_validation", |
| 120 | Key: "", |
| 121 | Message: err.Error(), |
| 122 | }) |
| 123 | return errors |
| 124 | } |
| 125 | |
| 126 | // Unmarshal the YAML data into a file.Shape object |
| 127 | s := &file.Shape{} |
| 128 | err = yaml.Unmarshal(out, &s) |
| 129 | if err != nil { |
| 130 | errors = append(errors, Error{ |
| 131 | Type: "file_validation", |
| 132 | Key: "", |
| 133 | Message: err.Error(), |
| 134 | }) |
| 135 | return errors |
| 136 | } |
| 137 | |
| 138 | return c.RunWithShape(ctx, s) |
| 139 | } |
| 140 | |
| 141 | func (c *Development) RunWithShape(ctx context.Context, shape *file.Shape) (errors []Error) { |
| 142 | // Parse the schema using the parser library |