mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
rc: add osVersion, osKernel and osArch to core/version
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
Some checks failed
build / windows (push) Has been cancelled
build / other_os (push) Has been cancelled
build / mac_amd64 (push) Has been cancelled
build / mac_arm64 (push) Has been cancelled
build / linux (push) Has been cancelled
build / go1.24 (push) Has been cancelled
build / linux_386 (push) Has been cancelled
build / lint (push) Has been cancelled
build / android-all (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/386 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/amd64 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v6 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm/v7 (push) Has been cancelled
Build & Push Docker Images / Build Docker Image for linux/arm64 (push) Has been cancelled
Build & Push Docker Images / Merge & Push Final Docker Image (push) Has been cancelled
This makes it return the same info as `rclone version`
This commit is contained in:
@@ -170,17 +170,20 @@ func init() {
|
|||||||
Add(Call{
|
Add(Call{
|
||||||
Path: "core/version",
|
Path: "core/version",
|
||||||
Fn: rcVersion,
|
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: `
|
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]
|
- decomposed - version number as [major, minor, patch]
|
||||||
- isGit - boolean - true if this was compiled from the git version
|
- isGit - boolean - true if this was compiled from the git version
|
||||||
- isBeta - boolean - true if this is a beta version
|
- isBeta - boolean - true if this is a beta version
|
||||||
- os - OS in use as according to Go
|
- os - OS in use as according to Go GOOS (e.g. "linux")
|
||||||
- arch - cpu architecture in use according to Go
|
- osKernel - OS Kernel version (e.g. "6.8.0-86-generic (x86_64)")
|
||||||
- goVersion - version of Go runtime in use
|
- 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)
|
- linking - type of rclone executable (static or dynamic)
|
||||||
- goTags - space separated build tags or "none"
|
- 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
|
return nil, err
|
||||||
}
|
}
|
||||||
linking, tagString := buildinfo.GetLinkingAndTags()
|
linking, tagString := buildinfo.GetLinkingAndTags()
|
||||||
|
osVersion, osKernel := buildinfo.GetOSVersion()
|
||||||
|
if osVersion == "" {
|
||||||
|
osVersion = "unknown"
|
||||||
|
}
|
||||||
|
if osKernel == "" {
|
||||||
|
osKernel = "unknown"
|
||||||
|
}
|
||||||
out = Params{
|
out = Params{
|
||||||
"version": fs.Version,
|
"version": fs.Version,
|
||||||
"decomposed": version.Slice(),
|
"decomposed": version.Slice(),
|
||||||
"isGit": strings.HasSuffix(fs.Version, "-DEV"),
|
"isGit": strings.HasSuffix(fs.Version, "-DEV"),
|
||||||
"isBeta": version.PreRelease != "",
|
"isBeta": version.PreRelease != "",
|
||||||
"os": runtime.GOOS,
|
"os": runtime.GOOS,
|
||||||
|
"osVersion": osVersion,
|
||||||
|
"osKernel": osKernel,
|
||||||
|
"osArch": buildinfo.GetArch(),
|
||||||
"arch": runtime.GOARCH,
|
"arch": runtime.GOARCH,
|
||||||
"goVersion": runtime.Version(),
|
"goVersion": runtime.Version(),
|
||||||
"linking": linking,
|
"linking": linking,
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ func TestCoreVersion(t *testing.T) {
|
|||||||
assert.Equal(t, runtime.GOOS, out["os"])
|
assert.Equal(t, runtime.GOOS, out["os"])
|
||||||
assert.Equal(t, runtime.GOARCH, out["arch"])
|
assert.Equal(t, runtime.GOARCH, out["arch"])
|
||||||
assert.Equal(t, runtime.Version(), out["goVersion"])
|
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)
|
_ = out["isGit"].(bool)
|
||||||
v := out["decomposed"].([]int64)
|
v := out["decomposed"].([]int64)
|
||||||
assert.True(t, len(v) >= 2)
|
assert.True(t, len(v) >= 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user