From c78f004c71daf92cd1a48f059613577e5193aec8 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) --- go.mod | 2 +- storage/pkg/command/frontend.go | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index acf0186c9e9..a518c495227 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/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20220118152736-9e0be6c85d75 github.com/asim/go-micro/plugins/events/nats/v4 v4.0.0-20220118152736-9e0be6c85d75 @@ -88,7 +89,6 @@ require ( github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect github.com/BurntSushi/toml v1.0.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 diff --git a/storage/pkg/command/frontend.go b/storage/pkg/command/frontend.go index 4f8a912a0ff..cc4f9d715e9 100644 --- a/storage/pkg/command/frontend.go +++ b/storage/pkg/command/frontend.go @@ -9,12 +9,14 @@ import ( "strconv" "strings" + "github.com/Masterminds/semver" "github.com/cs3org/reva/v2/cmd/revad/runtime" "github.com/gofrs/uuid" "github.com/oklog/run" ociscfg "github.com/owncloud/ocis/ocis-pkg/config" "github.com/owncloud/ocis/ocis-pkg/conversions" "github.com/owncloud/ocis/ocis-pkg/sync" + "github.com/owncloud/ocis/ocis-pkg/version" "github.com/owncloud/ocis/storage/pkg/config" "github.com/owncloud/ocis/storage/pkg/server/debug" "github.com/owncloud/ocis/storage/pkg/tracing" @@ -140,6 +142,11 @@ func Frontend(cfg *config.Config) *cli.Command { // frontendConfigFromStruct will adapt an oCIS config struct into a reva mapstructure to start a reva service. func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[string]interface{}) map[string]interface{} { + parsedVersion, err := semver.NewVersion(version.String) + if err != nil { + parsedVersion, _ = semver.NewVersion("0.0.0") + } + return map[string]interface{}{ "core": map[string]interface{}{ "max_cpus": cfg.Reva.Users.MaxCPUs, @@ -300,10 +307,10 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s "version": map[string]interface{}{ "product": "oCIS", "edition": "Community", - "major": 1, - "minor": 16, - "micro": 0, - "string": "1.16.0", + "major": parsedVersion.Major(), + "minor": parsedVersion.Minor(), + "micro": parsedVersion.Patch(), + "string": version.String, }, }, },