From fea75dfcf86e461a7c73a45ba71eae823fb2cda2 Mon Sep 17 00:00:00 2001 From: Enola Knezevic Date: Mon, 4 Mar 2024 16:02:31 +0100 Subject: [PATCH] build --- Cross.toml | 5 +++++ build.rs | 29 +++++++++++++++++++++++++++++ src/config.rs | 8 +------- src/errors.rs | 6 ------ src/main.rs | 2 +- 5 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 Cross.toml create mode 100644 build.rs diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..e253e5b --- /dev/null +++ b/Cross.toml @@ -0,0 +1,5 @@ +[target.aarch64-unknown-linux-gnu] +pre-build = ["dpkg --add-architecture arm64 && apt-get update && apt-get install --assume-yes libssl-dev:arm64 && rm -rf /var/lib/apt/lists/*"] + +[target.x86_64-unknown-linux-gnu] +pre-build = ["dpkg --add-architecture amd64 && apt-get update && apt-get install --assume-yes libssl-dev:amd64 && rm -rf /var/lib/apt/lists/*"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..68523ab --- /dev/null +++ b/build.rs @@ -0,0 +1,29 @@ +use std::env; + +use build_data::get_git_dirty; + +/// Outputs a readable version number such as +/// 0.4.0 (if git commit is clean) +/// 0.4.0-SNAPSHOT (if git commit is dirty, should not happen in CI/CD builds) +fn version() -> String { + let version = String::from(env!("CARGO_PKG_VERSION")); + match get_git_dirty().unwrap() { + false => { + version + }, + true => { + format!("{}-SNAPSHOT", version) + } + } +} + +fn main() { + build_data::set_GIT_COMMIT_SHORT(); + build_data::set_GIT_DIRTY(); + build_data::set_BUILD_DATE(); + build_data::set_BUILD_TIME(); + // We must always run this build script as otherwise, we would cache old versions of CQL maps + //build_data::no_debug_rebuilds(); + println!("cargo:rustc-env=SAMPLY_USER_AGENT=Samply.Prism.{}/{}", env!("CARGO_PKG_NAME"), version()); + +} diff --git a/src/config.rs b/src/config.rs index 0268df4..5ad7326 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,7 @@ pub(crate) static CONFIG: Lazy = Lazy::new(|| { }) }); -const CLAP_FOOTER: &str = "For proxy support, environment variables HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY (and their lower-case variants) are supported. Usually, you want to set HTTP_PROXY *and* HTTPS_PROXY or set ALL_PROXY if both values are the same.\n\nFor updates and detailed usage instructions, visit https://github.com/samply/focus"; +const CLAP_FOOTER: &str = "For proxy support, environment variables HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY (and their lower-case variants) are supported. Usually, you want to set HTTP_PROXY *and* HTTPS_PROXY or set ALL_PROXY if both values are the same.\n\nFor updates and detailed usage instructions, visit https://github.com/samply/prism"; #[derive(Parser, Debug)] #[clap( @@ -62,10 +62,6 @@ struct CliArgs { #[clap(long, env, default_value = "0.0.0.0:8080")] pub bind_addr: SocketAddr, - /// Authorization header - #[clap(long, env, value_parser)] - auth_header: Option, - /// Target_application_name #[clap(long, env, value_parser, default_value = "focus")] target: String, @@ -81,7 +77,6 @@ pub(crate) struct Config { pub cors_origin: AllowOrigin, pub project: String, pub bind_addr: SocketAddr, - pub auth_header: Option, pub query: String, pub target: String, } @@ -99,7 +94,6 @@ impl Config { cors_origin: cli_args.cors_origin, project: cli_args.project, bind_addr: cli_args.bind_addr, - auth_header: cli_args.auth_header, query: get_query(), target: cli_args.target, }; diff --git a/src/errors.rs b/src/errors.rs index a6b6d3e..57701fd 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -4,18 +4,12 @@ use thiserror::Error; pub enum PrismError { #[error("Configuration error: {0}")] ConfigurationError(String), - #[error("Cannot open file: {0}")] - FileOpeningError(String), #[error("Parsing error: {0}")] ParsingError(String), #[error("Beam error: {0}")] BeamError(String), #[error("CQL tampered with: {0}")] DeserializationError(serde_json::Error), - #[error("Serialization error: {0}")] - SerializationError(String), - #[error("Invalid Header Value: {0}")] - InvalidHeaderValue(http::header::InvalidHeaderValue), #[error("Decode error: {0}")] DecodeError(base64::DecodeError), #[error("Unexpected WorkStatus: {0:?}")] diff --git a/src/main.rs b/src/main.rs index 0ca03a0..7aa6c52 100644 --- a/src/main.rs +++ b/src/main.rs @@ -309,7 +309,7 @@ async fn wait_for_beam_proxy() -> beam_lib::Result<()> { const MAX_RETRIES: u8 = 3; let mut tries = 1; loop { - match reqwest::get(format!("http://localhost:8082/v1/health")).await { + match reqwest::get(format!("{}v1/health", CONFIG.beam_proxy_url.to_string())).await { //FIXME why doesn't it work with url from config Ok(res) if res.status() == StatusCode::OK => return Ok(()), _ if tries <= MAX_RETRIES => tries += 1,