-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: P-888 add cli to print the worker version * feat: P-888 added ws api to return the worker version * Update system_version.rs Signed-off-by: will.li <[email protected]> --------- Signed-off-by: will.li <[email protected]> Co-authored-by: higherordertech <higherordertech>
- Loading branch information
1 parent
342f535
commit 3473603
Showing
13 changed files
with
559 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
name = "itc-system-version" | ||
version = "0.1.0" | ||
authors = ['Trust Computing GmbH <[email protected]>', 'Integritee AG <[email protected]>'] | ||
build = 'build.rs' | ||
edition = "2021" | ||
|
||
[dependencies] | ||
# sgx dependencies | ||
sgx_tstd = { workspace = true, optional = true } | ||
|
||
[build-dependencies] | ||
built = { workspace = true, features = ["chrono", "semver"] } | ||
|
||
[features] | ||
default = ["std"] | ||
std = [] | ||
sgx = [ | ||
"sgx_tstd", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use std::process::Command; | ||
|
||
fn main() { | ||
// Generate build-time information | ||
built::write_built_file().expect("Failed to acquire build-time information"); | ||
|
||
// Example value: ce3abe05a53fcdf103af58b46b3974cb24309543 | ||
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() { | ||
if output.status.success() { | ||
if let Ok(hash) = String::from_utf8(output.stdout) { | ||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", hash.trim()); | ||
} | ||
} | ||
} | ||
|
||
// Example value: v0.9.20-07-51-gce3abe05 | ||
if let Ok(output) = Command::new("git").args(["describe", "--tags", "--long"]).output() { | ||
if output.status.success() { | ||
if let Ok(version) = String::from_utf8(output.stdout) { | ||
println!("cargo:rustc-env=GIT_VERSION={}", version.trim()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
#[cfg(all(feature = "std", feature = "sgx"))] | ||
compile_error!("feature \"std\" and feature \"sgx\" cannot be enabled at the same time"); | ||
|
||
#[cfg(all(not(feature = "std"), feature = "sgx"))] | ||
extern crate sgx_tstd as std; | ||
|
||
use std::{format, println, string::String}; | ||
|
||
mod built_info { | ||
include!(concat!(env!("OUT_DIR"), "/built.rs")); | ||
} | ||
|
||
const DEFAULT_VALUE: &str = "unknown"; | ||
|
||
pub fn print_system_version() { | ||
println!( | ||
r#"Version Information: | ||
------------------ | ||
Target: {} | ||
Rustc version: {} | ||
Git Information: | ||
-------------- | ||
Version: {} | ||
Commit Hash: {} | ||
Build Time: | ||
--------- | ||
{}"#, | ||
built_info::TARGET, | ||
built_info::RUSTC_VERSION, | ||
option_env!("GIT_VERSION").unwrap_or(DEFAULT_VALUE), | ||
option_env!("GIT_COMMIT_HASH").unwrap_or(DEFAULT_VALUE), | ||
built_info::BUILT_TIME_UTC, | ||
) | ||
} | ||
|
||
pub fn get_system_version() -> String { | ||
format!( | ||
r#"{{"target":"{}","rustc_version":"{}","git_version":"{}","git_commit_hash":"{}","build_time":"{}"}}"#, | ||
built_info::TARGET, | ||
built_info::RUSTC_VERSION, | ||
option_env!("GIT_VERSION").unwrap_or(DEFAULT_VALUE), | ||
option_env!("GIT_COMMIT_HASH").unwrap_or(DEFAULT_VALUE), | ||
built_info::BUILT_TIME_UTC | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tee-worker/identity/cli/src/base_cli/commands/system_version.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::{Cli, CliResult, CliResultOk}; | ||
|
||
// Display the current system version detail | ||
// usage example: | ||
// ./litentry-cli system-version | ||
#[derive(Parser)] | ||
pub struct SystemVersionCommand {} | ||
|
||
impl SystemVersionCommand { | ||
pub(crate) fn run(&self, _cli: &Cli) -> CliResult { | ||
itc_system_version::print_system_version(); | ||
Ok(CliResultOk::Bytes { bytes: vec![] }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.