forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
naming.go
262 lines (232 loc) · 8.74 KB
/
naming.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/*
* Copyright (c) 2018. Abstrium SAS <team (at) pydio.com>
* This file is part of Pydio Cells.
*
* Pydio Cells is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio Cells is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio Cells. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <https://pydio.com>.
*/
package common
import (
"time"
hashiversion "github.com/hashicorp/go-version"
"go.uber.org/zap/zapcore"
)
// Various custom types internally used by Pydio.
type (
ServiceType string
ServiceTag string
ServiceName string
LogConfigType string
)
// Defines all constants for services names.
const (
SERVICE_NATS = "nats"
SERVICE_LOG = "log"
SERVICE_CONFIG = "config"
SERVICE_INSTALL = "install"
SERVICE_UPDATE = "update"
SERVICE_HEALTHCHECK = "healthcheck"
SERVICE_TAG_IDM = "idm"
SERVICE_TAG_SCHEDULER = "scheduler"
SERVICE_TAG_DATA = "data"
SERVICE_TAG_DATASOURCE = "datasource"
SERVICE_TAG_BROKER = "broker"
SERVICE_TAG_GATEWAY = "gateway"
SERVICE_TAG_DISCOVERY = "discovery"
SERVICE_TAG_FRONTEND = "frontend"
SERVICE_ACL = "acl"
SERVICE_SHARE = "share"
SERVICE_ROLE = "role"
SERVICE_USER = "user"
SERVICE_AUTH = "auth"
SERVICE_OAUTH = "oauth"
SERVICE_WORKSPACE = "workspace"
SERVICE_POLICY = "policy"
SERVICE_GRAPH = "graph"
SERVICE_USER_META = "user-meta"
SERVICE_USER_KEY = "user-key"
SERVICE_TREE = "tree"
SERVICE_META = "meta"
SERVICE_ENC_KEY = "data-key"
SERVICE_SEARCH = "search"
SERVICE_CHANGES = "changes"
SERVICE_SYNC = "sync"
SERVICE_TEMPLATES = "templates"
SERVICE_ACTIVITY = "activity"
SERVICE_MAILER = "mailer"
SERVICE_WEBSOCKET = "websocket"
SERVICE_CHAT = "chat"
SERVICE_FRONTEND = "frontend"
SERVICE_FRONT_STATICS = "statics"
SERVICE_TIMER = "timer"
SERVICE_JOBS = "jobs"
SERVICE_TASKS = "tasks"
SERVICE_VERSIONS = "versions"
SERVICE_DOCSTORE = "docstore"
SERVICE_DATA_ = "data."
SERVICE_DATA_INDEX = SERVICE_DATA_ + "index"
SERVICE_DATA_OBJECTS = SERVICE_DATA_ + "objects"
SERVICE_DATA_SYNC = SERVICE_DATA_ + "sync"
SERVICE_DATA_INDEX_ = SERVICE_DATA_INDEX + "."
SERVICE_DATA_OBJECTS_ = SERVICE_DATA_OBJECTS + "."
SERVICE_DATA_SYNC_ = SERVICE_DATA_SYNC + "."
SERVICE_GRPC_NAMESPACE_ = "pydio.grpc."
SERVICE_WEB_NAMESPACE_ = "pydio.web."
SERVICE_REST_NAMESPACE_ = "pydio.rest."
SERVICE_GATEWAY_NAMESPACE_ = "pydio.gateway."
SERVICE_TEST_NAMESPACE_ = "pydio.test."
SERVICE_GATEWAY_PROXY = SERVICE_GATEWAY_NAMESPACE_ + "proxy"
SERVICE_GATEWAY_DATA = SERVICE_GATEWAY_NAMESPACE_ + "data"
SERVICE_GATEWAY_GRPC = SERVICE_GATEWAY_NAMESPACE_ + "grpc"
SERVICE_GATEWAY_DAV = SERVICE_GATEWAY_NAMESPACE_ + "dav"
SERVICE_GATEWAY_WOPI = SERVICE_GATEWAY_NAMESPACE_ + "wopi"
SERVICE_MICRO_API = SERVICE_GATEWAY_NAMESPACE_ + "rest"
)
// Define constants for Event Bus Topics
const (
TOPIC_PROXY_RESTART = "topic.pydio.proxy.restart"
TOPIC_SERVICE_START = "topic.pydio.service.start"
TOPIC_SERVICE_STOP = "topic.pydio.service.stop"
TOPIC_SERVICE_STARTED = "topic.pydio.service.started"
TOPIC_SERVICE_STOPPED = "topic.pydio.service.stopped"
TOPIC_INDEX_CHANGES = "topic.pydio.index.nodes.changes"
TOPIC_TREE_CHANGES = "topic.pydio.tree.nodes.changes"
TOPIC_META_CHANGES = "topic.pydio.meta.nodes.changes"
TOPIC_TIMER_EVENT = "topic.pydio.meta.timer.event"
TOPIC_JOB_CONFIG_EVENT = "topic.pydio.jobconfig.event"
TOPIC_JOB_TASK_EVENT = "topic.pydio.jobconfig.event"
TOPIC_IDM_EVENT = "topic.pydio.idm.event"
TOPIC_ACTIVITY_EVENT = "topic.pydio.activity.event"
TOPIC_CHAT_EVENT = "topic.pydio.chat.event"
TOPIC_DATASOURCE_EVENT = "topic.pydio.datasource.event"
TOPIC_INDEX_EVENT = "topic.pydio.index.event"
)
// Define constants for metadata and fixed datasources
const (
META_NAMESPACE_DATASOURCE_NAME = "pydio:meta-data-source-name"
META_NAMESPACE_DATASOURCE_PATH = "pydio:meta-data-source-path"
META_NAMESPACE_NODE_TEST_LOCAL_FOLDER = "pydio:test:local-folder-storage"
META_NAMESPACE_RECYCLE_RESTORE = "pydio:recycle_restore"
META_NAMESPACE_NODENAME = "name"
RECYCLE_BIN_NAME = "recycle_bin"
PYDIO_THUMBSTORE_NAMESPACE = "pydio-thumbstore"
PYDIO_DOCSTORE_BINARIES_NAMESPACE = "pydio-binaries"
PYDIO_VERSIONS_NAMESPACE = "versions-store"
)
// Additional constants for authentication/authorization aspects
const (
PYDIO_CONTEXT_USER_KEY = "X-Pydio-User"
PYDIO_SYSTEM_USERNAME = "pydio.system.user"
PYDIO_S3ANON_USERNAME = "pydio.anon.user"
PYDIO_S3ANON_PROFILE = "anon"
PYDIO_SYNC_HIDDEN_FILE_META = ".pydio"
X_AMZ_META_CLEAR_SIZE = "X-Amz-Meta-Pydio-Clear-Size"
X_AMZ_META_CLEAR_SIZE_UNKOWN = "unknown"
X_AMZ_META_NODE_UUID = "X-Amz-Meta-Pydio-Node-Uuid"
X_AMZ_META_CONTENT_MD5 = "X-Amz-Meta-Content-Md5"
X_AMZ_META_DIRECTIVE = "X-Amz-Metadata-Directive"
XPydioClientUuid = "X-Pydio-Client-Uuid"
XPydioSessionUuid = "X-Pydio-Session"
XPydioIndexationSessionUuid = "X-Pydio-Indexation-Session"
XPydioMoveUuid = "X-Pydio-Move"
SyncSessionClose_ = "close-"
SyncSessionPrefixCopy = "copy-"
SyncSessionPrefixMove = "move-"
PYDIO_PROFILE_ADMIN = "admin"
PYDIO_PROFILE_STANDARD = "standard"
PYDIO_PROFILE_SHARED = "shared"
PYDIO_PROFILE_ANON = "anon"
KEYRING_MASTER_KEY = "keyring.master"
META_FLAG_READONLY = "node_readonly"
META_FLAG_LEVEL_READONLY = "level_readonly"
META_FLAG_ENCRYPTED = "datasource_encrypted"
META_FLAG_VERSIONING = "datasource_versioning"
META_FLAG_WORKSPACE_ROOT = "ws_root"
META_FLAG_WORKSPACE_SCOPE = "ws_scope"
META_FLAG_WORKSPACE_SYNCABLE = "ws_syncable"
META_FLAG_WORKSPACE_PERMISSIONS = "ws_permissions"
META_FLAG_WORKSPACE_LABEL = "ws_label"
META_FLAG_WORKSPACE_DESCRIPTION = "ws_description"
META_FLAG_WORKSPACE_SLUG = "ws_slug"
META_FLAG_WORKSPACE_UUID = "ws_uuid"
META_FLAG_VIRTUAL_ROOT = "virtual_root"
META_FLAG_BUCKET = "ds_bucket"
NODE_FLAG_ETAG_TEMPORARY = "temporary"
)
var (
XSpecialPydioHeaders = []string{
XPydioClientUuid,
XPydioSessionUuid,
XPydioIndexationSessionUuid,
XPydioMoveUuid,
}
)
// DocStore constants for StoreID's
const (
DOCSTORE_ID_SELECTIONS = "selections"
DOCSTORE_ID_VIRTUALNODES = "virtualnodes"
DOCSTORE_ID_VERSIONING_POLICIES = "versioningPolicies"
DOCSTORE_ID_SHARES = "share"
DOCSTORE_ID_RESET_PASS_KEYS = "resetPasswordKeys"
)
// Define constants for Loggging configuration
const (
LogConfigConsole LogConfigType = "console"
LogConfigProduction LogConfigType = "production"
)
// Defaults for DB connexions.
const (
DB_NUM_RESERVED_CONNECTIONS = 10
DB_MAX_OPEN_CONNS = 20
DB_MAX_IDLE_CONNS = 20
DB_CONN_MAX_LIFETIME = 24 * time.Hour
)
// Main code information. Set by the go linker in the resulting binary when doing 'make main'
var (
BuildStamp string
BuildRevision string
version = "0.1.0"
)
// Package info. Initialised by main.
var (
PackageType string
PackageLabel string
)
// Update Server default values.
var (
UpdateDefaultChannel = "stable"
UpdateDefaultServerUrl = "https://updatecells.pydio.com/"
UpdateDefaultPublicKey = `-----BEGIN PUBLIC KEY-----\nMIIBCgKCAQEAwh/ofjZTITlQc4h/qDZMR3RquBxlG7UTunDKLG85JQwRtU7EL90v\nlWxamkpSQsaPeqho5Q6OGkhJvZkbWsLBJv6LZg+SBhk6ZSPxihD+Kfx8AwCcWZ46\nDTpKpw+mYnkNH1YEAedaSfJM8d1fyU1YZ+WM3P/j1wTnUGRgebK9y70dqZEo2dOK\nn98v3kBP7uEN9eP/wig63RdmChjCpPb5gK1/WKnY4NFLQ60rPAOBsXurxikc9N/3\nEvbIB/1vQNqm7yEwXk8LlOC6Fp8W/6A0DIxr2BnZAJntMuH2ulUfhJgw0yJalMNF\nDR0QNzGVktdLOEeSe8BSrASe9uZY2SDbTwIDAQAB\n-----END PUBLIC KEY-----`
)
// Logging Levels.
var (
LogConfig LogConfigType
LogLevel zapcore.Level
LogCaptureStdOut bool
)
var (
// PydioUserProfiles order reflects the level of authorizations
PydioUserProfiles = []string{
PYDIO_PROFILE_ANON,
PYDIO_PROFILE_SHARED,
PYDIO_PROFILE_STANDARD,
PYDIO_PROFILE_ADMIN,
}
)
// Version returns the current code version as an object.
func Version() *hashiversion.Version {
v, _ := hashiversion.NewVersion(version)
return v
}