···407407 logger: logr.Discard(),
408408 }
409409410410- // Test with no devices present - should return empty
411411- path := discoverer.findCommonDevicePath("20a0", "4230")
412412- // In a clean test environment, this should return empty since no devices exist
413413- // But since we can't control the actual filesystem, let's test the logic differently
414414-415410 // Test with unknown vendor ID - this should always return empty since no known paths exist for it
416416- path = discoverer.findCommonDevicePath("unknown", "unknown")
411411+ unknownPath := discoverer.findCommonDevicePath("unknown", "unknown")
417412418413 // The function checks actual filesystem paths, so we can't guarantee it returns empty
419414 // Instead, let's verify it returns a string (empty or path)
420420- assert.IsType(t, "", path)
415415+ assert.IsType(t, "", unknownPath)
421416422417 // Test that if a path is returned, it's one of the expected common paths
423423- if path != "" {
418418+ if unknownPath != "" {
424419 expectedPaths := []string{
425420 "/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3",
426421 "/dev/ttyACM0", "/dev/ttyACM1", "/dev/ttyACM2", "/dev/ttyACM3",
427422 "/dev/sc-hsm", "/dev/pkcs11",
428423 }
429429- assert.Contains(t, expectedPaths, path)
424424+ assert.Contains(t, expectedPaths, unknownPath)
430425 }
431426}
432427
+5-4
internal/modes/manager/manager.go
···7777 // Check if deployment name is provided via downward API
7878 if hostname := os.Getenv("HOSTNAME"); hostname != "" {
7979 // Kubernetes deployment pods have hostname like: deployment-name-replicaset-hash-pod-hash
8080- // Extract just the deployment name part
8080+ // Extract the deployment name by removing the last two parts (replicaset-hash and pod-hash)
8181 parts := strings.Split(hostname, "-")
8282- if len(parts) >= 2 {
8383- // Return the first two parts as deployment name (e.g., "controller-manager")
8484- return strings.Join(parts[:2], "-")
8282+ if len(parts) >= 3 {
8383+ // Remove last two parts (replicaset hash and pod hash) to get deployment name
8484+ deploymentParts := parts[:len(parts)-2]
8585+ return strings.Join(deploymentParts, "-")
8586 }
8687 return hostname
8788 }