(path: &Path, manifest: &ResourceManifest)
| 772 | } |
| 773 | |
| 774 | fn load_resource_manifest(path: &Path, manifest: &ResourceManifest) -> Result<DscResource, DscError> { |
| 775 | if manifest.version.is_date_version() { |
| 776 | warn!("{}", t!( |
| 777 | "discovery.commandDiscovery.invalidManifestVersion", |
| 778 | path = path.to_string_lossy(), |
| 779 | version = manifest.version |
| 780 | )); |
| 781 | } |
| 782 | |
| 783 | let kind = if let Some(kind) = manifest.kind.clone() { |
| 784 | kind |
| 785 | } else if manifest.adapter.is_some() { |
| 786 | Kind::Adapter |
| 787 | } else { |
| 788 | Kind::Resource |
| 789 | }; |
| 790 | |
| 791 | let mut capabilities: Vec<Capability> = vec![]; |
| 792 | if let Some(get) = &manifest.get { |
| 793 | verify_executable(&manifest.resource_type, "get", &get.executable, path.parent().unwrap()); |
| 794 | capabilities.push(Capability::Get); |
| 795 | } |
| 796 | if let Some(set) = &manifest.set { |
| 797 | verify_executable(&manifest.resource_type, "set", &set.executable, path.parent().unwrap()); |
| 798 | capabilities.push(Capability::Set); |
| 799 | if set.handles_exist == Some(true) { |
| 800 | capabilities.push(Capability::SetHandlesExist); |
| 801 | } |
| 802 | } |
| 803 | if let Some(test) = &manifest.test { |
| 804 | verify_executable(&manifest.resource_type, "test", &test.executable, path.parent().unwrap()); |
| 805 | capabilities.push(Capability::Test); |
| 806 | } |
| 807 | if let Some(delete) = &manifest.delete { |
| 808 | verify_executable(&manifest.resource_type, "delete", &delete.executable, path.parent().unwrap()); |
| 809 | capabilities.push(Capability::Delete); |
| 810 | } |
| 811 | if let Some(export) = &manifest.export { |
| 812 | verify_executable(&manifest.resource_type, "export", &export.executable, path.parent().unwrap()); |
| 813 | capabilities.push(Capability::Export); |
| 814 | } |
| 815 | if let Some(resolve) = &manifest.resolve { |
| 816 | verify_executable(&manifest.resource_type, "resolve", &resolve.executable, path.parent().unwrap()); |
| 817 | capabilities.push(Capability::Resolve); |
| 818 | } |
| 819 | if let Some(SchemaKind::Command(command)) = &manifest.schema { |
| 820 | verify_executable(&manifest.resource_type, "schema", &command.executable, path.parent().unwrap()); |
| 821 | } |
| 822 | |
| 823 | let mut resource = DscResource::new(); |
| 824 | resource.type_name = manifest.resource_type.clone(); |
| 825 | resource.kind = kind; |
| 826 | resource.implemented_as = Some(ImplementedAs::Command); |
| 827 | resource.deprecation_message = manifest.deprecation_message.clone(); |
| 828 | resource.description = manifest.description.clone(); |
| 829 | resource.version = manifest.version.clone(); |
| 830 | resource.capabilities = capabilities; |
| 831 | resource.path = path.to_path_buf(); |
no test coverage detected