Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename provider to adapter #334

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/reference/cli/resource/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ discovers resources by first searching the `PATH` or `DSC_RESOURCE_PATH` environ
`.dsc.resource.json`, `.dsc.resource.yml`, and `dsc.resource.yaml` files. For more information
about the environment variables DSC uses, see [Environment variables][01]

If any of the discovered resources are resource providers, DSC then calls the providers to list
If any of the discovered resources are resource adapters, DSC then calls the adapters to list
their resources, too.

DSC returns the list of discovered resources with their implementation information and metadata. If
Expand All @@ -47,9 +47,9 @@ type version tags description
---- ------- ---- -----------
Test/TestGroup 0.1.0
Microsoft/OSInfo 0.1.0 {os, linux, windows, macos} Returns information about the operating system.
Microsoft.Windows/Registry 0.1.0 {Windows, NT} Registry configuration provider for the Windows Registry
Microsoft.Windows/Registry 0.1.0 {Windows, NT} Registry configuration adapter for the Windows Registry
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
This is a test resource.
DSC/PowerShellGroup 0.1.0 {PowerShell} Resource provider to classic DSC Powershell resources.
DSC/PowerShellGroup 0.1.0 {PowerShell} Resource adapter to classic DSC Powershell resources.
DSC/AssertionGroup 0.1.0 `test` will be invoked for all resources in the supplied configuration.
DSC/ParallelGroup 0.1.0 All resources in the supplied configuration run concurrently.
This is a test resource.
Expand Down Expand Up @@ -85,7 +85,7 @@ Type Version Requires Description
---------------------------------------------------------------------------------------------------------------
DSC/Group 0.1.0 All resources in the supplied configuration is treated as a group.
DSC/ParallelGroup 0.1.0 All resources in the supplied configuration run concurrently.
DSC/PowerShellGroup 0.1.0 Resource provider to classic DSC Powershell resources.
DSC/PowerShellGroup 0.1.0 Resource adapter to classic DSC Powershell resources.
DSC/AssertionGroup 0.1.0 `test` will be invoked for all resources in the supplied configuration.
```

Expand Down Expand Up @@ -118,7 +118,7 @@ dsc resource list --tags Windows --tags Linux
```output
Type Version Requires Description
-------------------------------------------------------------------------------------------------------
Microsoft.Windows/Registry 0.1.0 Registry configuration provider for the Windows Registry
Microsoft.Windows/Registry 0.1.0 Registry configuration adapter for the Windows Registry
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
Microsoft/OSInfo 0.1.0 Returns information about the operating system.
```

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/schemas/config/functions/resourceId.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ This function enables instances to reference another instance for the [dependsOn

> [!NOTE]
> When using the `resourceId` function for [nested resource instances][02], instances can only
> reference other instances in the same resource provider or group instance. They can't use the
> reference other instances in the same resource adapter or group instance. They can't use the
> `resourceId()` function to lookup instances at the top-level of the configuration document or
> inside another provider or group instance.
> inside another adapter or group instance.

## Examples

Expand Down
6 changes: 3 additions & 3 deletions docs/reference/schemas/config/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ resource named `Tailspin Key`:

> [!NOTE]
> When defining dependencies for [nested resource instances][03], instances can only reference
> dependencies in the same resource provider or group instance. They can't use the `resourceId()`
> dependencies in the same resource adapter or group instance. They can't use the `resourceId()`
> function to lookup instances at the top-level of the configuration document or inside another
> provider or group instance.
> adapter or group instance.
>
> If a top-level instance depends on a nested instance, use the `resourceId()` function to lookup
> the instance of the provider or group containing the dependency instance instead.
> the instance of the adapter or group containing the dependency instance instead.

For more information about using functions in configuration documents, see
[DSC Configuration document functions reference][04]. For more information about the `resourceId()`
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/schemas/outputs/resource/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Required: true
### path

Represents the path to the resource's manifest on the machine. For resources made available through
a provider, this property identifies the path to the file that defines the resource instead.
an adapter, this property identifies the path to the file that defines the resource instead.

```yaml
Type: string
Expand All @@ -88,7 +88,7 @@ Required: true
### directory

Represents the path to the folder containing the resource's manifest on the machine. For resources
made available through a provider, this property identifies the path to the folder containing the
made available through an adapter, this property identifies the path to the folder containing the
file that defines the resource instead.

```yaml
Expand All @@ -113,7 +113,7 @@ this property is `null`, the author is unknown.

<!--
Resources currently return this a null except for the test resources. Is
this only for provider resources, or something else?
this only for adapter resources, or something else?
-->

```yaml
Expand All @@ -123,13 +123,13 @@ Required: true

### properties

Defines the property names for resources made available through a provider resource. For other
Defines the property names for resources made available through an adapter resource. For other
resources, this property is an empty array.

<!--
Resources currently return this a null except for the test resources.
Should this value be populated for all resources made available through a
provider?
adapter?
-->

```yaml
Expand All @@ -141,7 +141,7 @@ ItemsPattern: ^\w+$

### requires

Defines the fully qualified type name of the provider resource that this resource is made available
Defines the fully qualified type name of the adapter resource that this resource is made available
through.

```yaml
Expand Down
34 changes: 17 additions & 17 deletions docs/reference/schemas/resource/manifest/provider.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
---
description: JSON schema reference for the 'provider' property in a DSC Resource manifest
description: JSON schema reference for the 'adapter' property in a DSC Resource manifest
SteveL-MSFT marked this conversation as resolved.
Show resolved Hide resolved
ms.date: 01/17/2024
ms.topic: reference
title: DSC Resource manifest provider property schema reference
title: DSC Resource manifest adapter property schema reference
---

