Skip to content

Commit

Permalink
Always return an OsRelease struct, even if /etc/os-release is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumerose committed Jan 5, 2021
1 parent 7b098c1 commit 58f6dff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/crc/preflight/preflight_linux.go
Expand Up @@ -246,8 +246,10 @@ func distroIsLike(osRelease *linux.OsRelease, osType linux.OsType) bool {
func distro() *linux.OsRelease {
distro, err := linux.GetOsRelease()
if err != nil {
logging.Warnf("cannot get distribution name: %v", err)
return nil
logging.Errorf("cannot get distribution name: %v", err)
return &linux.OsRelease{
ID: "unknown",
}
}
return distro
}
2 changes: 1 addition & 1 deletion pkg/os/linux/release_info.go
Expand Up @@ -102,7 +102,7 @@ func UnmarshalOsRelease(osReleaseContents []byte, release *OsRelease) error {
func GetOsRelease() (*OsRelease, error) {
// Check if release file exist
if _, err := os.Stat(releaseFile); os.IsNotExist(err) {
return nil, fmt.Errorf("%s not exist", releaseFile)
return nil, fmt.Errorf("%s doesn't exist", releaseFile)
}
content, err := ioutil.ReadFile(releaseFile)
if err != nil {
Expand Down

0 comments on commit 58f6dff

Please sign in to comment.