(podSpecPath string)
| 1392 | } |
| 1393 | |
| 1394 | func loadPodSpec(podSpecPath string) (*corev1.Pod, error) { |
| 1395 | var pod corev1.Pod |
| 1396 | manifest, err := os.ReadFile(podSpecPath) |
| 1397 | if err != nil { |
| 1398 | panic(err) |
| 1399 | } |
| 1400 | s := json.NewSerializerWithOptions(json.DefaultMetaFactory, scheme.Scheme, |
| 1401 | scheme.Scheme, json.SerializerOptions{Yaml: true, Pretty: false, Strict: false}) |
| 1402 | reg := regexp.MustCompile(`\b(\w*kind:\w*)\B.*\b`) |
| 1403 | |
| 1404 | kind := reg.FindString(string(manifest)) |
| 1405 | slice := strings.Split(kind, ":") |
| 1406 | kind = strings.TrimSpace(slice[1]) |
| 1407 | |
| 1408 | log.Debugf("Decoding for Kind %s in path: %s", kind, podSpecPath) |
| 1409 | _, _, err = s.Decode(manifest, nil, &pod) |
| 1410 | if err != nil { |
| 1411 | return nil, err |
| 1412 | } |
| 1413 | return &pod, nil |
| 1414 | } |
| 1415 | |
| 1416 | func (p *Plugin) countGPUResources() (int64, error) { |
| 1417 | // get node info to check discovered GPU resources |
no outgoing calls
no test coverage detected