Value Specification
Item parameter values are eventually concrete values.
Some of those concrete values are not necessarily known until partway through a flow execution. When a flow is defined, a user needs a way to encode where a value comes from.
Plain Values
Plain values are values that a user provides before a command is executed.
A variation of plain values is to provide a lookup function that is evaluated at the point the value is needed, but that has potential negative effects for user experience:
- Performance: Web service call(s) may take seconds to complete.
- Consistency: Multiple executions may discover different values between different command executions.
In code, this may look like:
let app_params_spec = AppParams::spec()
.repo_path(Path::from("/path/to/project"))
.build();
let server_params_spec = ServerParams::spec()
.image_id(image_id!("abcd1234"))
.instance_size(InstanceSize::Large)
.build();
cmd_ctx_builder
.with_item_params(app_params_spec)
.with_item_params(server_params_spec)
.await?;
Referenced Values
Referenced values are values directly taken from a predecessor's state output.
In code, this may look like:
let file_upload_params_spec = FileUploadParams::spec()
.src_from::<AppOutputPath>()
// ..
.build();
cmd_ctx_builder
.with_item_params(file_upload_params_spec)
.await?;
Transformed Values
In code, this may look like:
let file_upload_params_spec = FileUploadParams::spec()
// ..
.dest_from_map::<Server>(|server| {
let ip = server.ip();
format!("user@${ip}:/path/to/dest")
})
.build();
cmd_ctx_builder
.with_item_params(file_upload_params_spec)
.await?;