Skip to content

Commit

Permalink
Readded features in full_version
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed May 16, 2024
1 parent 020e468 commit 907dc58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions limitador-server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::process::Command;
fn main() -> Result<(), Box<dyn Error>> {
set_git_hash("LIMITADOR_GIT_HASH");
set_profile("LIMITADOR_PROFILE");
set_features("LIMITADOR_FEATURES");
generate_protobuf()
}

Expand All @@ -31,6 +32,14 @@ fn set_profile(env: &str) {
}
}

fn set_features(env: &str) {
let mut features = vec![];
if cfg!(feature = "distributed_storage") {
features.push("+distributed");
}
println!("cargo:rustc-env={env}={features:?}");
}

fn set_git_hash(env: &str) {
let git_sha = Command::new("/usr/bin/git")
.args(["rev-parse", "HEAD"])
Expand Down
5 changes: 3 additions & 2 deletions limitador-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub mod prometheus_metrics;

const LIMITADOR_VERSION: &str = env!("CARGO_PKG_VERSION");
const LIMITADOR_PROFILE: &str = env!("LIMITADOR_PROFILE");
const LIMITADOR_FEATURES: &str = env!("LIMITADOR_FEATURES");
const LIMITADOR_HEADER: &str = "Limitador Server";

#[derive(Error, Debug)]
Expand Down Expand Up @@ -370,12 +371,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

fn create_config() -> (Configuration, &'static str) {
let full_version: &'static str = formatcp!(
"v{} ({}) {}",
"v{} ({}) {} {}",
LIMITADOR_VERSION,
env!("LIMITADOR_GIT_HASH"),
LIMITADOR_FEATURES,
LIMITADOR_PROFILE,
);

// wire args based of defaults
let limit_arg = Arg::new("LIMITS_FILE")
.action(ArgAction::Set)
Expand Down

0 comments on commit 907dc58

Please sign in to comment.