@@ -28,6 +28,7 @@ use ainari_common::enums;
2828table ! {
2929 meta_clusters ( uuid) {
3030 uuid -> Varchar ,
31+ name -> Varchar ,
3132 sakura_host_uuid -> Varchar ,
3233 proxy_uuid -> Varchar ,
3334 owner_id -> Varchar ,
@@ -46,6 +47,7 @@ table! {
4647#[ diesel( table_name = meta_clusters) ]
4748pub struct MetaClusterEntry {
4849 pub uuid : String ,
50+ pub name : String ,
4951 pub sakura_host_uuid : String ,
5052 pub proxy_uuid : String ,
5153 pub owner_id : String ,
@@ -64,6 +66,7 @@ pub fn init_meta_cluster_table() -> Result<(), Box<dyn Error>> {
6466 conn. batch_execute (
6567 "CREATE TABLE IF NOT EXISTS meta_clusters (
6668 uuid VARCHAR(40) PRIMARY KEY,
69+ name VARCHAR(256),
6770 sakura_host_uuid VARCHAR(40),
6871 proxy_uuid VARCHAR(40),
6972 owner_id VARCHAR(256),
@@ -83,12 +86,14 @@ pub fn init_meta_cluster_table() -> Result<(), Box<dyn Error>> {
8386
8487pub fn add_new_meta_cluster (
8588 meta_cluster_uuid : & Uuid ,
89+ cluster_name : & str ,
8690 sakura_host_uuid : & Uuid ,
8791 proxy_uuid : & Uuid ,
8892 context : & UserContext ,
8993) -> QueryResult < usize > {
9094 let meta_cluster = MetaClusterEntry {
9195 uuid : meta_cluster_uuid. to_string ( ) . clone ( ) ,
96+ name : cluster_name. to_string ( ) . clone ( ) ,
9297 sakura_host_uuid : sakura_host_uuid. to_string ( ) . clone ( ) ,
9398 proxy_uuid : proxy_uuid. to_string ( ) . clone ( ) ,
9499 owner_id : context. user_id . clone ( ) ,
@@ -259,6 +264,7 @@ mod tests {
259264 fn test_add_get_meta_cluster ( ) {
260265 let _ = init_meta_cluster_table ( ) ;
261266 let uuid1 = Uuid :: new_v4 ( ) ;
267+ let name = "test-cluster" . to_string ( ) ;
262268 let sakura_host_uuid1 = Uuid :: new_v4 ( ) ;
263269 let proxy_uuid1 = Uuid :: new_v4 ( ) ;
264270
@@ -274,6 +280,7 @@ mod tests {
274280
275281 let meta_cluster = MetaClusterEntry {
276282 uuid : uuid1. to_string ( ) ,
283+ name : name. clone ( ) ,
277284 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
278285 proxy_uuid : proxy_uuid1. to_string ( ) ,
279286 owner_id : owner_id. clone ( ) ,
@@ -320,6 +327,7 @@ mod tests {
320327 let _ = init_meta_cluster_table ( ) ;
321328 let uuid1 = Uuid :: new_v4 ( ) ;
322329 let uuid2 = Uuid :: new_v4 ( ) ;
330+ let name = "test-cluster" . to_string ( ) ;
323331 let sakura_host_uuid1 = Uuid :: new_v4 ( ) ;
324332 let proxy_uuid1 = Uuid :: new_v4 ( ) ;
325333
@@ -335,6 +343,7 @@ mod tests {
335343
336344 let meta_cluster1 = MetaClusterEntry {
337345 uuid : uuid1. to_string ( ) ,
346+ name : name. clone ( ) ,
338347 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
339348 proxy_uuid : proxy_uuid1. to_string ( ) ,
340349 owner_id : owner_id. clone ( ) ,
@@ -350,6 +359,7 @@ mod tests {
350359
351360 let meta_cluster2 = MetaClusterEntry {
352361 uuid : uuid2. to_string ( ) ,
362+ name : name. clone ( ) ,
353363 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
354364 proxy_uuid : proxy_uuid1. to_string ( ) ,
355365 owner_id : owner_id. clone ( ) ,
@@ -379,6 +389,7 @@ mod tests {
379389 fn test_delete_meta_cluster ( ) {
380390 let _ = init_meta_cluster_table ( ) ;
381391 let uuid1 = Uuid :: new_v4 ( ) ;
392+ let name = "test-cluster" . to_string ( ) ;
382393 let sakura_host_uuid1 = Uuid :: new_v4 ( ) ;
383394 let proxy_uuid1 = Uuid :: new_v4 ( ) ;
384395
@@ -394,6 +405,7 @@ mod tests {
394405
395406 let meta_cluster = MetaClusterEntry {
396407 uuid : uuid1. to_string ( ) ,
408+ name : name. clone ( ) ,
397409 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
398410 proxy_uuid : proxy_uuid1. to_string ( ) ,
399411 owner_id : owner_id. clone ( ) ,
@@ -422,6 +434,7 @@ mod tests {
422434 let uuid1 = Uuid :: new_v4 ( ) ;
423435 let uuid2 = Uuid :: new_v4 ( ) ;
424436 let uuid3 = Uuid :: new_v4 ( ) ;
437+ let name = "test-cluster" . to_string ( ) ;
425438 let sakura_host_uuid1 = Uuid :: new_v4 ( ) ;
426439 let proxy_uuid1 = Uuid :: new_v4 ( ) ;
427440
@@ -437,6 +450,7 @@ mod tests {
437450
438451 let meta_cluster1 = MetaClusterEntry {
439452 uuid : uuid1. to_string ( ) ,
453+ name : name. clone ( ) ,
440454 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
441455 proxy_uuid : proxy_uuid1. to_string ( ) ,
442456 owner_id : owner_id. clone ( ) ,
@@ -452,6 +466,7 @@ mod tests {
452466
453467 let meta_cluster2 = MetaClusterEntry {
454468 uuid : uuid2. to_string ( ) ,
469+ name : name. clone ( ) ,
455470 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
456471 proxy_uuid : proxy_uuid1. to_string ( ) ,
457472 owner_id : owner_id. clone ( ) ,
@@ -467,6 +482,7 @@ mod tests {
467482
468483 let meta_cluster3 = MetaClusterEntry {
469484 uuid : uuid3. to_string ( ) ,
485+ name : name. clone ( ) ,
470486 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
471487 proxy_uuid : proxy_uuid1. to_string ( ) ,
472488 owner_id : owner_id. clone ( ) ,
@@ -503,11 +519,13 @@ mod tests {
503519 let uuid1 = Uuid :: new_v4 ( ) ;
504520 let uuid2 = Uuid :: new_v4 ( ) ;
505521 let uuid3 = Uuid :: new_v4 ( ) ;
522+ let name = "test-cluster" . to_string ( ) ;
506523 let sakura_host_uuid1 = Uuid :: new_v4 ( ) ;
507524 let proxy_uuid1 = Uuid :: new_v4 ( ) ;
508525
509526 let meta_cluster1 = MetaClusterEntry {
510527 uuid : uuid1. to_string ( ) ,
528+ name : name. clone ( ) ,
511529 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
512530 proxy_uuid : proxy_uuid1. to_string ( ) ,
513531 owner_id : "test-user-42" . to_string ( ) ,
@@ -523,6 +541,7 @@ mod tests {
523541
524542 let meta_cluster2 = MetaClusterEntry {
525543 uuid : uuid2. to_string ( ) ,
544+ name : name. clone ( ) ,
526545 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
527546 proxy_uuid : proxy_uuid1. to_string ( ) ,
528547 owner_id : "test-user-43" . to_string ( ) ,
@@ -538,6 +557,7 @@ mod tests {
538557
539558 let meta_cluster3 = MetaClusterEntry {
540559 uuid : uuid3. to_string ( ) ,
560+ name : name. clone ( ) ,
541561 sakura_host_uuid : sakura_host_uuid1. to_string ( ) ,
542562 proxy_uuid : proxy_uuid1. to_string ( ) ,
543563 owner_id : "test-user-44" . to_string ( ) ,
0 commit comments