From c4e69cd66c0fc0bdb2f35f08efcfc5970dfe4e6f Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 25 Dec 2022 08:08:41 +0100 Subject: [PATCH] gui, api: Indicate running under container (#8728) This adds a word to the version string when running containerized. The purpose is mostly to facilitate troubleshooting via screenshot by "leaking" this rather important aspect of the setup. Additionally, the version row gets "no-overflow-ellipsis" treatment so that the whole thing is actually visible in the GUI and the (now useless) tooltip is removed. In production releases this won't make a difference as the whole thing will typically fit, but in odd setups it provides more info up front. --- go.mod | 1 + go.sum | 6 ++++++ gui/default/index.html | 4 +--- gui/default/syncthing/core/syncthingController.js | 4 ++++ lib/api/api.go | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 74538321d..eb4afd116 100644 --- a/go.mod +++ b/go.mod @@ -61,6 +61,7 @@ require ( require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/calmh/incontainer v0.0.0-20221224152218-b3e71b103d7a // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect github.com/golang/mock v1.6.0 // indirect diff --git a/go.sum b/go.sum index 2e6af2c6c..a77701ebb 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,12 @@ github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBT github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/calmh/glob v0.0.0-20220615080505-1d823af5017b h1:Fjm4GuJ+TGMgqfGHN42IQArJb77CfD/mAwLbDUoJe6g= github.com/calmh/glob v0.0.0-20220615080505-1d823af5017b/go.mod h1:91K7jfEsgJSyfSrX+gmrRfZMtntx6JsHolWubGXDopg= +github.com/calmh/incontainer v0.0.0-20221224114231-8fd484b086d2 h1:1e21mRtyPbUn5W/lFvk+rCBVuzkfiiflv1vn8p4Btho= +github.com/calmh/incontainer v0.0.0-20221224114231-8fd484b086d2/go.mod h1:eOhqnw15c9X+4RNBe0W3HlUZFfX16O0EDsCOInTndHY= +github.com/calmh/incontainer v0.0.0-20221224151841-a0bf9955b52f h1:a0rHjaYZeQgEn/oB956REp1A2mUFQY83iQlICIu7Oo4= +github.com/calmh/incontainer v0.0.0-20221224151841-a0bf9955b52f/go.mod h1:eOhqnw15c9X+4RNBe0W3HlUZFfX16O0EDsCOInTndHY= +github.com/calmh/incontainer v0.0.0-20221224152218-b3e71b103d7a h1:CjrQbpvnV4BMzPHf0r8p2FAvzEp/bp761CmBBeNIHXI= +github.com/calmh/incontainer v0.0.0-20221224152218-b3e71b103d7a/go.mod h1:eOhqnw15c9X+4RNBe0W3HlUZFfX16O0EDsCOInTndHY= github.com/calmh/xdr v1.1.0 h1:U/Dd4CXNLoo8EiQ4ulJUXkgO1/EyQLgDKLgpY1SOoJE= github.com/calmh/xdr v1.1.0/go.mod h1:E8sz2ByAdXC8MbANf1LCRYzedSnnc+/sXXJs/PVqoeg= github.com/ccding/go-stun v0.1.4 h1:lC0co3Q3vjAuu2Jz098WivVPBPbemYFqbwE1syoka4M= diff --git a/gui/default/index.html b/gui/default/index.html index 7f26b0adf..b527d98dd 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -720,9 +720,7 @@  Version - - {{versionString()}} - + {{versionString()}} diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index f43bdea8e..683504c24 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -3079,6 +3079,10 @@ angular.module('syncthing.core') 's390x': '64-bit z/Architecture', }[$scope.version.arch] || $scope.version.arch; + if ($scope.version.container) { + arch += " Container"; + } + return $scope.version.version + ', ' + os + ' (' + arch + ')'; }; diff --git a/lib/api/api.go b/lib/api/api.go index 03420c5a5..456123fdc 100644 --- a/lib/api/api.go +++ b/lib/api/api.go @@ -30,6 +30,7 @@ import ( "time" "unicode" + "github.com/calmh/incontainer" "github.com/julienschmidt/httprouter" "github.com/rcrowley/go-metrics" "github.com/thejerf/suture/v4" @@ -721,6 +722,7 @@ func (*service) getSystemVersion(w http.ResponseWriter, _ *http.Request) { "tags": build.TagsList(), "stamp": build.Stamp, "user": build.User, + "container": incontainer.Detect(), }) }