@@ -254,12 +254,12 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
254254 }
255255
256256 var tenants []* models.TenantList
257- var totalSize int64
258257
259- for _ , minInst := range minTenants .Items {
258+ for _ , tenant := range minTenants .Items {
259+ var totalSize int64
260260 var instanceCount int64
261261 var volumeCount int64
262- for _ , zone := range minInst .Spec .Zones {
262+ for _ , zone := range tenant .Spec .Zones {
263263 instanceCount = instanceCount + int64 (zone .Servers )
264264 volumeCount = volumeCount + int64 (zone .Servers * zone .VolumesPerServer )
265265 if zone .VolumeClaimTemplate != nil {
@@ -269,20 +269,20 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
269269 }
270270
271271 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 )),
275275 InstanceCount : instanceCount ,
276276 VolumeCount : volumeCount ,
277- CurrentState : minInst .Status .CurrentState ,
278- Namespace : minInst .ObjectMeta .Namespace ,
277+ CurrentState : tenant .Status .CurrentState ,
278+ Namespace : tenant .ObjectMeta .Namespace ,
279279 TotalSize : totalSize ,
280280 })
281281 }
282282
283283 return & models.ListTenantsResponse {
284284 Tenants : tenants ,
285- Total : 0 ,
285+ Total : int64 ( len ( tenants )) ,
286286 }, nil
287287}
288288
@@ -332,6 +332,13 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
332332 }
333333 minioImage = * minImg
334334 }
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
335342
336343 // if access/secret are provided, use them, else create a random pair
337344 accessKey := RandomCharString (16 )
@@ -355,11 +362,6 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
355362 },
356363 }
357364
358- clientset , err := cluster .K8sClient (session .SessionToken )
359- if err != nil {
360- return nil , err
361- }
362- ns := * params .Body .Namespace
363365 _ , err = clientset .CoreV1 ().Secrets (ns ).Create (context .Background (), & instanceSecret , metav1.CreateOptions {})
364366 if err != nil {
365367 return nil , err
@@ -389,10 +391,13 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
389391 },
390392 }
391393 // optionals are set below
392-
394+ var consoleAccess string
395+ var consoleSecret string
393396 if enableConsole {
394397 consoleSelector := fmt .Sprintf ("%s-console" , * params .Body .Name )
395398 consoleSecretName := fmt .Sprintf ("%s-secret" , consoleSelector )
399+ consoleAccess = RandomCharString (16 )
400+ consoleSecret = RandomCharString (32 )
396401 imm := true
397402 instanceSecret := corev1.Secret {
398403 ObjectMeta : metav1.ObjectMeta {
@@ -403,8 +408,8 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
403408 "CONSOLE_HMAC_JWT_SECRET" : []byte (RandomCharString (16 )),
404409 "CONSOLE_PBKDF_PASSPHRASE" : []byte (RandomCharString (16 )),
405410 "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 ),
408413 },
409414 }
410415 _ , err = clientset .CoreV1 ().Secrets (ns ).Create (context .Background (), & instanceSecret , metav1.CreateOptions {})
@@ -462,11 +467,16 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
462467 return nil , err
463468 }
464469 }
465-
466- return & models.CreateTenantResponse {
470+ response := & models.CreateTenantResponse {
467471 AccessKey : accessKey ,
468472 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
470480}
471481
472482// updateTenantAction does an update on the minioTenant by patching the desired changes
0 commit comments