(path string)
| 324 | } |
| 325 | |
| 326 | func existingWorkflowHasSource(path string) (bool, error) { |
| 327 | content, err := os.ReadFile(path) |
| 328 | if err != nil { |
| 329 | if errors.Is(err, os.ErrNotExist) { |
| 330 | return false, nil |
| 331 | } |
| 332 | return false, fmt.Errorf("failed to read workflow %s: %w", path, err) |
| 333 | } |
| 334 | |
| 335 | result, err := parser.ExtractFrontmatterFromContent(string(content)) |
| 336 | if err != nil { |
| 337 | deployLog.Printf("Failed to parse frontmatter in %s while checking source field: %v (treating workflow as non-sourced and proceeding with add)", path, err) |
| 338 | return false, nil |
| 339 | } |
| 340 | |
| 341 | sourceValue, ok := result.Frontmatter["source"] |
| 342 | if !ok { |
| 343 | return false, nil |
| 344 | } |
| 345 | |
| 346 | source, ok := sourceValue.(string) |
| 347 | return ok && strings.TrimSpace(source) != "", nil |
| 348 | } |
no test coverage detected