@@ -254,12 +254,12 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
254
254
}
255
255
256
256
var tenants []* models.TenantList
257
- var totalSize int64
258
257
259
- for _ , minInst := range minTenants .Items {
258
+ for _ , tenant := range minTenants .Items {
259
+ var totalSize int64
260
260
var instanceCount int64
261
261
var volumeCount int64
262
- for _ , zone := range minInst .Spec .Zones {
262
+ for _ , zone := range tenant .Spec .Zones {
263
263
instanceCount = instanceCount + int64 (zone .Servers )
264
264
volumeCount = volumeCount + int64 (zone .Servers * zone .VolumesPerServer )
265
265
if zone .VolumeClaimTemplate != nil {
@@ -269,20 +269,20 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
269
269
}
270
270
271
271
tenants = append (tenants , & models.TenantList {
272
- CreationDate : minInst .ObjectMeta .CreationTimestamp .String (),
273
- Name : minInst .ObjectMeta .Name ,
274
- ZoneCount : int64 (len (minInst .Spec .Zones )),
272
+ CreationDate : tenant .ObjectMeta .CreationTimestamp .String (),
273
+ Name : tenant .ObjectMeta .Name ,
274
+ ZoneCount : int64 (len (tenant .Spec .Zones )),
275
275
InstanceCount : instanceCount ,
276
276
VolumeCount : volumeCount ,
277
- CurrentState : minInst .Status .CurrentState ,
278
- Namespace : minInst .ObjectMeta .Namespace ,
277
+ CurrentState : tenant .Status .CurrentState ,
278
+ Namespace : tenant .ObjectMeta .Namespace ,
279
279
TotalSize : totalSize ,
280
280
})
281
281
}
282
282
283
283
return & models.ListTenantsResponse {
284
284
Tenants : tenants ,
285
- Total : 0 ,
285
+ Total : int64 ( len ( tenants )) ,
286
286
}, nil
287
287
}
288
288
@@ -332,6 +332,13 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
332
332
}
333
333
minioImage = * minImg
334
334
}
335
+ // get Kubernetes Client
336
+ clientset , err := cluster .K8sClient (session .SessionToken )
337
+ if err != nil {
338
+ return nil , err
339
+ }
340
+
341
+ ns := * params .Body .Namespace
335
342
336
343
// if access/secret are provided, use them, else create a random pair
337
344
accessKey := RandomCharString (16 )
@@ -355,11 +362,6 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
355
362
},
356
363
}
357
364
358
- clientset , err := cluster .K8sClient (session .SessionToken )
359
- if err != nil {
360
- return nil , err
361
- }
362
- ns := * params .Body .Namespace
363
365
_ , err = clientset .CoreV1 ().Secrets (ns ).Create (context .Background (), & instanceSecret , metav1.CreateOptions {})
364
366
if err != nil {
365
367
return nil , err
@@ -389,10 +391,13 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
389
391
},
390
392
}
391
393
// optionals are set below
392
-
394
+ var consoleAccess string
395
+ var consoleSecret string
393
396
if enableConsole {
394
397
consoleSelector := fmt .Sprintf ("%s-console" , * params .Body .Name )
395
398
consoleSecretName := fmt .Sprintf ("%s-secret" , consoleSelector )
399
+ consoleAccess = RandomCharString (16 )
400
+ consoleSecret = RandomCharString (32 )
396
401
imm := true
397
402
instanceSecret := corev1.Secret {
398
403
ObjectMeta : metav1.ObjectMeta {
@@ -403,8 +408,8 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
403
408
"CONSOLE_HMAC_JWT_SECRET" : []byte (RandomCharString (16 )),
404
409
"CONSOLE_PBKDF_PASSPHRASE" : []byte (RandomCharString (16 )),
405
410
"CONSOLE_PBKDF_SALT" : []byte (RandomCharString (8 )),
406
- "CONSOLE_ACCESS_KEY" : []byte (RandomCharString ( 16 ) ),
407
- "CONSOLE_SECRET_KEY" : []byte (RandomCharString ( 32 ) ),
411
+ "CONSOLE_ACCESS_KEY" : []byte (consoleAccess ),
412
+ "CONSOLE_SECRET_KEY" : []byte (consoleSecret ),
408
413
},
409
414
}
410
415
_ , err = clientset .CoreV1 ().Secrets (ns ).Create (context .Background (), & instanceSecret , metav1.CreateOptions {})
@@ -462,11 +467,16 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
462
467
return nil , err
463
468
}
464
469
}
465
-
466
- return & models.CreateTenantResponse {
470
+ response := & models.CreateTenantResponse {
467
471
AccessKey : accessKey ,
468
472
SecretKey : secretKey ,
469
- }, nil
473
+ }
474
+ // Attach Console Credentials
475
+ if enableConsole {
476
+ response .Console .AccessKey = consoleAccess
477
+ response .Console .SecretKey = consoleSecret
478
+ }
479
+ return response , nil
470
480
}
471
481
472
482
// updateTenantAction does an update on the minioTenant by patching the desired changes
0 commit comments