-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathoptions.go
More file actions
376 lines (334 loc) · 12.1 KB
/
options.go
File metadata and controls
376 lines (334 loc) · 12.1 KB
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
// Package options xxx
package options
import (
"github.com/Tencent/bk-bcs/bcs-common/common/conf"
"github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint
cmproto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager"
)
// EtcdOption option for etcd
type EtcdOption struct {
EtcdEndpoints string `json:"endpoints" value:"" usage:"endpoints of etcd"`
EtcdCert string `json:"cert" value:"" usage:"cert file of etcd"`
EtcdKey string `json:"key" value:"" usage:"key file for etcd"`
EtcdCa string `json:"ca" value:"" usage:"ca file for etcd"`
}
// LogConfig option for log
type LogConfig struct {
LogDir string `json:"dir"`
LogMaxSize uint64 `json:"maxsize"`
LogMaxNum int `json:"maxnum"`
ToStdErr bool `json:"tostderr"`
AlsoToStdErr bool `json:"alsotostderr"`
Verbosity int32 `json:"v"`
StdErrThreshold string `json:"stderrthreshold"`
VModule string `json:"vmodule"`
TraceLocation string `json:"backtraceat"`
}
// SwaggerConfig option for swagger
type SwaggerConfig struct {
Dir string `json:"dir"`
}
// ServerConfig option for server
type ServerConfig struct {
Address string `json:"address"`
Ipv6Address string `json:"ipv6Address"`
InsecureAddress string `json:"insecureaddress"`
Port uint `json:"port"`
HTTPPort uint `json:"httpport"`
MetricPort uint `json:"metricport"`
ServerCert string `json:"servercert"`
ServerKey string `json:"serverkey"`
ServerCa string `json:"serverca"`
}
// ClientConfig option for bcs-cluster-manager as client
type ClientConfig struct {
ClientCert string `json:"clientcert"`
ClientKey string `json:"clientkey"`
ClientCa string `json:"clientca"`
}
// TunnelConfig option for tunnel
type TunnelConfig struct {
PeerToken string `json:"peertoken"`
}
// MongoConfig option for mongo
type MongoConfig struct {
Address string `json:"address"`
Replicaset string `json:"replicaset"`
ConnectTimeout uint `json:"connecttimeout"`
Database string `json:"database"`
Username string `json:"username"`
Password string `json:"password"`
MaxPoolSize uint `json:"maxpoolsize"`
MinPoolSize uint `json:"minpoolsize"`
}
// BrokerConfig option for dispatch task broker
type BrokerConfig struct {
QueueAddress string `json:"address"`
Exchange string `json:"exchange"`
}
// BKOpsConfig for call bkops job
type BKOpsConfig struct {
EsbServer string `json:"esbServer"`
Server string `json:"server"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
Debug bool `json:"debug"`
TemplateURL string `json:"templateURL"`
FrontURL string `json:"frontURL"`
}
// CmdbConfig for bkcc cmdb
type CmdbConfig struct {
Enable bool `json:"enable"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
Server string `json:"server"`
Debug bool `json:"debug"`
}
// TenCmdbConfig for tencent cmdb
type TenCmdbConfig struct {
Enable bool `json:"enable"`
AppId string `json:"appId"`
AppKey string `json:"appKey"`
Server string `json:"server"`
Debug bool `json:"debug"`
}
// NodeManConfig for nodeman
type NodeManConfig struct {
Enable bool `json:"enable"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
Server string `json:"server"`
Debug bool `json:"debug"`
}
// ResourceManagerConfig init resource_module
type ResourceManagerConfig struct {
Enable bool `json:"enable"`
Module string `json:"module"`
}
// ProjectManagerConfig init project_module
type ProjectManagerConfig struct {
Enable bool `json:"enable"`
Module string `json:"module"`
}
// CidrManagerConfig init cidr_module
type CidrManagerConfig struct {
Enable bool `json:"enable"`
TLS bool `json:"tls"`
Module string `json:"module"`
}
// AccessConfig for auth
type AccessConfig struct {
Server string `json:"server"`
Debug bool `json:"debug"`
}
// PassConfig pass-cc config
type PassConfig struct {
Server string `json:"server"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
Enable bool `json:"enable"`
Debug bool `json:"debug"`
}
// UserConfig userManager config
type UserConfig struct {
Enable bool `json:"enable"`
GateWay string `json:"gateWay"`
IsVerifyTLS bool `json:"isVerifyTLS"`
Token string `json:"token"`
}
// StorageConfig storage config
type StorageConfig struct {
Host string `json:"host"`
Token string `json:"token"`
Debug bool `json:"debug"`
}
// AlarmConfig for alarm interface
type AlarmConfig struct {
Server string `json:"server"`
MonitorServer string `json:"monitorServer"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
Enable bool `json:"enable"`
Debug bool `json:"debug"`
}
// IAMConfig for perm interface
type IAMConfig struct {
SystemID string `json:"systemID"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
External bool `json:"external"`
GatewayServer string `json:"gateWayServer"`
IAMServer string `json:"iamServer"`
BkiIAMServer string `json:"bkiIamServer"`
Metric bool `json:"metric"`
Debug bool `json:"debug"`
ApplyPermAddress string `json:"applyPermAddress"`
}
// HelmConfig for helm
type HelmConfig struct {
Enable bool `json:"enable"`
// GateWay address
GateWay string `json:"gateWay"`
Token string `json:"token"`
Module string `json:"module"`
}
// AutoScaler Config for autoscaler
type AutoScaler struct {
ChartName string `json:"chartName"`
ReleaseName string `json:"releaseName"`
ReleaseNamespace string `json:"releaseNamespace"`
IsPublicRepo bool `json:"isPublicRepo"`
CaImageRegistry string `json:"caImageRegistry"`
}
// BcsWatch config
type BcsWatch struct {
ChartName string `json:"chartName"`
ReleaseName string `json:"releaseName"`
ReleaseNamespace string `json:"releaseNamespace"`
IsPublicRepo bool `json:"isPublicRepo"`
StorageServer string `json:"storageServer"`
}
// VirtualCluster config
type VirtualCluster struct {
HttpServer string `json:"httpServer"`
WsServer string `json:"wsServer"`
DebugWsServer string `json:"debugWsServer"`
ChartName string `json:"chartName"`
ReleaseName string `json:"releaseName"`
IsPublicRepo bool `json:"isPublicRepo"`
}
// AddonData addon data
type AddonData struct {
AddonName string `json:"addonName"`
}
// ComponentDeploy config
type ComponentDeploy struct {
AutoScaler AutoScaler `json:"autoScaler"`
Watch BcsWatch `json:"watch"`
Vcluster VirtualCluster `json:"vcluster"`
ImagePullSecret AddonData `json:"imagePullSecret"`
Registry string `json:"registry"`
BCSAPIGateway string `json:"bcsApiGateway"`
Token string `json:"token"`
BcsClusterUrl string `json:"bcsClusterUrl"`
}
// AuthConfig config for auth
type AuthConfig struct {
Enable bool `json:"enable"`
// jwt key
PublicKeyFile string `json:"publicKeyFile"`
PrivateKeyFile string `json:"privateKeyFile"`
// client 类型用户权限,使用 json 格式,key 为 client 名称,values 为拥有的权限,'*' 表示所有
// 如:`{"admin": ["*"], "client_a": ["ClusterManager.CreateCluster"]}`
ClientPermissions string `json:"clientPermissions"`
// 不鉴权接口,使用逗号分隔,格式 `ClusterManager.Health,ClusterManager.Health`
NoAuthMethod string `json:"noAuthMethod"`
}
// GseConfig for gse
type GseConfig struct {
Enable bool `json:"enable"`
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
EsbServer string `json:"server"`
GatewayServer string `json:"gatewayServer"`
Debug bool `json:"debug"`
}
// JobConfig for job
type JobConfig struct {
AppCode string `json:"appCode"`
AppSecret string `json:"appSecret"`
BkUserName string `json:"bkUserName"`
Server string `json:"server"`
Debug bool `json:"debug"`
JobTaskLink string `json:"jobTaskLink"`
}
// DaemonConfig for daemon
type DaemonConfig struct {
Enable bool `json:"enable"`
EnableInsTypeUsage bool `json:"enableInsTypeUsage"`
EnableAllocateCidr bool `json:"enableAllocateCidr"`
EnableAzureTaint bool `json:"enableAzureTaint"`
}
// CommonConfig for platform common config
type CommonConfig struct {
AnnoKeyProjCode string `json:"annoKeyProjCode"`
SystemNameSpaces string `json:"systemNameSpaces"`
}
// ClusterManagerOptions options of cluster manager
type ClusterManagerOptions struct {
Etcd EtcdOption `json:"etcd"`
Swagger SwaggerConfig `json:"swagger"`
Tunnel TunnelConfig `json:"tunnel"`
BcsLog LogConfig `json:"bcslog"`
Mongo MongoConfig `json:"mongo"`
Broker BrokerConfig `json:"broker"`
BKOps BKOpsConfig `json:"bkOps"`
StorageManager StorageConfig `json:"storage"`
Cmdb CmdbConfig `json:"cmdb"`
TenCmdb TenCmdbConfig `json:"tenCmdb"`
NodeMan NodeManConfig `json:"nodeman"`
ResourceManager ResourceManagerConfig `json:"resource"`
ProjectManager ProjectManagerConfig `json:"project"`
CidrManager CidrManagerConfig `json:"cidr"`
CloudTemplatePath string `json:"cloudTemplatePath"`
Access AccessConfig `json:"access"`
Passcc PassConfig `json:"passcc"`
UserManager UserConfig `json:"user"`
Alarm AlarmConfig `json:"alarm"`
IAM IAMConfig `json:"iam_config"`
Auth AuthConfig `json:"auth"`
Gse GseConfig `json:"gse"`
Job JobConfig `json:"job"`
Debug bool `json:"debug"`
Version BCSEdition `json:"version"`
Helm HelmConfig `json:"helm"`
ComponentDeploy ComponentDeploy `json:"componentDeploy"`
ResourceSchemaPath string `json:"resourceSchemaPath"`
TagDepart string `json:"tagDepart"`
PrefixVcluster string `json:"prefixVcluster"`
TracingConfig conf.TracingConfig `json:"tracingConfig"`
Encrypt encryptv2.Config `json:"encrypt"`
Daemon DaemonConfig `json:"daemon"`
CommonConfig CommonConfig `json:"commonConfig"`
ServerConfig
ClientConfig
}
var globalClusterManagerOption *ClusterManagerOptions
// SetGlobalCMOptions set global CM options
func SetGlobalCMOptions(opts *ClusterManagerOptions) {
if globalClusterManagerOption != nil {
return
}
globalClusterManagerOption = opts
}
// GetGlobalCMOptions get global CM options
func GetGlobalCMOptions() *ClusterManagerOptions {
return globalClusterManagerOption
}
// GetEditionInfo get edition
func GetEditionInfo() BCSEdition {
if globalClusterManagerOption.Version == "" {
globalClusterManagerOption.Version = InnerEdition
}
return globalClusterManagerOption.Version
}
// CloudTemplateList cloud template init config
type CloudTemplateList struct {
CloudList []*cmproto.Cloud `json:"cloudList"`
}