Skip to content

Commit

Permalink
Merge pull request #1425 from dfr/freebsd-test
Browse files Browse the repository at this point in the history
pkg/parsers: Enable GetKernelVersion on FreeBSD
  • Loading branch information
rhatdan committed Nov 9, 2022
2 parents 39e90e6 + f647828 commit a1a74c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 17 additions & 0 deletions pkg/parsers/kernel/uname_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kernel

import "golang.org/x/sys/unix"

// Utsname represents the system name structure.
// It is passthrough for unix.Utsname in order to make it portable with
// other platforms where it is not available.
type Utsname unix.Utsname

func uname() (*unix.Utsname, error) {
uts := &unix.Utsname{}

if err := unix.Uname(uts); err != nil {
return nil, err
}
return uts, nil
}
9 changes: 5 additions & 4 deletions pkg/parsers/kernel/uname_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//go:build freebsd || openbsd
// +build freebsd openbsd
//go:build openbsd
// +build openbsd

package kernel

import (
"errors"
"fmt"
"runtime'
)

// A stub called by kernel_unix.go .
func uname() (*Utsname, error) {
return nil, errors.New("Kernel version detection is available only on linux")
return nil, fmt.Errorf("Kernel version detection is not available on %s", runtime.GOOS)
}
4 changes: 2 additions & 2 deletions pkg/parsers/kernel/uname_unsupported_type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux && !solaris
// +build !linux,!solaris
//go:build !linux && !solaris && !freebsd
// +build !linux,!solaris,!freebsd

package kernel

Expand Down

0 comments on commit a1a74c4

Please sign in to comment.