github.com/demisto/mattermost-server@v4.9.0-rc3+incompatible/cmd/init.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package cmd 5 6 import ( 7 "github.com/mattermost/mattermost-server/app" 8 "github.com/mattermost/mattermost-server/model" 9 "github.com/mattermost/mattermost-server/utils" 10 "github.com/spf13/cobra" 11 ) 12 13 func InitDBCommandContextCobra(cmd *cobra.Command) (*app.App, error) { 14 config, err := cmd.Flags().GetString("config") 15 if err != nil { 16 return nil, err 17 } 18 19 a, err := InitDBCommandContext(config) 20 if err != nil { 21 // Returning an error just prints the usage message, so actually panic 22 panic(err) 23 } 24 25 a.DoAdvancedPermissionsMigration() 26 27 return a, nil 28 } 29 30 func InitDBCommandContext(configFileLocation string) (*app.App, error) { 31 if err := utils.TranslationsPreInit(); err != nil { 32 return nil, err 33 } 34 model.AppErrorInit(utils.T) 35 36 utils.ConfigureCmdLineLog() 37 38 a, err := app.New(app.ConfigFile(configFileLocation)) 39 if err != nil { 40 return nil, err 41 } 42 43 if model.BuildEnterpriseReady == "true" { 44 a.LoadLicense() 45 } 46 47 return a, nil 48 }