cmd/version: skip server start to get the current mattermost version (#15234)

This commit is contained in:
Carlos Tadeu Panato Junior
2020-08-13 13:31:59 +02:00
committed by GitHub
parent 91a76b2df9
commit 4e43826c5c

View File

@@ -16,10 +16,18 @@ var VersionCmd = &cobra.Command{
}
func init() {
VersionCmd.Flags().Bool("skip-server-start", false, "Skip the server initialization and return the Mattermost version without the DB version.")
RootCmd.AddCommand(VersionCmd)
}
func versionCmdF(command *cobra.Command, args []string) error {
skipStart, _ := command.Flags().GetBool("skip-server-start")
if skipStart {
printVersionNoDB()
return nil
}
a, err := InitDBCommandContextCobra(command)
if err != nil {
return err
@@ -31,10 +39,14 @@ func versionCmdF(command *cobra.Command, args []string) error {
}
func printVersion(a *app.App) {
printVersionNoDB()
CommandPrintln("DB Version: " + a.Srv().Store.GetCurrentSchemaVersion())
}
func printVersionNoDB() {
CommandPrintln("Version: " + model.CurrentVersion)
CommandPrintln("Build Number: " + model.BuildNumber)
CommandPrintln("Build Date: " + model.BuildDate)
CommandPrintln("Build Hash: " + model.BuildHash)
CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady)
CommandPrintln("DB Version: " + a.Srv().Store.GetCurrentSchemaVersion())
}