forked from mattermost/mattermost
/
options.go
82 lines (67 loc) · 1.64 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"github.com/mattermost/mattermost-server/store"
)
type Option func(s *Server)
// By default, the app will use the store specified by the configuration. This allows you to
// construct an app with a different store.
//
// The override parameter must be either a store.Store or func(App) store.Store.
func StoreOverride(override interface{}) Option {
return func(s *Server) {
switch o := override.(type) {
case store.Store:
s.newStore = func() store.Store {
return o
}
case func(*Server) store.Store:
s.newStore = func() store.Store {
return o(s)
}
default:
panic("invalid StoreOverride")
}
}
}
func ConfigFile(file string) Option {
return func(s *Server) {
s.configFile = file
}
}
func RunJobs(s *Server) {
s.runjobs = true
}
func JoinCluster(s *Server) {
s.joinCluster = true
}
func StartMetrics(s *Server) {
s.startMetrics = true
}
func StartElasticsearch(s *Server) {
s.startElasticsearch = true
}
func DisableConfigWatch(s *Server) {
s.disableConfigWatch = true
}
type AppOption func(a *App)
type AppOptionCreator func() []AppOption
func ServerConnector(s *Server) AppOption {
return func(a *App) {
a.Srv = s
a.Log = s.Log
a.AccountMigration = s.AccountMigration
a.Cluster = s.Cluster
a.Compliance = s.Compliance
a.DataRetention = s.DataRetention
a.Elasticsearch = s.Elasticsearch
a.Ldap = s.Ldap
a.MessageExport = s.MessageExport
a.Metrics = s.Metrics
a.Saml = s.Saml
a.HTTPService = s.HTTPService
a.ImageProxy = s.ImageProxy
a.Timezones = s.timezones
}
}