ParseYAMLPath collects all YAML files from a path (file or directory), reads them, and splits multi-document files into individual YAMLDoc entries.
(path string)
| 86 | // ParseYAMLPath collects all YAML files from a path (file or directory), |
| 87 | // reads them, and splits multi-document files into individual YAMLDoc entries. |
| 88 | func ParseYAMLPath(path string) ([]*YAMLDoc, error) { |
| 89 | files, err := CollectYAMLFiles(path) |
| 90 | if err != nil { |
| 91 | return nil, err |
| 92 | } |
| 93 | |
| 94 | if len(files) == 0 { |
| 95 | return nil, fmt.Errorf("no YAML files found in %q", path) |
| 96 | } |
| 97 | |
| 98 | var allDocs []*YAMLDoc |
| 99 | for _, f := range files { |
| 100 | rawData, err := os.ReadFile(f) |
| 101 | if err != nil { |
| 102 | return nil, fmt.Errorf("reading file %s: %w", f, err) |
| 103 | } |
| 104 | |
| 105 | docs, err := SplitYAMLDocuments(rawData) |
| 106 | if err != nil { |
| 107 | return nil, fmt.Errorf("parsing file %s: %w", f, err) |
| 108 | } |
| 109 | |
| 110 | allDocs = append(allDocs, docs...) |
| 111 | } |
| 112 | |
| 113 | return allDocs, nil |
| 114 | } |
| 115 | |
| 116 | // ApplyContractFromRawData applies a single contract document using the gRPC client. |
| 117 | func ApplyContractFromRawData(ctx context.Context, conn *grpc.ClientConn, rawData []byte) (bool, error) { |
no test coverage detected