diff --git a/dsc/src/resource_command.rs b/dsc/src/resource_command.rs index 427a796d4..181eb0940 100644 --- a/dsc/src/resource_command.rs +++ b/dsc/src/resource_command.rs @@ -27,7 +27,7 @@ pub fn get(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op if let Some(pr) = get_resource(dsc, requires) { resource = pr; } else { - error!("Provider {} not found", requires); + error!("Adapter {} not found", requires); return; }; } @@ -64,7 +64,7 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option) { if input.is_empty() { @@ -118,7 +118,7 @@ pub fn set(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op if let Some(pr) = get_resource(dsc, requires) { resource = pr; } else { - error!("Provider {} not found", requires); + error!("Adapter {} not found", requires); return; }; } @@ -146,7 +146,7 @@ pub fn set(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op /// /// # Panics /// -/// Will panic if provider-based resource is not found. +/// Will panic if adapter-based resource is not found. /// pub fn test(dsc: &DscManager, resource_type: &str, mut input: String, format: &Option) { let Some(mut resource) = get_resource(dsc, resource_type) else { @@ -161,7 +161,7 @@ pub fn test(dsc: &DscManager, resource_type: &str, mut input: String, format: &O if let Some(pr) = get_resource(dsc, requires) { resource = pr; } else { - error!("Provider {} not found", requires); + error!("Adapter {} not found", requires); return; }; } @@ -216,20 +216,20 @@ pub fn export(dsc: &mut DscManager, resource_type: &str, format: &Option = None; + let mut adapter_resource: Option<&DscResource> = None; if let Some(requires) = &dsc_resource.requires { input = add_type_name_to_json(input, dsc_resource.type_name.clone()); if let Some(pr) = get_resource(dsc, requires) { - provider_resource = Some(pr); + adapter_resource = Some(pr); } else { - error!("Provider '{}' not found", requires); + error!("Adapter '{}' not found", requires); return; }; } let mut conf = Configuration::new(); - if let Err(err) = add_resource_export_results_to_configuration(dsc_resource, provider_resource, &mut conf, &input) { + if let Err(err) = add_resource_export_results_to_configuration(dsc_resource, adapter_resource, &mut conf, &input) { error!("Error: {err}"); exit(EXIT_DSC_ERROR); } diff --git a/dsc_lib/src/configure/mod.rs b/dsc_lib/src/configure/mod.rs index f717c2f81..dc3573750 100644 --- a/dsc_lib/src/configure/mod.rs +++ b/dsc_lib/src/configure/mod.rs @@ -52,10 +52,10 @@ pub enum ErrorAction { /// # Errors /// /// This function will return an error if the underlying resource fails. -pub fn add_resource_export_results_to_configuration(resource: &DscResource, provider_resource: Option<&DscResource>, conf: &mut Configuration, input: &str) -> Result<(), DscError> { +pub fn add_resource_export_results_to_configuration(resource: &DscResource, adapter_resource: Option<&DscResource>, conf: &mut Configuration, input: &str) -> Result<(), DscError> { - let export_result = match provider_resource { - Some(_) => provider_resource.unwrap().export(input)?, + let export_result = match adapter_resource { + Some(_) => adapter_resource.unwrap().export(input)?, _ => resource.export(input)? }; diff --git a/dsc_lib/src/discovery/command_discovery.rs b/dsc_lib/src/discovery/command_discovery.rs index d4575c6fb..74b02dc00 100644 --- a/dsc_lib/src/discovery/command_discovery.rs +++ b/dsc_lib/src/discovery/command_discovery.rs @@ -51,7 +51,7 @@ impl CommandDiscovery { pb.set_message("Searching for resources"); let mut resources: BTreeMap = BTreeMap::new(); - let mut provider_resources: Vec = Vec::new(); + let mut adapter_resources: Vec = Vec::new(); let mut remaining_required_resource_types = required_resource_types.to_owned(); // try DSC_RESOURCE_PATH env var first otherwise use PATH let path_env = match env::var_os("DSC_RESOURCE_PATH") { @@ -97,8 +97,8 @@ impl CommandDiscovery { if resource.manifest.is_some() { let manifest = import_manifest(resource.manifest.clone().unwrap())?; - if manifest.provider.is_some() { - provider_resources.push(resource.type_name.to_lowercase()); + if manifest.adapter.is_some() { + adapter_resources.push(resource.type_name.to_lowercase()); resources.insert(resource.type_name.to_lowercase(), resource.clone()); } } @@ -123,30 +123,30 @@ impl CommandDiscovery { } } - debug!("Found {} matching non-provider resources", resources.len() - provider_resources.len()); + debug!("Found {} matching non-adapter resources", resources.len() - adapter_resources.len()); - // now go through the provider resources and add them to the list of resources - for provider in provider_resources { - debug!("Enumerating resources for provider {}", provider); + // now go through the adapter resources and add them to the list of resources + for adapter in adapter_resources { + debug!("Enumerating resources for adapter {}", adapter); let pb_adapter = multi_progress_bar.add(ProgressBar::new(1)); pb_adapter.enable_steady_tick(Duration::from_millis(120)); pb_adapter.set_style(ProgressStyle::with_template( "{spinner:.green} [{elapsed_precise:.cyan}] {msg:.white}" )?); - pb_adapter.set_message(format!("Enumerating resources for adapter {provider}")); - let provider_resource = resources.get(&provider).unwrap(); - let provider_type_name = provider_resource.type_name.clone(); - let manifest = import_manifest(provider_resource.manifest.clone().unwrap())?; - let mut provider_resources_count = 0; + pb_adapter.set_message(format!("Enumerating resources for adapter {adapter}")); + let adapter_resource = resources.get(&adapter).unwrap(); + let adapter_type_name = adapter_resource.type_name.clone(); + let manifest = import_manifest(adapter_resource.manifest.clone().unwrap())?; + let mut adapter_resources_count = 0; // invoke the list command - let list_command = manifest.provider.unwrap().list; - let (exit_code, stdout, stderr) = match invoke_command(&list_command.executable, list_command.args, None, Some(&provider_resource.directory), None) + let list_command = manifest.adapter.unwrap().list; + let (exit_code, stdout, stderr) = match invoke_command(&list_command.executable, list_command.args, None, Some(&adapter_resource.directory), None) { Ok((exit_code, stdout, stderr)) => (exit_code, stdout, stderr), Err(e) => { - /* In case of "resource list" operation - print failure from provider as warning + /* In case of "resource list" operation - print failure from adapter as warning In case of other resource/config operations: - print failure from provider as error because this provider was specifically requested by current resource/config operation*/ + print failure from adapter as error because this adapter was specifically requested by current resource/config operation*/ if return_all_resources { warn!("Could not start {}: {}", list_command.executable, e); } else { @@ -157,13 +157,13 @@ impl CommandDiscovery { }; if exit_code != 0 { - /* In case of "resource list" operation - print failure from provider as warning + /* In case of "resource list" operation - print failure from adapter as warning In case of other resource/config operations: - print failure from provider as error because this provider was specifically requested by current resource/config operation*/ + print failure from adapter as error because this adapter was specifically requested by current resource/config operation*/ if return_all_resources { - warn!("Provider failed to list resources with exit code {exit_code}: {stderr}"); + warn!("Adapter failed to list resources with exit code {exit_code}: {stderr}"); } else { - error!("Provider failed to list resources with exit code {exit_code}: {stderr}"); + error!("Adapter failed to list resources with exit code {exit_code}: {stderr}"); } } @@ -172,16 +172,16 @@ impl CommandDiscovery { Result::Ok(resource) => { if resource.requires.is_none() { if return_all_resources { - warn!("{}", DscError::MissingRequires(provider.clone(), resource.type_name.clone()).to_string()); + warn!("{}", DscError::MissingRequires(adapter.clone(), resource.type_name.clone()).to_string()); } else { - error!("{}", DscError::MissingRequires(provider.clone(), resource.type_name.clone()).to_string()); + error!("{}", DscError::MissingRequires(adapter.clone(), resource.type_name.clone()).to_string()); } continue; } if return_all_resources { resources.insert(resource.type_name.to_lowercase(), resource); - provider_resources_count += 1; + adapter_resources_count += 1; } else if remaining_required_resource_types.contains(&resource.type_name.to_lowercase()) { @@ -204,9 +204,9 @@ impl CommandDiscovery { } }; } - pb_adapter.finish_with_message(format!("Done with {provider}")); + pb_adapter.finish_with_message(format!("Done with {adapter}")); - debug!("Provider {} listed {} matching resources", provider_type_name, provider_resources_count); + debug!("Adapter '{}' listed {} matching resources", adapter_type_name, adapter_resources_count); } pb.finish_with_message("Discovery complete"); diff --git a/dsc_lib/src/dscerror.rs b/dsc_lib/src/dscerror.rs index ab97c16ad..3c5defacb 100644 --- a/dsc_lib/src/dscerror.rs +++ b/dsc_lib/src/dscerror.rs @@ -59,7 +59,7 @@ pub enum DscError { #[error("Missing manifest: {0}")] MissingManifest(String), - #[error("Provider source '{0}' missing 'requires' property for resource '{1}'")] + #[error("Adapter-based resource '{0}' missing 'requires' property for resource '{1}'")] MissingRequires(String, String), #[error("Schema missing from manifest: {0}")] diff --git a/dsc_lib/src/dscresources/dscresource.rs b/dsc_lib/src/dscresources/dscresource.rs index aeaf0320c..5ece53221 100644 --- a/dsc_lib/src/dscresources/dscresource.rs +++ b/dsc_lib/src/dscresources/dscresource.rs @@ -31,7 +31,7 @@ pub struct DscResource { pub author: Option, /// The properties of the resource. pub properties: Vec, - /// The required resource provider for the resource. + /// The required resource adapter for the resource. pub requires: Option, /// The manifest of the resource. pub manifest: Option, diff --git a/dsc_lib/src/dscresources/resource_manifest.rs b/dsc_lib/src/dscresources/resource_manifest.rs index 29c7c519f..d305c1806 100644 --- a/dsc_lib/src/dscresources/resource_manifest.rs +++ b/dsc_lib/src/dscresources/resource_manifest.rs @@ -37,9 +37,9 @@ pub struct ResourceManifest { /// Details how to call the Validate method of the resource. #[serde(skip_serializing_if = "Option::is_none")] pub validate: Option, - /// Indicates the resource is a provider of other resources. + /// Indicates the resource is a adapter of other resources. #[serde(skip_serializing_if = "Option::is_none")] - pub provider: Option, + pub adapter: Option, /// Mapping of exit codes to descriptions. Zero is always success and non-zero is always failure. #[serde(rename = "exitCodes", skip_serializing_if = "Option::is_none")] pub exit_codes: Option>, @@ -167,19 +167,19 @@ pub struct ExportMethod { } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)] -pub struct Provider { - /// The way to list provider supported resources. +pub struct Adapter { + /// The way to list adapter supported resources. pub list: ListMethod, - /// Defines how the provider supports accepting configuraiton. + /// Defines how the adapter supports accepting configuraiton. pub config: ConfigKind, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)] pub enum ConfigKind { - /// The provider accepts full unprocessed configuration. + /// The adapter accepts full unprocessed configuration. #[serde(rename = "full")] Full, - /// The provider accepts configuration as a sequence. + /// The adapter accepts configuration as a sequence. #[serde(rename = "sequence")] Sequence, } diff --git a/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 b/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 index d02c38d47..7e05639c0 100644 --- a/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 +++ b/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 @@ -57,7 +57,7 @@ function Test-TargetResource { [System.String] $PackageManagementProvider ) - + if (($Name -eq "TestPSRepository1") -and ($PackageManagementProvider -eq 'NuGet')) { return $true diff --git a/powershellgroup/powershellgroup.dsc.resource.json b/powershellgroup/powershellgroup.dsc.resource.json index 4b01ebbed..7f9f9e228 100644 --- a/powershellgroup/powershellgroup.dsc.resource.json +++ b/powershellgroup/powershellgroup.dsc.resource.json @@ -2,11 +2,11 @@ "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", "type": "DSC/PowerShellGroup", "version": "0.1.0", - "description": "Resource provider to classic DSC Powershell resources.", + "description": "Resource adapter to classic DSC Powershell resources.", "tags": [ "PowerShell" ], - "provider": { + "adapter": { "list": { "executable": "pwsh", "args": [ @@ -76,7 +76,7 @@ "-Command", "$Input | ./powershellgroup.resource.ps1 Validate" ] - }, + }, "exitCodes": { "0": "Success", "1": "Error" diff --git a/powershellgroup/windowspowershellgroup.resource.json_todo b/powershellgroup/windowspowershellgroup.resource.json_todo index 54015ca2f..d7828e13a 100644 --- a/powershellgroup/windowspowershellgroup.resource.json_todo +++ b/powershellgroup/windowspowershellgroup.resource.json_todo @@ -2,8 +2,8 @@ "manifestVersion": "1.0", "type": "DSC/WindowsPowerShellGroup", "version": "0.1.0", - "description": "Resource provider to classic DSC Powershell resources in Windows PowerShell.", - "provider": { + "description": "Resource adapter to classic DSC Powershell resources in Windows PowerShell.", + "adapter": { "list": { "executable": "powershell", "args": [ @@ -56,4 +56,3 @@ "1": "Error" } } - \ No newline at end of file diff --git a/registry/registry.dsc.resource.json b/registry/registry.dsc.resource.json index 74cec84c9..98110f41c 100644 --- a/registry/registry.dsc.resource.json +++ b/registry/registry.dsc.resource.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", "type": "Microsoft.Windows/Registry", - "description": "Registry configuration provider for the Windows Registry", + "description": "Manage Windows Registry keys and values", "tags": [ "Windows", "NT" diff --git a/tools/test_group_resource/src/main.rs b/tools/test_group_resource/src/main.rs index 44c742a1d..cb6555d60 100644 --- a/tools/test_group_resource/src/main.rs +++ b/tools/test_group_resource/src/main.rs @@ -37,7 +37,7 @@ fn main() { test: None, export: None, validate: None, - provider: None, + adapter: None, exit_codes: None, schema: None, }).unwrap()), @@ -67,7 +67,7 @@ fn main() { test: None, export: None, validate: None, - provider: None, + adapter: None, exit_codes: None, schema: None, }).unwrap()), diff --git a/tools/test_group_resource/testGroup.dsc.resource.json b/tools/test_group_resource/testGroup.dsc.resource.json index e674bb46b..4f82e27e6 100644 --- a/tools/test_group_resource/testGroup.dsc.resource.json +++ b/tools/test_group_resource/testGroup.dsc.resource.json @@ -16,7 +16,7 @@ ] } }, - "provider": { + "adapter": { "list": { "executable": "test_group_resource", "args": [ diff --git a/tools/test_group_resource/tests/provider.tests.ps1 b/tools/test_group_resource/tests/provider.tests.ps1 index bfcd0785c..c977b7f9e 100644 --- a/tools/test_group_resource/tests/provider.tests.ps1 +++ b/tools/test_group_resource/tests/provider.tests.ps1 @@ -1,9 +1,9 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe 'Resource provider tests' { +Describe 'Resource adapter tests' { - It 'Can list provider resources' { + It 'Can list adapter resources' { $out = dsc resource list *testresource* | ConvertFrom-Json | Sort-Object -Property type $out.Count | Should -Be 2 @@ -19,7 +19,7 @@ Describe 'Resource provider tests' { $out[1].requires | Should -BeExactly 'Test/TestGroup' } - It 'Error if provider resource is missing "requires" member' { + It 'Error if adapter resource is missing "requires" member' { $invalid_manifest = @' { "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", @@ -39,7 +39,7 @@ Describe 'Resource provider tests' { ] } }, - "provider": { + "adapter": { "list": { "executable": "test_group_resource", "args": [ diff --git a/wmigroup/wmigroup.dsc.resource.json.optout b/wmigroup/wmigroup.dsc.resource.json.optout index 049c2f6fe..90fa32a34 100644 --- a/wmigroup/wmigroup.dsc.resource.json.optout +++ b/wmigroup/wmigroup.dsc.resource.json.optout @@ -2,11 +2,11 @@ "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", "type": "DSC/WMIGroup", "version": "0.1.0", - "description": "Resource provider to WMI resources.", + "description": "Resource adapter to WMI resources.", "tags": [ "PowerShell" ], - "provider": { + "adapter": { "list": { "executable": "powershell", "args": [ @@ -39,7 +39,7 @@ "-Command", "$Input | ./wmigroup.resource.ps1 Validate" ] - }, + }, "exitCodes": { "0": "Success", "1": "Error"