Compare commits

...

2 Commits

Author SHA1 Message Date
680b51f0cf shorten UUIDs (not sure about this one) 2025-03-31 15:43:07 +00:00
896884a1e1 change testing to testnet 2025-03-31 15:42:43 +00:00
4 changed files with 18 additions and 7 deletions

@ -60,7 +60,7 @@ pub struct Config {
fn default_network() -> String { fn default_network() -> String {
// default to testnet // default to testnet
// TODO: remove instruction from docs to set brain_url, since it defaults now // TODO: remove instruction from docs to set brain_url, since it defaults now
"testing".to_string() "testnet".to_string()
} }
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
@ -355,7 +355,7 @@ impl Config {
} }
pub fn set_network(mut network: &str) { pub fn set_network(mut network: &str) {
if network != "staging" { if network != "staging" && network != "testnet" {
log::error!( log::error!(
"The network {network} is not officially supported. Defaulting to testnet!" "The network {network} is not officially supported. Defaulting to testnet!"
); );

@ -5,10 +5,9 @@ pub mod grpc_dtpm;
pub mod packaging; pub mod packaging;
pub mod utils; pub mod utils;
use std::sync::LazyLock;
use crate::config::Config; use crate::config::Config;
use crate::snp; use crate::snp;
use crate::utils::shorten_string;
use crate::{constants::HRATLS_APP_PORT, utils::block_on}; use crate::{constants::HRATLS_APP_PORT, utils::block_on};
use detee_shared::{ use detee_shared::{
app_proto::{ app_proto::{
@ -19,6 +18,7 @@ use detee_shared::{
}; };
use grpc_brain::get_one_app_node; use grpc_brain::get_one_app_node;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
use tabled::Tabled; use tabled::Tabled;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
@ -37,7 +37,7 @@ pub enum Error {
pub struct AppContract { pub struct AppContract {
#[tabled(rename = "Location")] #[tabled(rename = "Location")]
pub location: String, pub location: String,
#[tabled(rename = "UUID")] #[tabled(rename = "UUID", display_with = "shorten_string")]
pub uuid: String, pub uuid: String,
pub name: String, pub name: String,
#[tabled(rename = "Cores")] #[tabled(rename = "Cores")]

@ -3,8 +3,9 @@ pub mod deploy;
pub mod grpc; pub mod grpc;
mod injector; mod injector;
pub mod update; pub mod update;
use crate::utils::block_on;
use crate::utils::block_on;
use crate::utils::shorten_string;
use crate::{ use crate::{
config::{self, Config}, config::{self, Config},
snp, snp,
@ -169,7 +170,7 @@ impl Distro {
pub struct VmContract { pub struct VmContract {
#[tabled(rename = "Location")] #[tabled(rename = "Location")]
pub location: String, pub location: String,
#[tabled(rename = "UUID")] #[tabled(rename = "UUID", display_with = "shorten_string")]
pub uuid: String, pub uuid: String,
pub hostname: String, pub hostname: String,
#[tabled(rename = "Cores")] #[tabled(rename = "Cores")]

@ -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); req.metadata_mut().insert("request-signature", signature);
Ok(req) 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)
}
}