(header []string, kind entities.Kind)
| 142 | } |
| 143 | |
| 144 | func catalogColumnIndexes(header []string, kind entities.Kind) (nameIdx, descIdx int, ok bool) { |
| 145 | nameIdx = -1 |
| 146 | descIdx = -1 |
| 147 | kindName := strings.ToLower(string(kind)) |
| 148 | for i, cell := range header { |
| 149 | cleaned := strings.ToLower(cleanCatalogCell(cell)) |
| 150 | switch { |
| 151 | case descIdx == -1 && strings.Contains(cleaned, "description"): |
| 152 | descIdx = i |
| 153 | case nameIdx == -1 && (strings.Contains(cleaned, kindName) || cleaned == "name"): |
| 154 | nameIdx = i |
| 155 | } |
| 156 | } |
| 157 | if nameIdx == -1 && len(header) > 0 { |
| 158 | nameIdx = 0 |
| 159 | } |
| 160 | if descIdx == -1 && len(header) > 1 { |
| 161 | descIdx = 1 |
| 162 | } |
| 163 | if nameIdx == descIdx { |
| 164 | descIdx = -1 |
| 165 | } |
| 166 | return nameIdx, descIdx, nameIdx >= 0 |
| 167 | } |
| 168 | |
| 169 | func splitTableRow(line string) []string { |
| 170 | line = strings.TrimSpace(line) |
no test coverage detected