(fsys fs.FS, dir string, manifest *manifest)
| 225 | } |
| 226 | |
| 227 | func (task *UpdateTask) parseSQLStmts(fsys fs.FS, dir string, manifest *manifest) ([]string, error) { |
| 228 | result := make([]string, 0, 4) |
| 229 | |
| 230 | for _, file := range manifest.SchemaUpdateCqlFiles { |
| 231 | schemaPath := path.Join(dir, file) |
| 232 | task.logger.Info("Processing schema file: " + schemaPath) |
| 233 | schemaBuf, err := fs.ReadFile(fsys, schemaPath) |
| 234 | if err != nil { |
| 235 | return nil, fmt.Errorf("error reading file %s: %w", schemaPath, err) |
| 236 | } |
| 237 | stmts, err := persistence.LoadAndSplitQueryFromReaders([]io.Reader{bytes.NewBuffer(schemaBuf)}) |
| 238 | if err != nil { |
| 239 | return nil, fmt.Errorf("error parsing file %v, err=%v", schemaPath, err) |
| 240 | } |
| 241 | result = append(result, stmts...) |
| 242 | } |
| 243 | |
| 244 | if len(result) == 0 && !manifest.AllowNoCqlFiles { |
| 245 | return nil, fmt.Errorf("found 0 updates in dir %v", dir) |
| 246 | } |
| 247 | |
| 248 | return result, nil |
| 249 | } |
| 250 | |
| 251 | func validateCQLStmts(stmts []string) error { |
| 252 | for _, stmt := range stmts { |
no test coverage detected