-
Notifications
You must be signed in to change notification settings - Fork 113
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
Introduce config map format and parsing logic #1004
Conversation
b2a1e20
to
1078a29
Compare
@@ -13,9 +13,13 @@ oak_debug = [] | |||
default = ["oak_debug"] | |||
|
|||
[dependencies] | |||
anyhow = "*" |
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.
I think this should also be added to oak/server/rust/oak_loader/BUILD
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.
Done.
1078a29
to
ebf9e88
Compare
impl FromStr for ConfigEntry { | ||
type Err = anyhow::Error; | ||
fn from_str(v: &str) -> Result<Self, Self::Err> { | ||
let parts = v.split("=").collect::<Vec<_>>(); |
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 seems quite brittle. It might be nice in future to have some better defined parsing.
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.
I think this is fine for the foreseeable future, we fully control the file names anyways, so there is no risk that we end up with =
in the file name itself. But sure, if it does happen we can extend it.
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.
Seeing that this is also intended for sensitive data, is there a plan to add labels or some other mechanism to protect the data from untrusted nodes?
// We only log the keys here, since the values may be secret. | ||
debug!("parsed config map entries: {:?}", config_map.items.keys()); | ||
// TODO(#689): Pass the `config_map` object to the Runtime instance, and make it available to | ||
// the running Oak Application. |
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.
I am not clear on how this will be used. Is the intention to make this available to wasm nodes? Or to dynamically replace tokens in the application configuration?
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.
The intention is to make it available to the first node of an Oak application, which can then take it apart and distribute it to further nodes if it needs to. It will be easier after #917 is merged, so I'll wait for that before doing the rest of the work.
let mut file_map = HashMap::new(); | ||
for config_entry in config_entries { | ||
let file_content = read_file(&config_entry.filename)?; | ||
file_map.insert(config_entry.key.to_string(), file_content); |
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.
Perhaps log a warning if the key already exists and the value is being overwritten?
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.
Good point, done and added a test.
ebf9e88
to
a47ca7d
Compare
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.
Thanks!
impl FromStr for ConfigEntry { | ||
type Err = anyhow::Error; | ||
fn from_str(v: &str) -> Result<Self, Self::Err> { | ||
let parts = v.split("=").collect::<Vec<_>>(); |
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.
I think this is fine for the foreseeable future, we fully control the file names anyways, so there is no risk that we end up with =
in the file name itself. But sure, if it does happen we can extend it.
let mut file_map = HashMap::new(); | ||
for config_entry in config_entries { | ||
let file_content = read_file(&config_entry.filename)?; | ||
file_map.insert(config_entry.key.to_string(), file_content); |
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.
Good point, done and added a test.
// We only log the keys here, since the values may be secret. | ||
debug!("parsed config map entries: {:?}", config_map.items.keys()); | ||
// TODO(#689): Pass the `config_map` object to the Runtime instance, and make it available to | ||
// the running Oak Application. |
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.
The intention is to make it available to the first node of an Oak application, which can then take it apart and distribute it to further nodes if it needs to. It will be easier after #917 is merged, so I'll wait for that before doing the rest of the work.
a47ca7d
to
8dcf10d
Compare
This will be used to pass configuration files and secrets to Oak Applications, by specifying them via command line flags to the `oak_loader` binary. Also switch the top-level `oak_loader` error handling to the `anyhow` crate. Ref project-oak#689
8dcf10d
to
ba4affb
Compare
Reproducibility index:
|
This will be used to pass configuration files and secrets to Oak
Applications, by specifying them via command line flags to the
oak_loader
binary.Also switch the top-level
oak_loader
error handling to theanyhow
crate.
Ref #689
Checklist