diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-06 17:12:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 17:12:54 -0500 |
commit | 1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 (patch) | |
tree | 2766bacc1f045fa685ca3d8310cd6174d0311d09 /cmd | |
parent | b84bd21089d305333fa4114b95be70f5ad94ad1b (diff) | |
download | chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.gz chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.bz2 chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.zip |
app type transition (#7167)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/platform/channel.go | 26 | ||||
-rw-r--r-- | cmd/platform/channelargs.go | 4 | ||||
-rw-r--r-- | cmd/platform/config.go | 3 | ||||
-rw-r--r-- | cmd/platform/import.go | 5 | ||||
-rw-r--r-- | cmd/platform/init.go | 6 | ||||
-rw-r--r-- | cmd/platform/license.go | 2 | ||||
-rw-r--r-- | cmd/platform/mattermost.go | 2 | ||||
-rw-r--r-- | cmd/platform/roles.go | 4 | ||||
-rw-r--r-- | cmd/platform/server.go | 30 | ||||
-rw-r--r-- | cmd/platform/team.go | 8 | ||||
-rw-r--r-- | cmd/platform/teamargs.go | 4 | ||||
-rw-r--r-- | cmd/platform/test.go | 13 | ||||
-rw-r--r-- | cmd/platform/user.go | 14 | ||||
-rw-r--r-- | cmd/platform/userargs.go | 6 | ||||
-rw-r--r-- | cmd/platform/version.go | 2 |
15 files changed, 66 insertions, 63 deletions
diff --git a/cmd/platform/channel.go b/cmd/platform/channel.go index c9256a37f..05c3c5eae 100644 --- a/cmd/platform/channel.go +++ b/cmd/platform/channel.go @@ -170,7 +170,7 @@ func createChannelCmdF(cmd *cobra.Command, args []string) error { CreatorId: "", } - if _, err := app.CreateChannel(channel, false); err != nil { + if _, err := app.Global().CreateChannel(channel, false); err != nil { return err } @@ -208,7 +208,7 @@ func removeUserFromChannel(channel *model.Channel, user *model.User, userArg str CommandPrintErrorln("Can't find user '" + userArg + "'") return } - if err := app.RemoveUserFromChannel(user.Id, "", channel); err != nil { + if err := app.Global().RemoveUserFromChannel(user.Id, "", channel); err != nil { CommandPrintErrorln("Unable to remove '" + userArg + "' from " + channel.Name + ". Error: " + err.Error()) } } @@ -244,7 +244,7 @@ func addUserToChannel(channel *model.Channel, user *model.User, userArg string) CommandPrintErrorln("Can't find user '" + userArg + "'") return } - if _, err := app.AddUserToChannel(user, channel); err != nil { + if _, err := app.Global().AddUserToChannel(user, channel); err != nil { CommandPrintErrorln("Unable to add '" + userArg + "' from " + channel.Name + ". Error: " + err.Error()) } } @@ -264,7 +264,7 @@ func archiveChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find channel '" + args[i] + "'") continue } - if result := <-app.Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil { + if result := <-app.Global().Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); result.Err != nil { CommandPrintErrorln("Unable to archive channel '" + channel.Name + "' error: " + result.Err.Error()) } } @@ -308,7 +308,7 @@ func deleteChannelsCmdF(cmd *cobra.Command, args []string) error { } func deleteChannel(channel *model.Channel) *model.AppError { - return app.PermanentDeleteChannel(channel) + return app.Global().PermanentDeleteChannel(channel) } func moveChannelsCmdF(cmd *cobra.Command, args []string) error { @@ -344,30 +344,30 @@ func moveChannelsCmdF(cmd *cobra.Command, args []string) error { func moveChannel(team *model.Team, channel *model.Channel) *model.AppError { oldTeamId := channel.TeamId - if err := app.MoveChannel(team, channel); err != nil { + if err := app.Global().MoveChannel(team, channel); err != nil { return err } - if incomingWebhooks, err := app.GetIncomingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil { + if incomingWebhooks, err := app.Global().GetIncomingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil { return err } else { for _, webhook := range incomingWebhooks { if webhook.ChannelId == channel.Id { webhook.TeamId = team.Id - if result := <-app.Srv.Store.Webhook().UpdateIncoming(webhook); result.Err != nil { + if result := <-app.Global().Srv.Store.Webhook().UpdateIncoming(webhook); result.Err != nil { CommandPrintErrorln("Failed to move incoming webhook '" + webhook.Id + "' to new team.") } } } } - if outgoingWebhooks, err := app.GetOutgoingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil { + if outgoingWebhooks, err := app.Global().GetOutgoingWebhooksForTeamPage(oldTeamId, 0, 10000000); err != nil { return err } else { for _, webhook := range outgoingWebhooks { if webhook.ChannelId == channel.Id { webhook.TeamId = team.Id - if result := <-app.Srv.Store.Webhook().UpdateOutgoing(webhook); result.Err != nil { + if result := <-app.Global().Srv.Store.Webhook().UpdateOutgoing(webhook); result.Err != nil { CommandPrintErrorln("Failed to move outgoing webhook '" + webhook.Id + "' to new team.") } } @@ -396,7 +396,7 @@ func listChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find team '" + args[i] + "'") continue } - if result := <-app.Srv.Store.Channel().GetAll(team.Id); result.Err != nil { + if result := <-app.Global().Srv.Store.Channel().GetAll(team.Id); result.Err != nil { CommandPrintErrorln("Unable to list channels for '" + args[i] + "'") } else { channels := result.Data.([]*model.Channel) @@ -433,7 +433,7 @@ func restoreChannelsCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find channel '" + args[i] + "'") continue } - if result := <-app.Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil { + if result := <-app.Global().Srv.Store.Channel().SetDeleteAt(channel.Id, 0, model.GetMillis()); result.Err != nil { CommandPrintErrorln("Unable to restore channel '" + args[i] + "'") } } @@ -475,7 +475,7 @@ func modifyChannelCmdF(cmd *cobra.Command, args []string) error { channel.Type = model.CHANNEL_PRIVATE } - if _, err := app.UpdateChannel(channel); err != nil { + if _, err := app.Global().UpdateChannel(channel); err != nil { return errors.New("Failed to update channel '" + args[0] + "' - " + err.Error()) } diff --git a/cmd/platform/channelargs.go b/cmd/platform/channelargs.go index 02ee1b6ab..024073915 100644 --- a/cmd/platform/channelargs.go +++ b/cmd/platform/channelargs.go @@ -42,7 +42,7 @@ func getChannelFromChannelArg(channelArg string) *model.Channel { return nil } - if result := <-app.Srv.Store.Channel().GetByNameIncludeDeleted(team.Id, channelPart, true); result.Err == nil { + if result := <-app.Global().Srv.Store.Channel().GetByNameIncludeDeleted(team.Id, channelPart, true); result.Err == nil { channel = result.Data.(*model.Channel) } else { fmt.Println(result.Err.Error()) @@ -50,7 +50,7 @@ func getChannelFromChannelArg(channelArg string) *model.Channel { } if channel == nil { - if result := <-app.Srv.Store.Channel().Get(channelPart, true); result.Err == nil { + if result := <-app.Global().Srv.Store.Channel().Get(channelPart, true); result.Err == nil { channel = result.Data.(*model.Channel) } } diff --git a/cmd/platform/config.go b/cmd/platform/config.go index f9b9daa85..40dd99fbb 100644 --- a/cmd/platform/config.go +++ b/cmd/platform/config.go @@ -5,10 +5,11 @@ package main import ( "encoding/json" "errors" + "os" + "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" "github.com/spf13/cobra" - "os" ) var configCmd = &cobra.Command{ diff --git a/cmd/platform/import.go b/cmd/platform/import.go index bf027340a..7fe573aaf 100644 --- a/cmd/platform/import.go +++ b/cmd/platform/import.go @@ -7,6 +7,7 @@ import ( "os" "fmt" + "github.com/mattermost/platform/app" "github.com/spf13/cobra" ) @@ -70,7 +71,7 @@ func slackImportCmdF(cmd *cobra.Command, args []string) error { CommandPrettyPrintln("Running Slack Import. This may take a long time for large teams or teams with many messages.") - app.SlackImport(fileReader, fileInfo.Size(), team.Id) + app.Global().SlackImport(fileReader, fileInfo.Size(), team.Id) CommandPrettyPrintln("Finished Slack Import.") @@ -120,7 +121,7 @@ func bulkImportCmdF(cmd *cobra.Command, args []string) error { CommandPrettyPrintln("") - if err, lineNumber := app.BulkImport(fileReader, !apply, workers); err != nil { + if err, lineNumber := app.Global().BulkImport(fileReader, !apply, workers); err != nil { CommandPrettyPrintln(err.Error()) if lineNumber != 0 { CommandPrettyPrintln(fmt.Sprintf("Error occurred on data file line %v", lineNumber)) diff --git a/cmd/platform/init.go b/cmd/platform/init.go index 5f915b9ab..c2b1c6bc0 100644 --- a/cmd/platform/init.go +++ b/cmd/platform/init.go @@ -28,10 +28,10 @@ func initDBCommandContext(configFileLocation string) error { utils.ConfigureCmdLineLog() - app.NewServer() - app.InitStores() + app.Global().NewServer() + app.Global().InitStores() if model.BuildEnterpriseReady == "true" { - app.LoadLicense() + app.Global().LoadLicense() } return nil diff --git a/cmd/platform/license.go b/cmd/platform/license.go index dcb37092f..45a56a94c 100644 --- a/cmd/platform/license.go +++ b/cmd/platform/license.go @@ -42,7 +42,7 @@ func uploadLicenseCmdF(cmd *cobra.Command, args []string) error { return err } - if _, err := app.SaveLicense(fileBytes); err != nil { + if _, err := app.Global().SaveLicense(fileBytes); err != nil { return err } diff --git a/cmd/platform/mattermost.go b/cmd/platform/mattermost.go index 4b564e1ab..a8845148a 100644 --- a/cmd/platform/mattermost.go +++ b/cmd/platform/mattermost.go @@ -79,7 +79,7 @@ func resetCmdF(cmd *cobra.Command, args []string) error { } } - app.Srv.Store.DropAllTables() + app.Global().Srv.Store.DropAllTables() CommandPrettyPrintln("Database sucessfully reset") return nil diff --git a/cmd/platform/roles.go b/cmd/platform/roles.go index 97d6edf17..f41c0c206 100644 --- a/cmd/platform/roles.go +++ b/cmd/platform/roles.go @@ -52,7 +52,7 @@ func makeSystemAdminCmdF(cmd *cobra.Command, args []string) error { return errors.New("Unable to find user '" + args[i] + "'") } - if _, err := app.UpdateUserRoles(user.Id, "system_admin system_user"); err != nil { + if _, err := app.Global().UpdateUserRoles(user.Id, "system_admin system_user"); err != nil { return err } } @@ -75,7 +75,7 @@ func makeMemberCmdF(cmd *cobra.Command, args []string) error { return errors.New("Unable to find user '" + args[i] + "'") } - if _, err := app.UpdateUserRoles(user.Id, "system_user"); err != nil { + if _, err := app.Global().UpdateUserRoles(user.Id, "system_user"); err != nil { return err } } diff --git a/cmd/platform/server.go b/cmd/platform/server.go index f5be5a5fc..1870641b7 100644 --- a/cmd/platform/server.go +++ b/cmd/platform/server.go @@ -71,18 +71,18 @@ func runServer(configFileLocation string) { l4g.Error("Problem with file storage settings: " + err.Error()) } - app.NewServer() - app.InitStores() + app.Global().NewServer() + app.Global().InitStores() api.InitRouter() wsapi.InitRouter() api4.InitApi(false) api.InitApi() - app.InitPlugins() + app.Global().InitPlugins() wsapi.InitApi() web.InitWeb() if model.BuildEnterpriseReady == "true" { - app.LoadLicense() + app.Global().LoadLicense() } if !utils.IsLicensed() && len(utils.Cfg.SqlSettings.DataSourceReplicas) > 1 { @@ -98,7 +98,7 @@ func runServer(configFileLocation string) { resetStatuses() - app.StartServer() + app.Global().StartServer() // If we allow testing then listen for manual testing URL hits if utils.Cfg.ServiceSettings.EnableTesting { @@ -118,7 +118,7 @@ func runServer(configFileLocation string) { } if einterfaces.GetClusterInterface() != nil { - app.RegisterAllClusterMessageHandlers() + app.Global().RegisterAllClusterMessageHandlers() einterfaces.GetClusterInterface().StartInterNodeCommunication() } @@ -132,7 +132,7 @@ func runServer(configFileLocation string) { } } - jobs.Srv.Store = app.Srv.Store + jobs.Srv.Store = app.Global().Srv.Store if *utils.Cfg.JobSettings.RunJobs { jobs.Srv.StartWorkers() } @@ -157,7 +157,7 @@ func runServer(configFileLocation string) { jobs.Srv.StopSchedulers() jobs.Srv.StopWorkers() - app.StopServer() + app.Global().StopServer() } func runSecurityJob() { @@ -181,20 +181,20 @@ func runCommandWebhookCleanupJob() { } func resetStatuses() { - if result := <-app.Srv.Store.Status().ResetAll(); result.Err != nil { + if result := <-app.Global().Srv.Store.Status().ResetAll(); result.Err != nil { l4g.Error(utils.T("mattermost.reset_status.error"), result.Err.Error()) } } func setDiagnosticId() { - if result := <-app.Srv.Store.System().Get(); result.Err == nil { + if result := <-app.Global().Srv.Store.System().Get(); result.Err == nil { props := result.Data.(model.StringMap) id := props[model.SYSTEM_DIAGNOSTIC_ID] if len(id) == 0 { id = model.NewId() systemId := &model.System{Name: model.SYSTEM_DIAGNOSTIC_ID, Value: id} - <-app.Srv.Store.System().Save(systemId) + <-app.Global().Srv.Store.System().Save(systemId) } utils.CfgDiagnosticId = id @@ -202,19 +202,19 @@ func setDiagnosticId() { } func doSecurity() { - app.DoSecurityUpdateCheck() + app.Global().DoSecurityUpdateCheck() } func doDiagnostics() { if *utils.Cfg.LogSettings.EnableDiagnostics { - app.SendDailyDiagnostics() + app.Global().SendDailyDiagnostics() } } func doTokenCleanup() { - app.Srv.Store.Token().Cleanup() + app.Global().Srv.Store.Token().Cleanup() } func doCommandWebhookCleanup() { - app.Srv.Store.CommandWebhook().Cleanup() + app.Global().Srv.Store.CommandWebhook().Cleanup() } diff --git a/cmd/platform/team.go b/cmd/platform/team.go index 4e6a592a7..af367a717 100644 --- a/cmd/platform/team.go +++ b/cmd/platform/team.go @@ -94,7 +94,7 @@ func createTeamCmdF(cmd *cobra.Command, args []string) error { Type: teamType, } - if _, err := app.CreateTeam(team); err != nil { + if _, err := app.Global().CreateTeam(team); err != nil { return errors.New("Team creation failed: " + err.Error()) } @@ -128,7 +128,7 @@ func removeUserFromTeam(team *model.Team, user *model.User, userArg string) { CommandPrintErrorln("Can't find user '" + userArg + "'") return } - if err := app.LeaveTeam(team, user); err != nil { + if err := app.Global().LeaveTeam(team, user); err != nil { CommandPrintErrorln("Unable to remove '" + userArg + "' from " + team.Name + ". Error: " + err.Error()) } } @@ -160,7 +160,7 @@ func addUserToTeam(team *model.Team, user *model.User, userArg string) { CommandPrintErrorln("Can't find user '" + userArg + "'") return } - if err := app.JoinUserToTeam(team, user, ""); err != nil { + if err := app.Global().JoinUserToTeam(team, user, ""); err != nil { CommandPrintErrorln("Unable to add '" + userArg + "' to " + team.Name) } } @@ -207,5 +207,5 @@ func deleteTeamsCmdF(cmd *cobra.Command, args []string) error { } func deleteTeam(team *model.Team) *model.AppError { - return app.PermanentDeleteTeam(team) + return app.Global().PermanentDeleteTeam(team) } diff --git a/cmd/platform/teamargs.go b/cmd/platform/teamargs.go index 31f7b489e..3b83aaa59 100644 --- a/cmd/platform/teamargs.go +++ b/cmd/platform/teamargs.go @@ -18,12 +18,12 @@ func getTeamsFromTeamArgs(teamArgs []string) []*model.Team { func getTeamFromTeamArg(teamArg string) *model.Team { var team *model.Team - if result := <-app.Srv.Store.Team().GetByName(teamArg); result.Err == nil { + if result := <-app.Global().Srv.Store.Team().GetByName(teamArg); result.Err == nil { team = result.Data.(*model.Team) } if team == nil { - if result := <-app.Srv.Store.Team().Get(teamArg); result.Err == nil { + if result := <-app.Global().Srv.Store.Team().Get(teamArg); result.Err == nil { team = result.Data.(*model.Team) } } diff --git a/cmd/platform/test.go b/cmd/platform/test.go index efc89a2b2..9b652931d 100644 --- a/cmd/platform/test.go +++ b/cmd/platform/test.go @@ -9,14 +9,15 @@ import ( "os" "os/exec" + "os/signal" + "syscall" + "github.com/mattermost/platform/api" "github.com/mattermost/platform/api4" "github.com/mattermost/platform/app" "github.com/mattermost/platform/utils" "github.com/mattermost/platform/wsapi" "github.com/spf13/cobra" - "os/signal" - "syscall" ) var testCmd = &cobra.Command{ @@ -56,9 +57,9 @@ func webClientTestsCmdF(cmd *cobra.Command, args []string) error { api.InitApi() wsapi.InitApi() setupClientTests() - app.StartServer() + app.Global().StartServer() runWebClientTests() - app.StopServer() + app.Global().StopServer() return nil } @@ -75,13 +76,13 @@ func serverForWebClientTestsCmdF(cmd *cobra.Command, args []string) error { api.InitApi() wsapi.InitApi() setupClientTests() - app.StartServer() + app.Global().StartServer() c := make(chan os.Signal) signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) <-c - app.StopServer() + app.Global().StopServer() return nil } diff --git a/cmd/platform/user.go b/cmd/platform/user.go index cc0ceb2a0..c211ea75c 100644 --- a/cmd/platform/user.go +++ b/cmd/platform/user.go @@ -188,7 +188,7 @@ func changeUserActiveStatus(user *model.User, userArg string, activate bool) err if user.IsLDAPUser() { return errors.New("You can not modify the activation status of AD/LDAP accounts. Please modify through the AD/LDAP server.") } - if _, err := app.UpdateActive(user, activate); err != nil { + if _, err := app.Global().UpdateActive(user, activate); err != nil { return fmt.Errorf("Unable to change activation status of user: %v", userArg) } @@ -241,13 +241,13 @@ func userCreateCmdF(cmd *cobra.Command, args []string) error { Locale: locale, } - ruser, err := app.CreateUser(user) + ruser, err := app.Global().CreateUser(user) if err != nil { return errors.New("Unable to create user. Error: " + err.Error()) } if systemAdmin { - app.UpdateUserRoles(ruser.Id, "system_user system_admin") + app.Global().UpdateUserRoles(ruser.Id, "system_user system_admin") } CommandPrettyPrintln("Created User") @@ -310,7 +310,7 @@ func resetUserPasswordCmdF(cmd *cobra.Command, args []string) error { } password := args[1] - if result := <-app.Srv.Store.User().UpdatePassword(user.Id, model.HashPassword(password)); result.Err != nil { + if result := <-app.Global().Srv.Store.User().UpdatePassword(user.Id, model.HashPassword(password)); result.Err != nil { return result.Err } @@ -373,7 +373,7 @@ func deleteUserCmdF(cmd *cobra.Command, args []string) error { return errors.New("Unable to find user '" + args[i] + "'") } - if err := app.PermanentDeleteUser(user); err != nil { + if err := app.Global().PermanentDeleteUser(user); err != nil { return err } } @@ -406,7 +406,7 @@ func deleteAllUsersCommandF(cmd *cobra.Command, args []string) error { } } - if err := app.PermanentDeleteAllUsers(); err != nil { + if err := app.Global().PermanentDeleteAllUsers(); err != nil { return err } @@ -473,7 +473,7 @@ func verifyUserCmdF(cmd *cobra.Command, args []string) error { CommandPrintErrorln("Unable to find user '" + args[i] + "'") continue } - if cresult := <-app.Srv.Store.User().VerifyEmail(user.Id); cresult.Err != nil { + if cresult := <-app.Global().Srv.Store.User().VerifyEmail(user.Id); cresult.Err != nil { CommandPrintErrorln("Unable to verify '" + args[i] + "' email. Error: " + cresult.Err.Error()) } } diff --git a/cmd/platform/userargs.go b/cmd/platform/userargs.go index 43b53edd7..de45629c2 100644 --- a/cmd/platform/userargs.go +++ b/cmd/platform/userargs.go @@ -18,18 +18,18 @@ func getUsersFromUserArgs(userArgs []string) []*model.User { func getUserFromUserArg(userArg string) *model.User { var user *model.User - if result := <-app.Srv.Store.User().GetByEmail(userArg); result.Err == nil { + if result := <-app.Global().Srv.Store.User().GetByEmail(userArg); result.Err == nil { user = result.Data.(*model.User) } if user == nil { - if result := <-app.Srv.Store.User().GetByUsername(userArg); result.Err == nil { + if result := <-app.Global().Srv.Store.User().GetByUsername(userArg); result.Err == nil { user = result.Data.(*model.User) } } if user == nil { - if result := <-app.Srv.Store.User().Get(userArg); result.Err == nil { + if result := <-app.Global().Srv.Store.User().Get(userArg); result.Err == nil { user = result.Data.(*model.User) } } diff --git a/cmd/platform/version.go b/cmd/platform/version.go index ccbd73e02..735057c0c 100644 --- a/cmd/platform/version.go +++ b/cmd/platform/version.go @@ -31,5 +31,5 @@ func printVersion() { CommandPrintln("Build Date: " + model.BuildDate) CommandPrintln("Build Hash: " + model.BuildHash) CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady) - CommandPrintln("DB Version: " + app.Srv.Store.(*store.LayeredStore).DatabaseLayer.GetCurrentSchemaVersion()) + CommandPrintln("DB Version: " + app.Global().Srv.Store.(*store.LayeredStore).DatabaseLayer.GetCurrentSchemaVersion()) } |