Skip to content

Commit 6a0c452

Browse files
committed
fix: ensure cli/env overrides are applied
Closes #66
1 parent b60ed83 commit 6a0c452

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/api/workspace.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'a> WorkspaceApi<'a> {
274274
ret
275275
}
276276

277-
pub async fn edit(&self, workspace_key: &str) -> Result<(), AnyError> {
277+
pub async fn edit(&self, workspace_key: &str, spec: &WorkParams) -> Result<(), AnyError> {
278278
let labels = Labels::new(Some(workspace_key), Some(WORK_ROLE));
279279
for c in self.api.container.get_all(&labels).await? {
280280
if let Some(labels) = c.labels {
@@ -295,6 +295,7 @@ impl<'a> WorkspaceApi<'a> {
295295
let decrypted_string = decrypted_config.to_string(format)?;
296296
let edited_string = edit::edit(decrypted_string.clone())?;
297297

298+
//TODO: this check should be performed on the fully constructed config (to pick up changes in e.g. ROOZ_ env vars)
298299
if edited_string != decrypted_string {
299300
let edited_config = RoozCfg::from_string(&edited_string, format)?;
300301
let identity = self.read_age_identity().await?;
@@ -323,9 +324,7 @@ impl<'a> WorkspaceApi<'a> {
323324
};
324325

325326
self.new(
326-
&WorkParams {
327-
..Default::default()
328-
},
327+
spec,
329328
Some(ConfigSource::Body {
330329
value: encrypted_config,
331330
origin: config_source.to_string(),

src/cli.rs

+2
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ pub struct ShowConfigParams {
211211
pub struct EditParams {
212212
#[arg()]
213213
pub name: String,
214+
#[command(flatten)]
215+
pub work: WorkParams,
214216
}
215217

216218
#[derive(Parser, Debug)]

src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ async fn main() -> Result<(), AnyError> {
194194
}
195195

196196
Cli {
197-
command: Edit(EditParams { name, .. }),
197+
command: Edit(EditParams { name, work }),
198198
..
199199
} => {
200-
workspace.edit(&name).await?;
200+
workspace.edit(&name, &work).await?;
201201
}
202202

203203
Cli {

0 commit comments

Comments
 (0)