Merge pull request #822 from tgross/b-panic-on-empty-readline

fix host.Info() panic if /etc/debian_version is empty
pull/826/head
shirou 5 years ago committed by GitHub
commit 3964e5b579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -280,7 +280,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
platform = "debian" platform = "debian"
} }
contents, err := common.ReadLines(common.HostEtc("debian_version")) contents, err := common.ReadLines(common.HostEtc("debian_version"))
if err == nil { if err == nil && len(contents) > 0 && contents[0] != "" {
version = contents[0] version = contents[0]
} }
} }
@ -315,7 +315,7 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
} else if common.PathExists(common.HostEtc("alpine-release")) { } else if common.PathExists(common.HostEtc("alpine-release")) {
platform = "alpine" platform = "alpine"
contents, err := common.ReadLines(common.HostEtc("alpine-release")) contents, err := common.ReadLines(common.HostEtc("alpine-release"))
if err == nil && len(contents) > 0 { if err == nil && len(contents) > 0 && contents[0] != "" {
version = contents[0] version = contents[0]
} }
} else if common.PathExists(common.HostEtc("os-release")) { } else if common.PathExists(common.HostEtc("os-release")) {

Loading…
Cancel
Save