@@ -580,49 +580,42 @@ func (s Scanner) detectContainerOSesOnServer(containerHost osTypeInterface) (ose
580
580
return oses
581
581
}
582
582
583
- func (s Scanner ) detectOS (c config.ServerInfo ) (osType osTypeInterface ) {
584
- var itsMe bool
585
- var fatalErr error
586
-
587
- if itsMe , osType , _ = detectPseudo (c ); itsMe {
588
- return
583
+ func (s Scanner ) detectOS (c config.ServerInfo ) osTypeInterface {
584
+ if itsMe , osType , _ := detectPseudo (c ); itsMe {
585
+ return osType
589
586
}
590
587
591
- itsMe , osType , fatalErr = s .detectDebianWithRetry (c )
592
- if fatalErr != nil {
593
- osType .setErrs ([]error {
594
- xerrors .Errorf ("Failed to detect OS: %w" , fatalErr )})
595
- return
588
+ if itsMe , osType , fatalErr := s .detectDebianWithRetry (c ); fatalErr != nil {
589
+ osType .setErrs ([]error {xerrors .Errorf ("Failed to detect OS: %w" , fatalErr )})
590
+ return osType
591
+ } else if itsMe {
592
+ logging .Log .Debugf ("Debian based Linux. Host: %s:%s" , c .Host , c .Port )
593
+ return osType
596
594
}
597
595
598
- if itsMe {
599
- logging .Log .Debugf ("Debian like Linux. Host: %s:%s" , c .Host , c .Port )
600
- return
596
+ if itsMe , osType := detectRedhat ( c ); itsMe {
597
+ logging .Log .Debugf ("Redhat based Linux. Host: %s:%s" , c .Host , c .Port )
598
+ return osType
601
599
}
602
600
603
- if itsMe , osType = detectRedhat (c ); itsMe {
604
- logging .Log .Debugf ("Redhat like Linux. Host: %s:%s" , c .Host , c .Port )
605
- return
606
- }
607
-
608
- if itsMe , osType = detectSUSE (c ); itsMe {
601
+ if itsMe , osType := detectSUSE (c ); itsMe {
609
602
logging .Log .Debugf ("SUSE Linux. Host: %s:%s" , c .Host , c .Port )
610
- return
603
+ return osType
611
604
}
612
605
613
- if itsMe , osType = detectFreebsd (c ); itsMe {
606
+ if itsMe , osType : = detectFreebsd (c ); itsMe {
614
607
logging .Log .Debugf ("FreeBSD. Host: %s:%s" , c .Host , c .Port )
615
- return
608
+ return osType
616
609
}
617
610
618
- if itsMe , osType = detectAlpine (c ); itsMe {
611
+ if itsMe , osType : = detectAlpine (c ); itsMe {
619
612
logging .Log .Debugf ("Alpine. Host: %s:%s" , c .Host , c .Port )
620
- return
613
+ return osType
621
614
}
622
615
623
- //TODO darwin https://github.com/mizzy/specinfra/blob/master/lib/specinfra/helper/detect_os/darwin.rb
616
+ osType := & unknown { base { ServerInfo : c }}
624
617
osType .setErrs ([]error {xerrors .New ("Unknown OS Type" )})
625
- return
618
+ return osType
626
619
}
627
620
628
621
// Retry as it may stall on the first SSH connection
0 commit comments