atharvalade commented on code in PR #2998:
URL: https://github.com/apache/iggy/pull/2998#discussion_r2996284523
##########
core/cli/src/commands/binary_context/common.rs:
##########
@@ -126,6 +126,69 @@ impl ContextManager {
Ok(context_state.contexts.clone())
}
+ pub async fn create_context(&mut self, name: &str, config: ContextConfig)
-> Result<()> {
+ self.get_context_state().await?;
+ let cs = self.context_state.as_ref().unwrap();
+
+ if cs.contexts.contains_key(name) {
+ bail!("context '{name}' already exists in {CONTEXTS_FILE_NAME}")
+ }
+
+ let mut new_contexts = cs.contexts.clone();
+ new_contexts.insert(name.to_string(), config);
+
+ self.context_rw.ensure_iggy_home_exists()?;
+ self.context_rw
+ .write_contexts(new_contexts.clone())
Review Comment:
Thanks for catching this -- added `set_owner_only_permissions` that sets
0600 on `contexts.toml` after every write (unix only, no-op on Windows).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]