-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AA: Add Config file mechanism #454
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2024 Alibaba Cloud | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use anyhow::Result; | ||
use serde::Deserialize; | ||
use std::fs::File; | ||
use thiserror::Error; | ||
|
||
pub mod aa_kbc_params; | ||
|
||
pub const DEFAULT_AA_CONFIG_PATH: &str = "/etc/attestation-agent.toml"; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[allow(dead_code)] | ||
pub struct Config { | ||
/// URL Address of Attestation Service | ||
pub as_uri: String, | ||
// TODO: Add more fields that accessing AS needs. | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
pub enum ConfigFileError { | ||
#[error("failed to open")] | ||
Io(#[from] std::io::Error), | ||
#[error("failed to parse")] | ||
Parse(#[from] serde_json::Error), | ||
} | ||
|
||
impl TryFrom<&str> for Config { | ||
type Error = ConfigFileError; | ||
fn try_from(config_path: &str) -> Result<Self, Self::Error> { | ||
let file = File::open(config_path)?; | ||
let cfg: Config = serde_json::from_reader(file)?; | ||
Ok(cfg) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use attestation_agent::aa_kbc_params; | ||
use attestation_agent::config::aa_kbc_params; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR also moves There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these two parts can be classified as a commit, because |
||
use thiserror::Error; | ||
|
||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is never called due to the code. Is this intentded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API is indeed not used in AA's gRPC binary, but AA library, as an independent Rust Crate, will provide support for a wider range of scenarios, so it is necessary to provide the API here.