-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better OS version parsing #433
Comments
@Xeckt wanna take this ? |
I can take this on. Will have to tackle it somewhat later as we're finishing a project at work. |
@glimchb - How would you like this done? Because if we want to fetch OS, do we want to create a separate util function for it in the event it needs to be handle elsewhere in the future? That way we can make the logic a little longer so it's more reliable to parse. Is it also necessary to parse version? For example Arch Linux os-release file does not contain version so the above code would error out. |
I don't know how important the func GetOs() {
var u syscall.Utsname
if err := syscall.Uname(&u); err != nil {
log.Fatal(err)
}
fmt.Println(
utsToString(u.Machine),
utsToString(u.Release),
utsToString(u.Sysname),
)
}
func utsToString(uname [65]int8) string {
var b [65]byte
for i := range uname {
b[i] = uint8(uname[i])
}
return string(b[:])
} Gives on my Arch linux:
I don't know how important having the exact distribution string on here is though, maybe for debug purposes later. I can of course clean up the above to work as a single function as well. |
For now i think we should go with simple improvement
|
That's fine but we can do it with built in packages over adding more dependencies? Plus VERSION keys don't always exist on os-release files as mentioned before, what would you like to do about that? Obviously we can nil check, but if version is needed? |
this looks ugly
I don't ike syscalls here, espcially if we run inside docker, we can easily map os-release file inside container
understood, we can deal with this when requirement will come up |
Mapping os-release seems to add another layer of logic that doesn't seem needed? Though I like the idea of mapping inside a container, which begs the questions:
Syscalls just seem the more reliable way in my eyes. I understand |
see
sztp/sztp-agent/pkg/secureagent/utils.go
Lines 63 to 64 in fd911e2
maybe better use:
or existing go constants... like
runtime.GOOS
...The text was updated successfully, but these errors were encountered: