/
defs.go
259 lines (245 loc) · 7.63 KB
/
defs.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
package cblib
import (
"github.com/clearblade/cblib/internal/types"
)
//
// These are variables that can be used as
// flags to a main package using this library, or
// they can be set directly by unit tests, etc.
// My, there are a lot of these...
//
const (
NotExistErrorString = "Does not exist"
SpecialNoCBMetaError = "No cbmeta file"
ExportItemIdDefault = true
SortCollectionsDefault = false
DataPageSizeDefault = 100
)
var DefaultCollectionColumns = []string{"item_id"}
var (
URL string
MsgURL string
SystemKey string
DevToken string
ShouldImportCollectionRows bool
ImportRows bool
ExportRows bool
ExportItemId bool
ImportUsers bool
ExportUsers bool
CleanUp bool
EdgeSchema bool
DeviceSchema bool
UserSchema bool
DataPageSize int
MaxRetries int
Email string
Password string
CollectionSchema string
ServiceName string
LibraryName string
CollectionName string
CollectionId string
SortCollections bool
User string
UserId string
RoleName string
TriggerName string
TimerName string
DeviceName string
EdgeName string
PortalName string
PluginName string
AdaptorName string
DeploymentName string
ServiceCacheName string
WebhookName string
ExternalDatabaseName string
BucketSetName string
BucketSetFiles string
BucketSetBoxName string
BucketSetFileName string
SecretName string
Message bool
Topic string
Payload string
Help bool
Params string
Push bool
AllServices bool
AllLibraries bool
AllDevices bool
AllEdges bool
AllPortals bool
AllPlugins bool
AllAdaptors bool
AllDeployments bool
AllCollections bool
AllRoles bool
AllUsers bool
AllAssets bool
AllTriggers bool
AllTimers bool
AllServiceCaches bool
AllWebhooks bool
AllExternalDatabases bool
AllBucketSets bool
AllBucketSetFiles bool
AllSecrets bool
MessageHistoryStorage bool
MessageTypeTriggers bool
AutoApprove bool
TempDir string
SkipUpdateMapNameToIdFiles bool
)
var (
systemDotJSON map[string]interface{}
libCode map[string]interface{}
svcCode map[string]interface{}
MetaInfo map[string]interface{}
)
type AffectedAssets struct {
AllAssets bool
AllServices bool
AllLibraries bool
AllEdges bool
AllDevices bool
AllPortals bool
AllPlugins bool
AllAdaptors bool
AllDeployments bool
AllCollections bool
AllRoles bool
AllUsers bool
AllTriggers bool
AllTimers bool
AllServiceCaches bool
AllWebhooks bool
AllExternalDatabases bool
AllBucketSets bool
AllSecrets bool
MessageTypeTriggers bool
DeviceSchema bool
UserSchema bool
EdgeSchema bool
MessageHistoryStorage bool
CollectionSchema string
ServiceName string
LibraryName string
CollectionName string
User string
RoleName string
TriggerName string
TimerName string
EdgeName string
DeviceName string
PortalName string
PluginName string
AdaptorName string
DeploymentName string
ServiceCacheName string
WebhookName string
ExternalDatabaseName string
BucketSetName string
BucketSetFiles string
AllBucketSetFiles bool
BucketSetBoxName string
BucketSetFileName string
SecretName string
ExportUsers bool
ExportRows bool
ExportItemId bool
}
func createAffectedAssets() AffectedAssets {
return AffectedAssets{
AllAssets: AllAssets,
AllServices: AllServices,
AllLibraries: AllLibraries,
AllEdges: AllEdges,
AllDevices: AllDevices,
AllPortals: AllPortals,
AllPlugins: AllPlugins,
AllAdaptors: AllAdaptors,
AllDeployments: AllDeployments,
AllCollections: AllCollections,
AllRoles: AllRoles,
AllUsers: AllUsers,
AllServiceCaches: AllServiceCaches,
AllWebhooks: AllWebhooks,
AllExternalDatabases: AllExternalDatabases,
UserSchema: UserSchema,
DeviceSchema: DeviceSchema,
EdgeSchema: EdgeSchema,
AllTriggers: AllTriggers,
AllTimers: AllTimers,
AllBucketSets: AllBucketSets,
AllSecrets: AllSecrets,
CollectionSchema: CollectionSchema,
ServiceName: ServiceName,
LibraryName: LibraryName,
CollectionName: CollectionName,
User: User,
RoleName: RoleName,
TriggerName: TriggerName,
TimerName: TimerName,
EdgeName: EdgeName,
DeviceName: DeviceName,
PortalName: PortalName,
PluginName: PluginName,
AdaptorName: AdaptorName,
DeploymentName: DeploymentName,
ServiceCacheName: ServiceCacheName,
WebhookName: WebhookName,
ExternalDatabaseName: ExternalDatabaseName,
BucketSetName: BucketSetName,
SecretName: SecretName,
ExportUsers: ExportUsers,
ExportRows: ExportRows,
ExportItemId: ExportItemId,
BucketSetFiles: BucketSetFiles,
AllBucketSetFiles: AllBucketSetFiles,
BucketSetBoxName: BucketSetBoxName,
BucketSetFileName: BucketSetFileName,
MessageHistoryStorage: MessageHistoryStorage,
MessageTypeTriggers: MessageTypeTriggers,
}
}
type Role_meta struct {
Name string
Description string
Permission []map[string]interface{}
}
type Column struct {
ColumnName string
ColumnType string
}
type Collection_meta struct {
Name string
Collection_id string
Columns []Column
}
type User_meta struct {
Columns []Column
}
func systemMetaToMap(meta *types.System_meta) map[string]interface{} {
result := make(map[string]interface{})
result["platform_url"] = meta.PlatformUrl
result["messaging_url"] = meta.MessageUrl
result["system_key"] = meta.Key
result["system_secret"] = meta.Secret
result["name"] = meta.Name
result["description"] = meta.Description
result["auth"] = true
return result
}
func systemMetaFromMap(theMap map[string]interface{}) *types.System_meta {
return &types.System_meta{
Name: theMap["name"].(string),
Key: theMap["system_key"].(string),
Secret: theMap["system_secret"].(string),
Description: theMap["description"].(string),
PlatformUrl: theMap["platform_url"].(string),
MessageUrl: theMap["messaging_url"].(string),
Services: map[string]types.Service_meta{},
}
}