# DSC Resource manifest provider property schema reference
# DSC Resource manifest adapter property schema reference

## Synopsis

Defines a DSC Resource as a DSC Resource Provider.
Defines a DSC Resource as a DSC Resource Adapter.

## Metadata

```yaml
SchemaDialect: https://json-schema.org/draft/2020-12/schema
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/resource/manifest.provider.json
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/resource/manifest.adapter.json
Type: object
```

## Description

DSC Resource Providers must define the `provider` property in their manifest. This property
identifies the resource as a provider and defines how DSC can call the provider to get the
resources the provider supports and how to pass resource instances to the provider.
DSC Resource Adapters must define the `adapter` property in their manifest. This property
identifies the resource as an adapter and defines how DSC can call the adapter to get the
resources the adapter supports and how to pass resource instances to the adapter.

## Examples

### Example 1 - DSC/PowerShellGroup

This example is from the `DSC/PowerShellGroup` DSC Resource Provider.
This example is from the `DSC/PowerShellGroup` DSC Resource Adapter.

```json
"provider": {
"adapter": {
"config": "full",
"list": {
"executable": "pwsh",
Expand All @@ -47,7 +47,7 @@ This example is from the `DSC/PowerShellGroup` DSC Resource Provider.
}
```

The manifest sets `config` to `full`, indicating that the provider expects a JSON blob representing
The manifest sets `config` to `full`, indicating that the adapter expects a JSON blob representing
the full and unprocessed configuration from `stdin`.

It defines `list.executable` as `pwsh`. The arguments defined in `list.args` ensure that DSC runs
Expand All @@ -59,15 +59,15 @@ PowerShell:
- To invoke the `powershellgroup.resource.ps1` script in the same folder as the `dsc` command and
pass the `List` argument.

With this definition, DSC calls the `list` method for this provider by running:
With this definition, DSC calls the `list` method for this adapter by running:

```sh
pwsh -NoLogo -NonInteractive -NoProfile -Command "./powershellgroup.resource.ps1 List"
```

## Required Properties

The `provider` definition must include these properties:
The `adapter` definition must include these properties:

- [config](#config)
- [list](#list)
Expand All @@ -76,12 +76,12 @@ The `provider` definition must include these properties:

### config

The `config` property defines how the provider expects to receive resource configurations. The
The `config` property defines how the adapter expects to receive resource configurations. The
value must be one of the following options:

- `full` - Indicates that the provider expects a JSON blob containing the full and
- `full` - Indicates that the adapter expects a JSON blob containing the full and
unprocessed configuration as a single JSON blob over `stdin`.
- `sequence` - Indicates that the provider expects each resource's configuration as
- `sequence` - Indicates that the adapter expects each resource's configuration as
a [JSON Line][01] over `stdin`.

```yaml
Expand All @@ -91,7 +91,7 @@ ValidValues: [full, sequence]

### list

The `list` property defines how to call the provider to list the resources it supports. The value
The `list` property defines how to call the adapter to list the resources it supports. The value
of this property must be an object and define the `executable` subproperty.

```yaml
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/schemas/resource/manifest/root.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ Type: object
Required: false
```

### provider
### adapter

When specified, the `provider` property defines the resource as a DSC Resource Provider.
When specified, the `adapter` property defines the resource as a DSC Resource Adapter.

The value of this property must be an object. The object's `list` and `config` properties are
mandatory. The `list` property defines how to call the provider to return the resources that the
provider can manage. The `config` property defines how the provider expects input. For more
information, see the [DSC Resource manifest provider property schema reference][11].
mandatory. The `list` property defines how to call the adapter to return the resources that the
adapter can manage. The `config` property defines how the adapter expects input. For more
information, see the [DSC Resource manifest adapter property schema reference][11].

### exitCodes

Expand Down Expand Up @@ -268,5 +268,5 @@ Required: true
[08]: set.md
[09]: test.md
[10]: validate.md
[11]: provider.md
[11]: adapter.md
[12]: schema/property.md
20 changes: 10 additions & 10 deletions dsc/src/resource_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option<OutputForm
if let Some(pr) = get_resource(dsc, requires) {
resource = pr;
} else {
error!("Provider '{}' not found", requires);
error!("Adapter '{}' not found", requires);
return;
};
}
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option<OutputForm
///
/// # Panics
///
/// Will panic if provider-based resource is not found.
/// Will panic if adapter-based resource is not found.
///
pub fn set(dsc: &DscManager, resource_type: &str, mut input: String, format: &Option<OutputFormat>) {
if input.is_empty() {
Expand All @@ -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;
};
}
Expand Down Expand Up @@ -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<OutputFormat>) {
let Some(mut resource) = get_resource(dsc, resource_type) else {
Expand All @@ -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;
};
}
Expand Down Expand Up @@ -216,20 +216,20 @@ pub fn export(dsc: &mut DscManager, resource_type: &str, format: &Option<OutputF
return
};

let mut provider_resource: Option<&DscResource> = 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);
}
Expand Down
6 changes: 3 additions & 3 deletions dsc_lib/src/configure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
};

Expand Down