Repository: elastic/go-sysinfo
Pull request #69 (2019-10-28 15:11:31)

Do not skip reading symlinks when trying to determine os distribution.

andrewkroh: Can you add testdata for Fedora 30. Add files to:

https://github.com/elastic/go-sysinfo/tree/master/providers/linux/testdata

Then update a test case in:

https://github.com/elastic/go-sysinfo/blob/master/providers/linux/os_test.go#L160
andrewkroh: And in your commit message if you add `Closes #57` github will automatically associate the issue to the PR and close the issue when the PR is merged.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 280c226..1287ae8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 # Changelog
+
 All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -18,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Security
 
+## [1.1.1] - 2019-10-29
+
+### Fixed
+
+- Fixed an issue determining the Linux distribution for Fedora 30. [#69](https://github.com/elastic/go-sysinfo/pull/69)
+
 ## [1.1.0] - 2019-08-22
 
 ### Added
diff --git a/providers/linux/os.go b/providers/linux/os.go
index d4daedd..9cda73a 100644
--- a/providers/linux/os.go
+++ b/providers/linux/os.go
@@ -205,7 +205,7 @@ func findDistribRelease(baseDir string) (*types.OSInfo, error) {
 		}
 
 		info, err := os.Lstat(path)
-		if err != nil || !info.Mode().IsRegular() || info.Size() == 0 {
+		if err != nil || info.Size() == 0 {
 			continue
 		}
 


Test patch:
diff --git a/providers/linux/os_test.go b/providers/linux/os_test.go
index 2977887..cac0181 100644
--- a/providers/linux/os_test.go
+++ b/providers/linux/os_test.go
@@ -157,4 +157,21 @@ func TestOperatingSystem(t *testing.T) {
 		}, *os)
 		t.Logf("%#v", os)
 	})
+	t.Run("fedora30", func(t *testing.T) {
+		os, err := getOSInfo("testdata/fedora30")
+		if err != nil {
+			t.Fatal(err)
+		}
+		assert.Equal(t, types.OSInfo{
+			Family:   "redhat",
+			Platform: "fedora",
+			Name:     "Fedora",
+			Version:  "30 (Container Image)",
+			Major:    30,
+			Minor:    0,
+			Patch:    0,
+			Codename: "Thirty",
+		}, *os)
+		t.Logf("%#v", os)
+	})
 }
diff --git a/providers/linux/testdata/fedora30/etc/fedora-release b/providers/linux/testdata/fedora30/etc/fedora-release
new file mode 120000
index 0000000..245bb42
--- /dev/null
+++ b/providers/linux/testdata/fedora30/etc/fedora-release
@@ -0,0 +1,1 @@
+../usr/lib/fedora-release
\ No newline at end of file
diff --git a/providers/linux/testdata/fedora30/etc/os-release b/providers/linux/testdata/fedora30/etc/os-release
new file mode 120000
index 0000000..c4c75b4
--- /dev/null
+++ b/providers/linux/testdata/fedora30/etc/os-release
@@ -0,0 +1,1 @@
+../usr/lib/os-release
\ No newline at end of file
diff --git a/providers/linux/testdata/fedora30/etc/redhat-release b/providers/linux/testdata/fedora30/etc/redhat-release
new file mode 120000
index 0000000..fc49fa6
--- /dev/null
+++ b/providers/linux/testdata/fedora30/etc/redhat-release
@@ -0,0 +1,1 @@
+fedora-release
\ No newline at end of file
diff --git a/providers/linux/testdata/fedora30/etc/system-release b/providers/linux/testdata/fedora30/etc/system-release
new file mode 120000
index 0000000..fc49fa6
--- /dev/null
+++ b/providers/linux/testdata/fedora30/etc/system-release
@@ -0,0 +1,1 @@
+fedora-release
\ No newline at end of file
diff --git a/providers/linux/testdata/fedora30/usr/lib/fedora-release b/providers/linux/testdata/fedora30/usr/lib/fedora-release
new file mode 100644
index 0000000..88caaa8
--- /dev/null
+++ b/providers/linux/testdata/fedora30/usr/lib/fedora-release
@@ -0,0 +1,1 @@
+Fedora release 30 (Thirty)
diff --git a/providers/linux/testdata/fedora30/usr/lib/os-release b/providers/linux/testdata/fedora30/usr/lib/os-release
new file mode 100644
index 0000000..8fc7f4a
--- /dev/null
+++ b/providers/linux/testdata/fedora30/usr/lib/os-release
@@ -0,0 +1,21 @@
+NAME=Fedora
+VERSION="30 (Container Image)"
+ID=fedora
+VERSION_ID=30
+VERSION_CODENAME=""
+PLATFORM_ID="platform:f30"
+PRETTY_NAME="Fedora 30 (Container Image)"
+ANSI_COLOR="0;34"
+LOGO=fedora-logo-icon
+CPE_NAME="cpe:/o:fedoraproject:fedora:30"
+HOME_URL="https://fedoraproject.org/"
+DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/"
+SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=30
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=30
+PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
+VARIANT="Container Image"
+VARIANT_ID=container
diff --git a/providers/linux/testdata/fedora30/usr/lib/redhat-release b/providers/linux/testdata/fedora30/usr/lib/redhat-release
new file mode 100644
index 0000000..88caaa8
--- /dev/null
+++ b/providers/linux/testdata/fedora30/usr/lib/redhat-release
@@ -0,0 +1,1 @@
+Fedora release 30 (Thirty)
diff --git a/providers/linux/testdata/fedora30/usr/lib/system-release b/providers/linux/testdata/fedora30/usr/lib/system-release
new file mode 100644
index 0000000..88caaa8
--- /dev/null
+++ b/providers/linux/testdata/fedora30/usr/lib/system-release
@@ -0,0 +1,1 @@
+Fedora release 30 (Thirty)