v1.16.3
ADDED: * Much more functions to tplx/sprigx
This commit is contained in:
43
tplx/sprigx/funcs_tpl_psutils.go
Normal file
43
tplx/sprigx/funcs_tpl_psutils.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package sprigx
|
||||
|
||||
import (
|
||||
`github.com/shirou/gopsutil/v4/host`
|
||||
)
|
||||
|
||||
/*
|
||||
psHostPlatInfo returns a "squashed" github.com/shirou/gopsutil/v4/host.PlatformInformation;
|
||||
normally it returns a (string, string, string, error)
|
||||
but you can only have a (any) or (any, error) return in Golang templates.
|
||||
*/
|
||||
func psHostPlatInfo() (platInfo [3]string, err error) {
|
||||
|
||||
var s1 string
|
||||
var s2 string
|
||||
var s3 string
|
||||
|
||||
if s1, s2, s3, err = host.PlatformInformation(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
platInfo = [3]string{s1, s2, s3}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
psHostVirt returns a "squared" github.com/shirou/gopsutil/v4/host.Virtualization;
|
||||
normally it returns a (string, string, error) but Go templates etc.
|
||||
*/
|
||||
func psHostVirt() (virtInfo [2]string, err error) {
|
||||
|
||||
var s1 string
|
||||
var s2 string
|
||||
|
||||
if s1, s2, err = host.Virtualization(); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
virtInfo = [2]string{s1, s2}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user