Skip to content

Commit 485b8e2

Browse files
committed
Allow variable expansion on the "background_script" state property
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
1 parent efa9bf2 commit 485b8e2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

crates/core/tedge_api/src/workflow/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ impl OperationAction {
276276
},
277277
handlers.clone(),
278278
),
279+
OperationAction::BgScript(script, handlers) => OperationAction::BgScript(
280+
ShellScript {
281+
command: state.inject_values_into_template(&script.command),
282+
args: state.inject_values_into_parameters(&script.args),
283+
},
284+
handlers.clone(),
285+
),
279286
OperationAction::Operation(command, Some(script), input, handlers) => {
280287
OperationAction::Operation(
281288
state.inject_values_into_template(command),

docs/src/references/agent/operation-workflow.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ on_timeout = "timeout_restart"
508508
on_success = "successful_restart"
509509
```
510510

511+
As for regular scripts, the parameters of a background script can be populated from the current command state,
512+
as in `background_script = "sudo shutdown --reboot ${.payload.reboot_delay}"`
513+
511514
#### Awaiting Sub-Command Completion
512515

513516
When a sub `operation` is executed, the operation workflow moves to a waiting state which `action` must be `await-operation-completion`.

0 commit comments

Comments
 (0)