[MM-48878] cmd/mattermost/export: start export command without metrics (#21857)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-12-23 09:45:42 +03:00
коммит произвёл GitHub
родитель 7a8b09c242
Коммит 06745d9b61
5 изменённых файлов: 19 добавлений и 21 удалений

Просмотреть файл

@@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/audit"
"github.com/mattermost/mattermost-server/v6/config"
"github.com/mattermost/mattermost-server/v6/store/sqlstore"
@@ -100,7 +101,7 @@ func initDbCmdF(command *cobra.Command, _ []string) error {
}
func resetCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.SkipPostInitialization())
if err != nil {
return err
}

Просмотреть файл

@@ -10,6 +10,7 @@ import (
"path/filepath"
"time"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/app/request"
"github.com/mattermost/mattermost-server/v6/audit"
"github.com/mattermost/mattermost-server/v6/model"
@@ -93,7 +94,7 @@ func init() {
}
func scheduleExportCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.SkipPostInitialization())
if err != nil {
return err
}
@@ -153,7 +154,7 @@ func scheduleExportCmdF(command *cobra.Command, args []string) error {
func buildExportCmdF(format string) func(command *cobra.Command, args []string) error {
return func(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.SkipPostInitialization())
license := a.Srv().License()
if err != nil {
return err
@@ -201,7 +202,7 @@ func buildExportCmdF(format string) func(command *cobra.Command, args []string)
}
func bulkExportCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.SkipPostInitialization())
if err != nil {
return err
}

Просмотреть файл

@@ -14,8 +14,8 @@ import (
"github.com/mattermost/mattermost-server/v6/utils"
)
func initDBCommandContextCobra(command *cobra.Command, readOnlyConfigStore bool) (*app.App, error) {
a, err := initDBCommandContext(getConfigDSN(command, config.GetEnvironment()), readOnlyConfigStore)
func initDBCommandContextCobra(command *cobra.Command, readOnlyConfigStore bool, options ...app.Option) (*app.App, error) {
a, err := initDBCommandContext(getConfigDSN(command, config.GetEnvironment()), readOnlyConfigStore, options...)
if err != nil {
// Returning an error just prints the usage message, so actually panic
panic(err)
@@ -27,25 +27,19 @@ func initDBCommandContextCobra(command *cobra.Command, readOnlyConfigStore bool)
return a, nil
}
func InitDBCommandContextCobra(command *cobra.Command) (*app.App, error) {
return initDBCommandContextCobra(command, true)
func InitDBCommandContextCobra(command *cobra.Command, options ...app.Option) (*app.App, error) {
return initDBCommandContextCobra(command, true, options...)
}
func InitDBCommandContextCobraReadWrite(command *cobra.Command) (*app.App, error) {
return initDBCommandContextCobra(command, false)
}
func initDBCommandContext(configDSN string, readOnlyConfigStore bool) (*app.App, error) {
func initDBCommandContext(configDSN string, readOnlyConfigStore bool, options ...app.Option) (*app.App, error) {
if err := utils.TranslationsPreInit(); err != nil {
return nil, err
}
model.AppErrorInit(i18n.T)
s, err := app.NewServer(
// The option order is important as app.Config option reads app.StartMetrics option.
app.StartMetrics,
app.Config(configDSN, readOnlyConfigStore, nil),
)
// The option order is important as app.Config option reads app.StartMetrics option.
options = append(options, app.Config(configDSN, readOnlyConfigStore, nil))
s, err := app.NewServer(options...)
if err != nil {
return nil, err
}

Просмотреть файл

@@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/audit"
"github.com/mattermost/mattermost-server/v6/config"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@@ -34,7 +35,7 @@ func jobserverCmdF(command *cobra.Command, args []string) error {
noSchedule, _ := command.Flags().GetBool("noschedule")
// Initialize
a, err := initDBCommandContext(getConfigDSN(command, config.GetEnvironment()), false)
a, err := initDBCommandContext(getConfigDSN(command, config.GetEnvironment()), false, app.StartMetrics)
if err != nil {
return err
}

Просмотреть файл

@@ -14,6 +14,7 @@ import (
"github.com/spf13/cobra"
"github.com/mattermost/mattermost-server/v6/api4"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/i18n"
"github.com/mattermost/mattermost-server/v6/wsapi"
@@ -46,7 +47,7 @@ func init() {
}
func webClientTestsCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.StartMetrics)
if err != nil {
return err
}
@@ -70,7 +71,7 @@ func webClientTestsCmdF(command *cobra.Command, args []string) error {
}
func serverForWebClientTestsCmdF(command *cobra.Command, args []string) error {
a, err := InitDBCommandContextCobra(command)
a, err := InitDBCommandContextCobra(command, app.StartMetrics)
if err != nil {
return err
}