Skip to content

Commit

Permalink
feat: Load DATABEND_ENTERPRISE_LICENSE_EMBEDDED while building (#16440)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
Co-authored-by: Bohu <overred.shuttler@gmail.com>
  • Loading branch information
Xuanwo and BohuTANG authored Sep 12, 2024
1 parent d444db2 commit 4d14d75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/common/building/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub fn add_building_env_vars() {
add_env_credits_info();
add_target_features();
add_env_version();
add_env_license();
}

pub fn set_env_config() {
Expand Down Expand Up @@ -87,6 +88,11 @@ fn discover_version() -> Result<String> {
}
}

pub fn add_env_license() {
let v = env::var("DATABEND_ENTERPRISE_LICENSE_EMBEDDED").unwrap_or_default();
println!("cargo:rustc-env=DATABEND_ENTERPRISE_LICENSE_EMBEDDED={v}");
}

pub fn add_env_commit_authors(repo: &Repository) {
match git::get_commit_authors(repo) {
Ok(authors) => println!("cargo:rustc-env=DATABEND_COMMIT_AUTHORS={}", authors),
Expand Down
9 changes: 8 additions & 1 deletion src/query/service/src/sessions/query_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,11 +1105,18 @@ impl TableContext for QueryContext {
}

fn get_license_key(&self) -> String {
unsafe {
let mut license = unsafe {
self.get_settings()
.get_enterprise_license()
.unwrap_or_default()
};

// Try load license from embedded env if failed to load from settings.
if license.is_empty() {
license = env!("DATABEND_ENTERPRISE_LICENSE_EMBEDDED").to_string();
}

license
}

fn get_query_profiles(&self) -> Vec<PlanProfile> {
Expand Down

0 comments on commit 4d14d75

Please sign in to comment.