Skip to content

Commit

Permalink
chore: Restructuring repo and updating build.rs/mod.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
lfbrehm committed Sep 4, 2024
1 parent c6f45e4 commit 7e08c98
Show file tree
Hide file tree
Showing 24 changed files with 21,570 additions and 19,354 deletions.
83 changes: 65 additions & 18 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,95 @@ extern crate tonic_build;
use std::fs;

fn main() {

// V2
let mut protos: Vec<String> = Vec::new();

let service_entries = fs::read_dir("./src/protos/aruna/api/storage/services/v2/").unwrap();
let service_entries = fs::read_dir("./src/protos/v2/aruna/api/storage/services/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/aruna/api/storage/services/v2/",
"./src/protos/v2/aruna/api/storage/services/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

let service_entries = fs::read_dir("./src/protos/aruna/api/notification/services/v2/").unwrap();
let service_entries = fs::read_dir("./src/protos/v2/aruna/api/notification/services/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/aruna/api/notification/services/v2/",
"./src/protos/v2/aruna/api/notification/services/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

let service_entries = fs::read_dir("./src/protos/aruna/api/dataproxy/services/v2/").unwrap();
let service_entries = fs::read_dir("./src/protos/v2/aruna/api/dataproxy/services/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/aruna/api/dataproxy/services/v2/",
"./src/protos/v2/aruna/api/dataproxy/services/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

let service_entries = fs::read_dir("./src/protos/aruna/api/hooks/services/v2/").unwrap();
let service_entries = fs::read_dir("./src/protos/v2/aruna/api/hooks/services/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/aruna/api/hooks/services/v2/",
"./src/protos/v2/aruna/api/hooks/services/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

let service_entries = fs::read_dir("./src/protos/aruna/api/health/v2/").unwrap();
let service_entries = fs::read_dir("./src/protos/v2/aruna/api/health/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/aruna/api/health/v2/",
"./src/protos/v2/aruna/api/health/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

let service_entries = fs::read_dir("./src/protos/v2/aruna/api/storage/models/v2/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
let rel_path = format!(
"{}{}",
"./src/protos/v2/aruna/api/storage/models/v2/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}


tonic_build::configure()
.type_attribute(".", "#[derive(serde::Deserialize, serde::Serialize)]")
.compile_well_known_types(true)
.extern_path(".google.protobuf", "::prost_wkt_types")
.build_server(true)
.out_dir("./src/aruna")
.out_dir("./src/v2/aruna")
.compile(
&protos,
&[
"./src/protos".to_string(),
"./src/protos/aruna/api/google".to_string(),
"./src/protos/aruna/api/protoc-gen-openapiv2".to_string(),
"./src/protos/v2".to_string(),
"./src/protos/v2/aruna/api/google".to_string(),
"./src/protos/v2/aruna/api/protoc-gen-openapiv2".to_string(),
],
)
.unwrap();
Expand All @@ -87,14 +102,46 @@ fn main() {
.extern_path(".google.protobuf", "::prost_wkt_types")
.build_server(true)
.build_transport(false)
.out_dir("./src/aruna_no_transport")
.out_dir("./src/v2/aruna_no_transport")
.compile(
&protos,
&[
"./src/protos".to_string(),
"./src/protos/aruna/api/google".to_string(),
"./src/protos/aruna/api/protoc-gen-openapiv2".to_string(),
"./src/protos/v2".to_string(),
"./src/protos/v2/aruna/api/google".to_string(),
"./src/protos/v2/aruna/api/protoc-gen-openapiv2".to_string(),
],
)
.unwrap();


// V3
let mut protos = Vec::new();
let service_entries = fs::read_dir("./src/protos/v3/").unwrap();

for entry in service_entries {
let dir = entry.unwrap();
if dir.file_name().to_str().unwrap().contains("timestamp") {
continue
}
let rel_path = format!(
"{}{}",
"./src/protos/v3/",
dir.file_name().to_str().unwrap()
);
protos.push(rel_path);
}

tonic_build::configure()
.build_server(true)
.out_dir("./src/v3")
.extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp")
.build_server(true)
.compile(
&protos,
&[
"./src/protos/v3",
]
)
.unwrap();

}
Empty file removed src/aruna/google.protobuf.rs
Empty file.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(feature = "transport")]
pub mod aruna;
pub mod v2;
#[cfg(feature = "transport")]
pub use aruna::aruna::*;
pub use v2::aruna::aruna::*;
#[cfg(not(feature = "transport"))]
pub mod aruna_no_transport;
#[cfg(not(feature = "transport"))]
pub use aruna_no_transport::aruna::*;
pub use v2::aruna_no_transport::aruna::*;
#[cfg(feature = "transport")]
pub mod v3;
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -558,47 +558,6 @@ pub struct Object {
#[prost(message, repeated, tag = "18")]
pub rule_bindings: ::prost::alloc::vec::Vec<RuleBinding>,
}
/// --------------- ENUMS ------------------------
/// Defines the public announcement type
#[derive(serde::Deserialize, serde::Serialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AnnouncementType {
Unspecified = 0,
Orga = 1,
Release = 2,
Update = 3,
Maintenance = 4,
Blog = 5,
}
impl AnnouncementType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
AnnouncementType::Unspecified => "ANNOUNCEMENT_TYPE_UNSPECIFIED",
AnnouncementType::Orga => "ANNOUNCEMENT_TYPE_ORGA",
AnnouncementType::Release => "ANNOUNCEMENT_TYPE_RELEASE",
AnnouncementType::Update => "ANNOUNCEMENT_TYPE_UPDATE",
AnnouncementType::Maintenance => "ANNOUNCEMENT_TYPE_MAINTENANCE",
AnnouncementType::Blog => "ANNOUNCEMENT_TYPE_BLOG",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"ANNOUNCEMENT_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"ANNOUNCEMENT_TYPE_ORGA" => Some(Self::Orga),
"ANNOUNCEMENT_TYPE_RELEASE" => Some(Self::Release),
"ANNOUNCEMENT_TYPE_UPDATE" => Some(Self::Update),
"ANNOUNCEMENT_TYPE_MAINTENANCE" => Some(Self::Maintenance),
"ANNOUNCEMENT_TYPE_BLOG" => Some(Self::Blog),
_ => None,
}
}
}
/// Dataclass defines the confidentiality of the object
#[derive(serde::Deserialize, serde::Serialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
Expand Down
Loading

0 comments on commit 7e08c98

Please sign in to comment.