mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
rc: add osVersion, osKernel and osArch to core/version
This makes it return the same info as `rclone version`
This commit is contained in:
@@ -170,17 +170,20 @@ func init() {
|
||||
Add(Call{
|
||||
Path: "core/version",
|
||||
Fn: rcVersion,
|
||||
Title: "Shows the current version of rclone and the go runtime.",
|
||||
Title: "Shows the current version of rclone, Go and the OS.",
|
||||
Help: `
|
||||
This shows the current version of go and the go runtime:
|
||||
This shows the current versions of rclone, Go and the OS:
|
||||
|
||||
- version - rclone version, e.g. "v1.53.0"
|
||||
- version - rclone version, e.g. "v1.71.2"
|
||||
- decomposed - version number as [major, minor, patch]
|
||||
- isGit - boolean - true if this was compiled from the git version
|
||||
- isBeta - boolean - true if this is a beta version
|
||||
- os - OS in use as according to Go
|
||||
- arch - cpu architecture in use according to Go
|
||||
- goVersion - version of Go runtime in use
|
||||
- os - OS in use as according to Go GOOS (e.g. "linux")
|
||||
- osKernel - OS Kernel version (e.g. "6.8.0-86-generic (x86_64)")
|
||||
- osVersion - OS Version (e.g. "ubuntu 24.04 (64 bit)")
|
||||
- osArch - cpu architecture in use (e.g. "arm64 (ARMv8 compatible)")
|
||||
- arch - cpu architecture in use according to Go GOARCH (e.g. "arm64")
|
||||
- goVersion - version of Go runtime in use (e.g. "go1.25.0")
|
||||
- linking - type of rclone executable (static or dynamic)
|
||||
- goTags - space separated build tags or "none"
|
||||
|
||||
@@ -195,12 +198,22 @@ func rcVersion(ctx context.Context, in Params) (out Params, err error) {
|
||||
return nil, err
|
||||
}
|
||||
linking, tagString := buildinfo.GetLinkingAndTags()
|
||||
osVersion, osKernel := buildinfo.GetOSVersion()
|
||||
if osVersion == "" {
|
||||
osVersion = "unknown"
|
||||
}
|
||||
if osKernel == "" {
|
||||
osKernel = "unknown"
|
||||
}
|
||||
out = Params{
|
||||
"version": fs.Version,
|
||||
"decomposed": version.Slice(),
|
||||
"isGit": strings.HasSuffix(fs.Version, "-DEV"),
|
||||
"isBeta": version.PreRelease != "",
|
||||
"os": runtime.GOOS,
|
||||
"osVersion": osVersion,
|
||||
"osKernel": osKernel,
|
||||
"osArch": buildinfo.GetArch(),
|
||||
"arch": runtime.GOARCH,
|
||||
"goVersion": runtime.Version(),
|
||||
"linking": linking,
|
||||
|
||||
@@ -111,6 +111,9 @@ func TestCoreVersion(t *testing.T) {
|
||||
assert.Equal(t, runtime.GOOS, out["os"])
|
||||
assert.Equal(t, runtime.GOARCH, out["arch"])
|
||||
assert.Equal(t, runtime.Version(), out["goVersion"])
|
||||
assert.True(t, strings.HasPrefix(out["osArch"].(string), runtime.GOARCH))
|
||||
assert.NotEqual(t, "", out["osVersion"].(string))
|
||||
assert.NotEqual(t, "", out["osKernel"].(string))
|
||||
_ = out["isGit"].(bool)
|
||||
v := out["decomposed"].([]int64)
|
||||
assert.True(t, len(v) >= 2)
|
||||
|
||||
Reference in New Issue
Block a user