Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Fix error when empty line found in os-release file, see #40. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky authored Jun 23, 2022
1 parent f7da3e2 commit c833132
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/collector/linux_sysinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ func parseOsRelease(r io.Reader) (string, string, error) {
var name, version string

for scanner.Scan() {
// Skip empty lines
if scanner.Text() == "" {
continue
}

parts := strings.SplitN(scanner.Text(), "=", 2)

if len(parts) != 2 {
Expand Down
1 change: 1 addition & 0 deletions internal/collector/testdata/etc/os-release.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian

PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
Expand Down

0 comments on commit c833132

Please sign in to comment.