shorten UUIDs (not sure about this one)
This commit is contained in:
		
							parent
							
								
									51ceb4a245
								
							
						
					
					
						commit
						5e3a2176f3
					
				| @ -5,10 +5,9 @@ pub mod grpc_dtpm; | ||||
| pub mod packaging; | ||||
| pub mod utils; | ||||
| 
 | ||||
| use std::sync::LazyLock; | ||||
| 
 | ||||
| use crate::config::Config; | ||||
| use crate::snp; | ||||
| use crate::utils::shorten_string; | ||||
| use crate::{constants::HRATLS_APP_PORT, utils::block_on}; | ||||
| use detee_shared::{ | ||||
|     app_proto::{ | ||||
| @ -19,6 +18,7 @@ use detee_shared::{ | ||||
| }; | ||||
| use grpc_brain::get_one_app_node; | ||||
| use serde::{Deserialize, Serialize}; | ||||
| use std::sync::LazyLock; | ||||
| use tabled::Tabled; | ||||
| 
 | ||||
| #[derive(thiserror::Error, Debug)] | ||||
| @ -37,7 +37,7 @@ pub enum Error { | ||||
| pub struct AppContract { | ||||
|     #[tabled(rename = "Location")] | ||||
|     pub location: String, | ||||
|     #[tabled(rename = "UUID")] | ||||
|     #[tabled(rename = "UUID", display_with = "shorten_string")] | ||||
|     pub uuid: String, | ||||
|     pub name: String, | ||||
|     #[tabled(rename = "Cores")] | ||||
|  | ||||
| @ -3,8 +3,9 @@ pub mod deploy; | ||||
| pub mod grpc; | ||||
| mod injector; | ||||
| pub mod update; | ||||
| use crate::utils::block_on; | ||||
| 
 | ||||
| use crate::utils::block_on; | ||||
| use crate::utils::shorten_string; | ||||
| use crate::{ | ||||
|     config::{self, Config}, | ||||
|     snp, | ||||
| @ -169,7 +170,7 @@ impl Distro { | ||||
| pub struct VmContract { | ||||
|     #[tabled(rename = "Location")] | ||||
|     pub location: String, | ||||
|     #[tabled(rename = "UUID")] | ||||
|     #[tabled(rename = "UUID", display_with = "shorten_string")] | ||||
|     pub uuid: String, | ||||
|     pub hostname: String, | ||||
|     #[tabled(rename = "Cores")] | ||||
|  | ||||
							
								
								
									
										10
									
								
								src/utils.rs
									
									
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										10
									
								
								src/utils.rs
									
									
									
									
									
								
							| @ -31,3 +31,13 @@ pub fn sign_request<T: std::fmt::Debug>(req: T) -> Result<Request<T>, Error> { | ||||
|     req.metadata_mut().insert("request-signature", signature); | ||||
|     Ok(req) | ||||
| } | ||||
| 
 | ||||
| pub fn shorten_string(my_string: &String) -> String { | ||||
|     if my_string.len() <= 8 { | ||||
|         my_string.to_string() | ||||
|     } else { | ||||
|         let first_part = &my_string[..4]; | ||||
|         let last_part = &my_string[my_string.len() - 4..]; | ||||
|         format!("{}..{}", first_part, last_part) | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user