From 4ce35acf0157e8d31f46a6ea6c7cf2e60d8be1fa Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Tue, 4 Jan 2022 12:35:35 +0100 Subject: [PATCH 1/3] 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 00000000000..6714300c1bc --- /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 9cd3c95d8f4..69a786eb963 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 f5778bd59ca..a8e362a60a7 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 From 5f0c635f92b94a2bbbc77d280290922389e304db Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 6 May 2022 16:41:52 +0200 Subject: [PATCH 2/3] make status values configurable --- extensions/frontend/pkg/revaconfig/config.go | 18 +++----- extensions/ocdav/pkg/command/server.go | 5 +++ extensions/ocdav/pkg/config/config.go | 10 +++++ .../pkg/config/defaults/defaultconfig.go | 8 ++++ go.mod | 2 +- go.sum | 6 +-- ocis-pkg/version/version.go | 43 ++++++++++++++++++- 7 files changed, 74 insertions(+), 18 deletions(-) diff --git a/extensions/frontend/pkg/revaconfig/config.go b/extensions/frontend/pkg/revaconfig/config.go index 69a786eb963..6adf5740bd9 100644 --- a/extensions/frontend/pkg/revaconfig/config.go +++ b/extensions/frontend/pkg/revaconfig/config.go @@ -4,17 +4,12 @@ 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, @@ -144,10 +139,11 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "installed": true, "maintenance": false, "needsDbUpgrade": false, - "version": version.String + ".0", - "versionstring": version.String, + "version": version.Long(), + "versionstring": version.GetString(), "edition": "Community", - "productname": "oCIS", + "productname": "Infinite Scale", + "product": "oCIS", "hostname": "", }, "support_url_signing": true, @@ -218,9 +214,9 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "version": map[string]interface{}{ "product": "oCIS", "edition": "Community", - "major": parsedVersion.Major(), - "minor": parsedVersion.Minor(), - "micro": parsedVersion.Patch(), + "major": version.Parsed().Major(), + "minor": version.Parsed().Minor(), + "micro": version.Parsed().Patch(), "string": version.String, }, }, diff --git a/extensions/ocdav/pkg/command/server.go b/extensions/ocdav/pkg/command/server.go index f55c641003c..b9a109d2750 100644 --- a/extensions/ocdav/pkg/command/server.go +++ b/extensions/ocdav/pkg/command/server.go @@ -55,6 +55,11 @@ func Server(cfg *config.Config) *cli.Command { ocdav.Prefix(cfg.HTTP.Prefix), ocdav.GatewaySvc(cfg.Reva.Address), ocdav.JWTSecret(cfg.TokenManager.JWTSecret), + ocdav.ProductName(cfg.Status.ProductName), + ocdav.Product(cfg.Status.Product), + ocdav.Version(cfg.Status.Version), + ocdav.VersionString(cfg.Status.VersionString), + ocdav.Edition(cfg.Status.Edition), // ocdav.FavoriteManager() // FIXME needs a proper persistence implementation // ocdav.LockSystem(), // will default to the CS3 lock system // ocdav.TLSConfig() // tls config for the http server diff --git a/extensions/ocdav/pkg/config/config.go b/extensions/ocdav/pkg/config/config.go index 92395e3a43e..8c7e2407dcd 100644 --- a/extensions/ocdav/pkg/config/config.go +++ b/extensions/ocdav/pkg/config/config.go @@ -33,6 +33,7 @@ type Config struct { Middleware Middleware `yaml:"middleware"` Context context.Context `yaml:"-"` + Status Status `yaml:"-"` } type Tracing struct { Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED;OCDAV_TRACING_ENABLED" desc:"Activates tracing."` @@ -75,3 +76,12 @@ type Middleware struct { type Auth struct { CredentialsByUserAgent map[string]string `yaml:"credentials_by_user_agent"` } + +// Status holds the configurable values for the status.php +type Status struct { + Version string + VersionString string + Product string + ProductName string + Edition string +} diff --git a/extensions/ocdav/pkg/config/defaults/defaultconfig.go b/extensions/ocdav/pkg/config/defaults/defaultconfig.go index d151762cc57..b2c917765cb 100644 --- a/extensions/ocdav/pkg/config/defaults/defaultconfig.go +++ b/extensions/ocdav/pkg/config/defaults/defaultconfig.go @@ -2,6 +2,7 @@ package defaults import ( "github.com/owncloud/ocis/v2/extensions/ocdav/pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/version" ) func FullDefaultConfig() *config.Config { @@ -42,6 +43,13 @@ func DefaultConfig() *config.Config { CredentialsByUserAgent: map[string]string{}, }, }, + Status: config.Status{ + Version: version.Long(), + VersionString: version.GetString(), + Product: "oCIS", + ProductName: "Infinite Scale", + Edition: "Community", + }, } } diff --git a/go.mod b/go.mod index a8e362a60a7..0d56b6a4578 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/blevesearch/bleve_index_api v1.0.1 github.com/coreos/go-oidc/v3 v3.1.0 github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde - github.com/cs3org/reva/v2 v2.3.1-0.20220506133959-1ad146903c6f + github.com/cs3org/reva/v2 v2.3.1-0.20220506154310-71844dde23d4 github.com/disintegration/imaging v1.6.2 github.com/glauth/glauth/v2 v2.0.0-20211021011345-ef3151c28733 github.com/go-chi/chi/v5 v5.0.7 diff --git a/go.sum b/go.sum index b806db17177..b1a5440324a 100644 --- a/go.sum +++ b/go.sum @@ -318,10 +318,8 @@ github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde h1:WrD9O8ZaWvsm0 github.com/cs3org/go-cs3apis v0.0.0-20220412090512-93c5918b4bde/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= github.com/cs3org/reva v1.18.0 h1:MbPS5ZAa8RzKcTxAVeSDdISB3XXqLIxqB03BTN5ReBY= github.com/cs3org/reva v1.18.0/go.mod h1:e5VDUDu4vVWIeVkZcW//n6UZzhGGMa+Tz/whCiX3N6o= -github.com/cs3org/reva/v2 v2.3.0 h1:AwDwqqzAKTrkBz1ifOy3U92C12zk92uBw6LyhLAjCBc= -github.com/cs3org/reva/v2 v2.3.0/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng= -github.com/cs3org/reva/v2 v2.3.1-0.20220506133959-1ad146903c6f h1:1vv8pODAoBgFGCP7UGoQCxvY6hK3vb6KirlqUNRcRys= -github.com/cs3org/reva/v2 v2.3.1-0.20220506133959-1ad146903c6f/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng= +github.com/cs3org/reva/v2 v2.3.1-0.20220506154310-71844dde23d4 h1:nr35Kdfp8lnYTxissRlgqIOirIe2NpE3+OEq4GRbGDg= +github.com/cs3org/reva/v2 v2.3.1-0.20220506154310-71844dde23d4/go.mod h1:2e/4HcIy54Mic3V7Ow0bz4n5dkZU0dHIZSWomFe5vng= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= diff --git a/ocis-pkg/version/version.go b/ocis-pkg/version/version.go index 81e81815f46..6ef03d8c179 100644 --- a/ocis-pkg/version/version.go +++ b/ocis-pkg/version/version.go @@ -1,15 +1,18 @@ package version import ( + "strconv" "time" + + "github.com/Masterminds/semver" ) var ( // String gets defined by the build system. - String = "0.0.0" + String = "dev" // Date indicates the build date. - Date = "00000000" + Date = time.Now().Format("20060102") ) // Compiled returns the compile time of this service. @@ -17,3 +20,39 @@ func Compiled() time.Time { t, _ := time.Parse("20060102", Date) return t } + +func GetString() string { + if String == "dev" { + return "0.0.0+dev" + } + parsedVersion, err := semver.NewVersion(String) + // We have no semver version but a commitid + if err != nil { + return String + } + return parsedVersion.String() +} + +func Parsed() *semver.Version { + var versionToParse string + if String == "dev" { + versionToParse = "0.0.0+dev" + } + parsedVersion, err := semver.NewVersion(versionToParse) + // We have no semver version but a commitid + if err != nil { + parsedVersion, _ = semver.NewVersion("0.0.0+" + String) + } + return parsedVersion +} + +func Long() string { + var s string + if Parsed().Metadata() == "" { + s = "-" + Parsed().Prerelease() + } + s = "+" + Parsed().Metadata() + return strconv.FormatInt(Parsed().Major(), 10) + "." + + strconv.FormatInt(Parsed().Minor(), 10) + "." + + strconv.FormatInt(Parsed().Patch(), 10) + "." + "0" + s +} From 071db57f14762855174894f093a5bd96209666c2 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Sat, 7 May 2022 15:59:43 +0200 Subject: [PATCH 3/3] bump core commitID --- .drone.env | 4 +-- extensions/frontend/pkg/revaconfig/config.go | 6 ++-- .../pkg/config/defaults/defaultconfig.go | 2 +- ocis-pkg/version/version.go | 28 ++++++++----------- .../expected-failures-API-on-OCIS-storage.md | 4 --- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.drone.env b/.drone.env index 667a1868ce8..807a6b899fa 100644 --- a/.drone.env +++ b/.drone.env @@ -1,6 +1,6 @@ # The test runner source for API tests -CORE_COMMITID=403bd55c38a823f7915a04105e95fad5db84185b -CORE_BRANCH=master +CORE_COMMITID=b19721114df5cefeca22926a97e635245849ddf6 +CORE_BRANCH=version-status-php-fix2 # The test runner source for UI tests WEB_COMMITID=b747d299b66a2f9f11559c8c14ce3d6fd64a6135 diff --git a/extensions/frontend/pkg/revaconfig/config.go b/extensions/frontend/pkg/revaconfig/config.go index 6adf5740bd9..a7f30597c3a 100644 --- a/extensions/frontend/pkg/revaconfig/config.go +++ b/extensions/frontend/pkg/revaconfig/config.go @@ -143,7 +143,7 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "versionstring": version.GetString(), "edition": "Community", "productname": "Infinite Scale", - "product": "oCIS", + "product": "Infinite Scale", "hostname": "", }, "support_url_signing": true, @@ -212,12 +212,12 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { }, }, "version": map[string]interface{}{ - "product": "oCIS", + "product": "Infinite Scale", "edition": "Community", "major": version.Parsed().Major(), "minor": version.Parsed().Minor(), "micro": version.Parsed().Patch(), - "string": version.String, + "string": version.GetString(), }, }, }, diff --git a/extensions/ocdav/pkg/config/defaults/defaultconfig.go b/extensions/ocdav/pkg/config/defaults/defaultconfig.go index b2c917765cb..dcf990ab425 100644 --- a/extensions/ocdav/pkg/config/defaults/defaultconfig.go +++ b/extensions/ocdav/pkg/config/defaults/defaultconfig.go @@ -46,7 +46,7 @@ func DefaultConfig() *config.Config { Status: config.Status{ Version: version.Long(), VersionString: version.GetString(), - Product: "oCIS", + Product: "Infinite Scale", ProductName: "Infinite Scale", Edition: "Community", }, diff --git a/ocis-pkg/version/version.go b/ocis-pkg/version/version.go index 6ef03d8c179..1cfabd6f2ff 100644 --- a/ocis-pkg/version/version.go +++ b/ocis-pkg/version/version.go @@ -21,38 +21,32 @@ func Compiled() time.Time { return t } +// GetString returns a version string with pre-releases and metadata func GetString() string { - if String == "dev" { - return "0.0.0+dev" - } - parsedVersion, err := semver.NewVersion(String) - // We have no semver version but a commitid - if err != nil { - return String - } - return parsedVersion.String() + return Parsed().String() } +// Parsed returns a semver Version func Parsed() *semver.Version { - var versionToParse string + versionToParse := String if String == "dev" { versionToParse = "0.0.0+dev" } parsedVersion, err := semver.NewVersion(versionToParse) // We have no semver version but a commitid if err != nil { - parsedVersion, _ = semver.NewVersion("0.0.0+" + String) + parsedVersion, err = semver.NewVersion("0.0.0+" + String) + // this should never happen + if err != nil { + return &semver.Version{} + } } return parsedVersion } +// Long returns the legacy version with 4 number parts like 10.9.8.0 func Long() string { - var s string - if Parsed().Metadata() == "" { - s = "-" + Parsed().Prerelease() - } - s = "+" + Parsed().Metadata() return strconv.FormatInt(Parsed().Major(), 10) + "." + strconv.FormatInt(Parsed().Minor(), 10) + "." + - strconv.FormatInt(Parsed().Patch(), 10) + "." + "0" + s + strconv.FormatInt(Parsed().Patch(), 10) + "." + "0" } diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index ab30ab97952..086d3b93a4b 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -1613,10 +1613,6 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers - [apiMain/checksums.feature:233](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiMain/checksums.feature#L233) -#### [status does not have new product data item](https://github.com/owncloud/ocis/issues/3317) - -- [apiCapabilities/capabilities.feature:959](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiCapabilities/capabilities.feature#L959) - #### public links without permission are allowed now - [apiShareUpdateToShares/updateShare.feature:113](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareUpdateToShares/updateShare.feature#L113)