Invoke the resolve operation on a resource # Arguments `resource` - The resource manifest `cwd` - The current working directory `input` - Input to the command # Returns `ResolveResult` - The result of the resolve operation # Errors Error returned if the resource does not successfully resolve the input
(resource: &DscResource, input: &str)
| 721 | /// |
| 722 | /// Error returned if the resource does not successfully resolve the input |
| 723 | pub fn invoke_resolve(resource: &DscResource, input: &str) -> Result<ResolveResult, DscError> { |
| 724 | let Some(manifest) = &resource.manifest else { |
| 725 | return Err(DscError::MissingManifest(resource.type_name.to_string())); |
| 726 | }; |
| 727 | let Some(resolve) = &manifest.resolve else { |
| 728 | return Err(DscError::Operation(t!("dscresources.commandResource.resolveNotSupported", resource = &resource.type_name).to_string())); |
| 729 | }; |
| 730 | |
| 731 | let command_resource_info = CommandResourceInfo { |
| 732 | type_name: resource.type_name.clone(), |
| 733 | path: if resource.require_adapter.is_some() { Some(resource.path.clone()) } else { None }, |
| 734 | }; |
| 735 | |
| 736 | let args = process_get_args(resolve.args.as_ref(), input, &command_resource_info); |
| 737 | let command_input = get_command_input(resolve.input.as_ref(), input)?; |
| 738 | |
| 739 | info!("{}", t!("dscresources.commandResource.invokeResolveUsing", resource = &resource.type_name, executable = &resolve.executable)); |
| 740 | let (_exit_code, stdout, _stderr) = invoke_command(&resolve.executable, args, command_input.stdin.as_deref(), Some(&resource.directory), command_input.env, manifest.exit_codes.as_ref())?; |
| 741 | let result: ResolveResult = serde_json::from_str(&stdout)?; |
| 742 | Ok(result) |
| 743 | } |
| 744 | |
| 745 | /// Asynchronously invoke a command and return the exit code, stdout, and stderr. |
| 746 | /// |
no test coverage detected