Update proto messages and Rust types for brain integration

removed uuid type and change it a simple string
improved some grpc response type
fix some typos
This commit is contained in:
Noor 2025-01-30 18:23:29 +05:30
parent 3e783b11ba
commit a2899ba5a2
Signed by: noormohammedb
GPG Key ID: D83EFB8B3B967146
3 changed files with 19 additions and 37 deletions

@ -6,10 +6,11 @@ import "shared.proto";
message NewContainerRes {
optional shared.UUID container_id = 1;
string uuid = 1;
string status = 2;
string ip_address = 3;
repeated shared.MappedPort mapped_ports = 4;
string error = 5;
}
message ContainerInspectResp {
@ -30,7 +31,7 @@ message LogResp {
message ContainerFilters {
string admin_pubkey = 1;
optional shared.UUID container_id = 2;
optional string container_id = 2;
}
message ContainerListResp {
@ -38,7 +39,7 @@ message ContainerListResp {
}
message DeleteContainerRes {
optional shared.UUID container_id = 1;
optional string container_id = 1;
string status = 2;
}
@ -55,8 +56,8 @@ message BrainMessage {
message DaemonMessage {
oneof Msg {
shared.Pubkey pubkey = 1;
NewContainerRes new_vm_resp = 2;
DeleteContainerRes delete_vm_resp = 3;
NewContainerRes new_container_resp = 2;
DeleteContainerRes delete_container_resp = 3;
}
}

@ -8,11 +8,7 @@ message SetConfigResponse {
message Empty {
}
message UUID {
string uuid = 1;
}
// The main Config structure
message ManagerConfigPB {
repeated FileEntry filesystems = 1;
repeated EnvironmentEntry environments = 2;
@ -20,13 +16,11 @@ message ManagerConfigPB {
Container container = 4;
}
// Represents a file entry with a path and content
message FileEntry {
string path = 1;
string content = 2;
}
// Represents an environment variable entry
message EnvironmentEntry {
string name = 1;
string value = 2;
@ -41,7 +35,6 @@ message RestartPolicy {
}
}
// Represents a child process configuration
message ChildProcess {
string path = 1;
repeated string arguments = 2;
@ -69,13 +62,14 @@ message ContainerContracts {
message Container {
optional string package_url = 1;
string node = 2;
string package_url = 1;
string node_pubkey = 2;
Resource resource = 3;
UUID uuid = 4;
string uuid = 4;
string admin_pubkey = 5;
}
message Resource {
uint32 memory_mb = 1;
uint32 disk_mb = 2;

@ -193,22 +193,23 @@ impl From<RestartPolicy> for pb_shared::RestartPolicy {
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Container {
pub package_url: Option<String>,
pub node: String,
pub package_url: String,
pub resource: Option<Resource>,
pub uuid: Option<Uuid>,
#[serde(default)]
pub uuid: String,
#[serde(default)]
pub admin_pubkey: String,
pub node_pubkey: String,
}
impl From<pb_shared::Container> for Container {
fn from(pb_val: pb_shared::Container) -> Self {
Self {
package_url: pb_val.package_url,
node: pb_val.node,
resource: pb_val.resource.map(Resource::from),
uuid: pb_val.uuid.map(Uuid::from),
uuid: pb_val.uuid,
admin_pubkey: pb_val.admin_pubkey,
node_pubkey: pb_val.node_pubkey,
}
}
}
@ -217,29 +218,15 @@ impl From<Container> for pb_shared::Container {
fn from(val: Container) -> pb_shared::Container {
pb_shared::Container {
package_url: val.package_url,
node: val.node,
resource: val.resource.map(Into::into),
uuid: val.uuid.map(Into::into),
// uuid: val.uuid.map(Into::into),
uuid: val.uuid,
admin_pubkey: val.admin_pubkey,
node_pubkey: val.node_pubkey,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Uuid {
pub uuid: String,
}
impl From<pb_shared::Uuid> for Uuid {
fn from(pb_val: pb_shared::Uuid) -> Self {
Self { uuid: pb_val.uuid }
}
}
impl From<Uuid> for pb_shared::Uuid {
fn from(val: Uuid) -> pb_shared::Uuid {
pb_shared::Uuid { uuid: val.uuid }
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct Resource {
pub memory_mb: u32,