diff --git a/.make/go.mk b/.make/go.mk index 48fa70bef5..1dec932a09 100644 --- a/.make/go.mk +++ b/.make/go.mk @@ -29,7 +29,7 @@ ifndef VERSION ifneq ($(DRONE_TAG),) VERSION ?= $(subst v,,$(DRONE_TAG)) else - VERSION ?= $(shell git rev-parse --short HEAD) + STRING ?= $(shell git rev-parse --short HEAD) endif endif @@ -37,8 +37,8 @@ ifndef DATE DATE := $(shell date -u '+%Y%m%d') endif -LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w -X "$(OCIS_REPO)/ocis-pkg/version.String=$(VERSION)" -X "$(OCIS_REPO)/ocis-pkg/version.Date=$(DATE)" -DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -X "$(OCIS_REPO)/ocis-pkg/version.String=$(VERSION)" -X "$(OCIS_REPO)/ocis-pkg/version.Date=$(DATE)" +LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -s -w -X "$(OCIS_REPO)/ocis-pkg/version.String=$(STRING)" -X "$(OCIS_REPO)/ocis-pkg/version.Tag=$(VERSION)" -X "$(OCIS_REPO)/ocis-pkg/version.Date=$(DATE)" +DEBUG_LDFLAGS += -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn -X "$(OCIS_REPO)/ocis-pkg/version.String=$(STRING)" -X "$(OCIS_REPO)/ocis-pkg/version.Tag=$(VERSION)"-X "$(OCIS_REPO)/ocis-pkg/version.Date=$(DATE)" GCFLAGS += all=-N -l diff --git a/changelog/unreleased/fix-version.md b/changelog/unreleased/fix-version.md new file mode 100644 index 0000000000..36c5eb0a59 --- /dev/null +++ b/changelog/unreleased/fix-version.md @@ -0,0 +1,6 @@ +Bugfix: Fix version number in status page + +We needed to undo the version number changes on the status page to keep compatibility for legacy clients. We added a new field `productversion` for the actual version of the product. + +https://github.com/owncloud/ocis/issues/3788 +https://github.com/owncloud/ocis/pull/3805 diff --git a/extensions/frontend/pkg/revaconfig/config.go b/extensions/frontend/pkg/revaconfig/config.go index 5a23aebe98..3b56cabb74 100644 --- a/extensions/frontend/pkg/revaconfig/config.go +++ b/extensions/frontend/pkg/revaconfig/config.go @@ -139,11 +139,12 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "installed": true, "maintenance": false, "needsDbUpgrade": false, - "version": version.Long(), - "versionstring": version.GetString(), + "version": version.Legacy, + "versionstring": version.LegacyString, "edition": "Community", "productname": "Infinite Scale", "product": "Infinite Scale", + "productversion": version.GetString(), "hostname": "", }, "support_url_signing": true, @@ -215,10 +216,10 @@ func FrontendConfigFromStruct(cfg *config.Config) map[string]interface{} { "version": map[string]interface{}{ "product": "Infinite Scale", "edition": "Community", - "major": version.Parsed().Major(), - "minor": version.Parsed().Minor(), - "micro": version.Parsed().Patch(), - "string": version.GetString(), + "major": version.ParsedLegacy().Major(), + "minor": version.ParsedLegacy().Minor(), + "micro": version.ParsedLegacy().Patch(), + "string": version.LegacyString, }, }, }, diff --git a/extensions/ocdav/pkg/command/server.go b/extensions/ocdav/pkg/command/server.go index 75fa0a471d..a544c7906c 100644 --- a/extensions/ocdav/pkg/command/server.go +++ b/extensions/ocdav/pkg/command/server.go @@ -58,6 +58,7 @@ func Server(cfg *config.Config) *cli.Command { ocdav.GatewaySvc(cfg.Reva.Address), ocdav.JWTSecret(cfg.TokenManager.JWTSecret), ocdav.ProductName(cfg.Status.ProductName), + ocdav.ProductVersion(cfg.Status.ProductVersion), ocdav.Product(cfg.Status.Product), ocdav.Version(cfg.Status.Version), ocdav.VersionString(cfg.Status.VersionString), diff --git a/extensions/ocdav/pkg/config/config.go b/extensions/ocdav/pkg/config/config.go index ca7108de95..de5470cd34 100644 --- a/extensions/ocdav/pkg/config/config.go +++ b/extensions/ocdav/pkg/config/config.go @@ -79,9 +79,10 @@ type Auth struct { // Status holds the configurable values for the status.php type Status struct { - Version string - VersionString string - Product string - ProductName string - Edition string + Version string + VersionString string + Product string + ProductName string + ProductVersion string + Edition string } diff --git a/extensions/ocdav/pkg/config/defaults/defaultconfig.go b/extensions/ocdav/pkg/config/defaults/defaultconfig.go index dcf990ab42..e41d021b8e 100644 --- a/extensions/ocdav/pkg/config/defaults/defaultconfig.go +++ b/extensions/ocdav/pkg/config/defaults/defaultconfig.go @@ -44,11 +44,12 @@ func DefaultConfig() *config.Config { }, }, Status: config.Status{ - Version: version.Long(), - VersionString: version.GetString(), - Product: "Infinite Scale", - ProductName: "Infinite Scale", - Edition: "Community", + Version: version.Legacy, + VersionString: version.LegacyString, + ProductVersion: version.GetString(), + Product: "Infinite Scale", + ProductName: "Infinite Scale", + Edition: "Community", }, } } diff --git a/extensions/proxy/pkg/config/defaults/defaultconfig.go b/extensions/proxy/pkg/config/defaults/defaultconfig.go index 64934fb895..b7f90f8d1f 100644 --- a/extensions/proxy/pkg/config/defaults/defaultconfig.go +++ b/extensions/proxy/pkg/config/defaults/defaultconfig.go @@ -128,6 +128,10 @@ func DefaultPolicies() []config.Policy { Endpoint: "/webdav/", Service: "com.owncloud.web.ocdav", }, + { + Endpoint: "/status", + Service: "com.owncloud.web.ocdav", + }, { Endpoint: "/status.php", Service: "com.owncloud.web.ocdav", diff --git a/ocis-pkg/version/version.go b/ocis-pkg/version/version.go index 1cfabd6f2f..f4a551d6a8 100644 --- a/ocis-pkg/version/version.go +++ b/ocis-pkg/version/version.go @@ -1,18 +1,31 @@ package version import ( - "strconv" "time" "github.com/Masterminds/semver" ) var ( - // String gets defined by the build system. - String = "dev" + // String gets defined by the build system + String string + + // Tag gets defined by the build system + Tag string + + // LatestTag is the latest released version plus the dev meta version. + // Will be overwritten by the release pipeline + // Needs a manual change for every tagged release + LatestTag = "2.0.0-beta1+dev" // Date indicates the build date. Date = time.Now().Format("20060102") + + // Legacy defines the old long 4 number ownCloud version needed for some clients + Legacy = "10.11.0.0" + + // LegacyString defines the old ownCloud version needed for some clients + LegacyString = "10.11.0" ) // Compiled returns the compile time of this service. @@ -27,26 +40,34 @@ func GetString() string { } // Parsed returns a semver Version -func Parsed() *semver.Version { - versionToParse := String - if String == "dev" { - versionToParse = "0.0.0+dev" +func Parsed() (version *semver.Version) { + versionToParse := LatestTag + if Tag != "" { + versionToParse = Tag } - parsedVersion, err := semver.NewVersion(versionToParse) + version, err := semver.NewVersion(versionToParse) // We have no semver version but a commitid if err != nil { - parsedVersion, err = semver.NewVersion("0.0.0+" + String) // this should never happen if err != nil { return &semver.Version{} } } - return parsedVersion + if String != "" { + nVersion, err := version.SetMetadata(String) + if err != nil { + return &semver.Version{} + } + version = &nVersion + } + return version } -// Long returns the legacy version with 4 number parts like 10.9.8.0 -func Long() string { - return strconv.FormatInt(Parsed().Major(), 10) + "." + - strconv.FormatInt(Parsed().Minor(), 10) + "." + - strconv.FormatInt(Parsed().Patch(), 10) + "." + "0" +// ParsedLegacy returns the legacy version +func ParsedLegacy() *semver.Version { + parsedVersion, err := semver.NewVersion(LegacyString) + if err != nil { + return &semver.Version{} + } + return parsedVersion }