Skip to content

Commit

Permalink
Merge pull request #37 from DataDog/lebauce/trim-quotes-os-release
Browse files Browse the repository at this point in the history
Trim quotes from values retrieved from /etc/os-release
  • Loading branch information
ISauve authored Nov 17, 2021
2 parents 9aa392a + 1e2204a commit 6301733
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,24 @@ func getOSRelease() (platform string, version string, err error) {
}
switch field[0] {
case "ID": // use ID for lowercase
platform = field[1]
platform = trimQuotes(field[1])
case "VERSION":
version = field[1]
version = trimQuotes(field[1])
}
}
return platform, version, nil
}

// trimQuotes removes quotes in the source string.
func trimQuotes(s string) string {
if len(s) >= 2 {
if s[0] == '"' && s[len(s)-1] == '"' {
return s[1 : len(s)-1]
}
}
return s
}

func getLSB() (*LSB, error) {
ret := &LSB{}
if common.PathExistsWithContents(common.HostEtc("lsb-release")) {
Expand Down

0 comments on commit 6301733

Please sign in to comment.