From 4ce35acf0157e8d31f46a6ea6c7cf2e60d8be1fa Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Tue, 4 Jan 2022 12:35:35 +0100 Subject: [PATCH] Update reva and use ocis-pkg version string in capabilities Needed to use github.com/Masterminds/semver/v3 instead of v1 to be able to extract major, minor and patch version from a version string. Falling back to 0.0.0 in any error case (e.g. if the version.String is a hash) --- .../unreleased/ocs-version-product-field.md | 5 ++++ extensions/frontend/pkg/revaconfig/config.go | 25 ++++++++++++------- go.mod | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 changelog/unreleased/ocs-version-product-field.md diff --git a/changelog/unreleased/ocs-version-product-field.md b/changelog/unreleased/ocs-version-product-field.md new file mode 100644 index 000000000..6714300c1 --- /dev/null +++ b/changelog/unreleased/ocs-version-product-field.md @@ -0,0 +1,5 @@ +Enhancement: Product field in OCS version + +We've added a new field to the OCS Version, which is supposed to announce the product name. The web ui as a client will make use of it to make the backend product and version available (e.g. for easier bug reports). + +https://github.com/owncloud/ocis/pull/2918 diff --git a/extensions/frontend/pkg/revaconfig/config.go b/extensions/frontend/pkg/revaconfig/config.go index 9cd3c95d8..69a786eb9 100644 --- a/extensions/frontend/pkg/revaconfig/config.go +++ b/extensions/frontend/pkg/revaconfig/config.go @@ -4,11 +4,17 @@ import ( "path" "strconv" + "github.com/Masterminds/semver" "github.com/owncloud/ocis/v2/extensions/frontend/pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/version" ) // FrontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { + parsedVersion, err := semver.NewVersion(version.String) + if err != nil { + parsedVersion, _ = semver.NewVersion("0.0.0") + } archivers := []map[string]interface{}{ { "enabled": true, @@ -138,10 +144,10 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "installed": true, "maintenance": false, "needsDbUpgrade": false, - "version": "10.0.11.5", - "versionstring": "10.0.11", - "edition": "community", - "productname": "reva", + "version": version.String + ".0", + "versionstring": version.String, + "edition": "Community", + "productname": "oCIS", "hostname": "", }, "support_url_signing": true, @@ -210,11 +216,12 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { }, }, "version": map[string]interface{}{ - "edition": "reva", - "major": 10, - "minor": 0, - "micro": 11, - "string": "10.0.11", + "product": "oCIS", + "edition": "Community", + "major": parsedVersion.Major(), + "minor": parsedVersion.Minor(), + "micro": parsedVersion.Patch(), + "string": version.String, }, }, }, diff --git a/go.mod b/go.mod index f5778bd59..a8e362a60 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.17 require ( github.com/CiscoM31/godata v1.0.5 github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e + github.com/Masterminds/semver v1.5.0 github.com/ReneKroon/ttlcache/v2 v2.11.0 github.com/blevesearch/bleve/v2 v2.3.2 github.com/blevesearch/bleve_index_api v1.0.1 @@ -89,7 +90,6 @@ require ( github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect github.com/BurntSushi/toml v1.1.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver v1.5.0 // indirect github.com/Masterminds/sprig v2.22.0+incompatible // indirect github.com/Microsoft/go-winio v0.5.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20211112122917-428f8eabeeb3 // indirect