getDriverName returns a unique name for an NVIDIA driver instance in the format nvidia- -driver- -
(cr *nvidiav1alpha1.NVIDIADriver, osVersion string)
| 475 | |
| 476 | // getDriverName returns a unique name for an NVIDIA driver instance in the format nvidia-<driverType>-driver-<crName>-<osVersion> |
| 477 | func getDriverName(cr *nvidiav1alpha1.NVIDIADriver, osVersion string) string { |
| 478 | const ( |
| 479 | // https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names |
| 480 | // https://github.com/kubernetes/apimachinery/blob/v0.28.1/pkg/util/validation/validation.go#L209 |
| 481 | nameMaxLength = 253 |
| 482 | ) |
| 483 | |
| 484 | name := fmt.Sprintf("nvidia-%s-driver-%s-%s", cr.Spec.DriverType, cr.Name, osVersion) |
| 485 | |
| 486 | if cr.Spec.DriverType == nvidiav1alpha1.VGPUHostManager { |
| 487 | name = fmt.Sprintf("nvidia-vgpu-manager-%s-%s", cr.Name, osVersion) |
| 488 | } |
| 489 | |
| 490 | // truncate name if it exceeds the maximum length |
| 491 | if len(name) > nameMaxLength { |
| 492 | name = name[:nameMaxLength] |
| 493 | } |
| 494 | return name |
| 495 | } |
| 496 | |
| 497 | // getDriverAppName returns a unique name for an NVIDIA driver instance in the format nvidia-<driverType>-driver-<osVersion>-<hash> |
| 498 | // The hash string <string> is calculated from the NVIDIADriver CR UID. |