Skip to content

Commit

Permalink
(SCHEMA) Update schemas for the provider->adapter rename
Browse files Browse the repository at this point in the history
This change updates the source schemas to account for renaming DSC Resource
Providers to DSC Resource Adapters in PowerShell#334. This is a breaking schema change
that requires a new canonical URI, so the change also adds new schema URIs to
DSC to account for the changes.

The regenerated schemas will be added in the next commit.
  • Loading branch information
michaeltlombardi committed Apr 10, 2024
1 parent ef36815 commit c3d2fb8
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
10 changes: 8 additions & 2 deletions dsc_lib/src/configure/config_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ pub struct Resource {
#[derive(Debug, Default, Clone, Copy, Hash, Eq, PartialEq, Deserialize, Serialize, JsonSchema)]
pub enum DocumentSchemaUri {
#[default]
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json")]
Version2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/config/document.json")]
Bundled2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/config/document.vscode.json")]
VSCode2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json")]
Version2023_10,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/config/document.json")]
Expand All @@ -125,7 +131,7 @@ pub enum DocumentSchemaUri {
impl Default for Configuration {
fn default() -> Self {
Self {
schema: DocumentSchemaUri::Version2023_08,
schema: DocumentSchemaUri::Version2024_04,
parameters: None,
variables: None,
resources: Vec::new(),
Expand All @@ -138,7 +144,7 @@ impl Configuration {
#[must_use]
pub fn new() -> Self {
Self {
schema: DocumentSchemaUri::Version2023_08,
schema: DocumentSchemaUri::Version2024_04,
parameters: None,
variables: None,
resources: Vec::new(),
Expand Down
6 changes: 6 additions & 0 deletions dsc_lib/src/dscresources/resource_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ pub struct ResourceManifest {
#[derive(Debug, Default, Clone, Copy, Hash, Eq, PartialEq, Deserialize, Serialize, JsonSchema)]
pub enum ManifestSchemaUri {
#[default]
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.json")]
Version2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json")]
Bundled2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.vscode.json")]
VSCode2024_04,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/resource/manifest.json")]
Version2023_10,
#[serde(rename = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/bundled/resource/manifest.json")]
Expand Down
6 changes: 6 additions & 0 deletions schemas/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ using namespace System.Collections

<#
.SYNOPSIS
Build the DSC schema files from the source YAML files.
.DESCRIPTION
This build script composes the JSON Schema files from the source YAML files, creating new
files in the specified output directory. It creates a schema registry to analyze the source
schemas and resolve references for bundling.
#>

[cmdletbinding(DefaultParameterSetName='ByConfig')]
Expand Down
2 changes: 1 addition & 1 deletion schemas/schemas.config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
host: https://raw.githubusercontent.com
prefix: PowerShell/DSC/main/schemas
version: 2023/10
version: 2024/04
docs_base_url: https://learn.microsoft.com/powershell/dsc
docs_version_pin: view=dsc-3.0&preserve-view=true
bundle_schemas:
Expand Down
4 changes: 2 additions & 2 deletions schemas/src/outputs/resource/list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ properties:
type: string
pattern: ^\w+$
requires:
title: Required DSC Resource Provider
title: Required DSC Resource Adapter
description: >-
Defines the fully qualified type name of the DSC Resource Provider the
Defines the fully qualified type name of the DSC Resource Adapter the
DSC Resource depends on.
oneOf:
- $ref: /<PREFIX>/<VERSION>/definitions/resourceType.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# yaml-language-server: $schema=https://json-schema.org/draft/2020-12/schema
$schema: https://json-schema.org/draft/2020-12/schema
$id: <HOST>/<PREFIX>/<VERSION>/resource/manifest.provider.yaml
$id: <HOST>/<PREFIX>/<VERSION>/resource/manifest.adapter.yaml

title: Provider
title: Adapter
description: >-
Defines the DSC Resource as a DSC Resource Provider. A DSC Resource Provider enables users to
Defines the DSC Resource as a DSC Resource Adapter. A DSC Resource Adapter enables users to
manage resources that don't have their own manifests with DSC.
markdownDescription: | # VS Code only
***
[_Online Documentation_][01]
***
Defines the DSC Resource as a DSC Resource Provider. A DSC Resource Provider enables users to
Defines the DSC Resource as a DSC Resource Adapter. A DSC Resource Adapter enables users to
manage resources that don't have their own manifests with DSC.
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/provider?<DOCS_VERSION_PIN>
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/adapter?<DOCS_VERSION_PIN>
type: object
required:
Expand All @@ -24,15 +24,15 @@ properties:
list:
title: List Command
description: >-
Defines how DSC must call the DSC Resource Provider to list its supported DSC Resources.
Defines how DSC must call the DSC Resource Adapter to list its supported DSC Resources.
markdownDescription: | # VS Code only
***
[_Online Documentation_][01]
***
Defines how DSC must call the DSC Resource Provider to list its supported DSC Resources.
Defines how DSC must call the DSC Resource Adapter to list its supported DSC Resources.
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/provider?<DOCS_VERSION_PIN>#list
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/adapter?<DOCS_VERSION_PIN>#list
type: object
required:
- executable
Expand All @@ -49,7 +49,7 @@ properties:
is only required when the command isn't recognizable by the operating system as an
executable.
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/provider?<DOCS_VERSION_PIN>#executable
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/adapter?<DOCS_VERSION_PIN>#executable
args:
$ref: /<PREFIX>/<VERSION>/definitions/commandArgs.yaml
markdownDescription: |
Expand All @@ -75,11 +75,11 @@ properties:
registry resources list
```
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/provider?<DOCS_VERSION_PIN>#args
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/adapter?<DOCS_VERSION_PIN>#args
config:
title: Expected Configuration
description: >-
Defines whether the provider expects to receive a full and unprocessed configuration as a
Defines whether the adapter expects to receive a full and unprocessed configuration as a
single JSON blob over stdin or a sequence of JSON Lines for each child resource's
configurations.
type: string
Expand All @@ -92,21 +92,21 @@ properties:
[_Online Documentation_][01]
***
Defines whether the provider expects to receive a full and unprocessed configuration as a
Defines whether the adapter expects to receive a full and unprocessed configuration as a
single JSON blob over stdin or a sequence of JSON Lines for each child resource's
configurations.
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/provider?<DOCS_VERSION_PIN>#config
[01]: <DOCS_BASE_URL>/reference/schemas/resource/manifest/adapter?<DOCS_VERSION_PIN>#config
markdownEnumDescriptions:
- | # full
_Full and unprocessed config as a JSON blob_
> Indicates that the provider expects a JSON blob containing the full and unprocessed
> Indicates that the adapter expects a JSON blob containing the full and unprocessed
> configuration as a single JSON blob over `stdin`.
- | # sequence
_Resource instances as JSON Lines_
> Indicates that the provider expects each resource's configuration as a [JSON Line][01]
> Indicates that the adapter expects each resource's configuration as a [JSON Line][01]
> over `stdin`.
[01]: https://jsonlines.org/
Expand All @@ -125,7 +125,7 @@ examples:
defaultSnippets: # VS Code only
- label: ' Define without arguments'
markdownDescription: |
Define the provider config kind and `list` command for the resource when no arguments are
Define the adapter config kind and `list` command for the resource when no arguments are
required.
body:
config: $1
Expand All @@ -134,7 +134,7 @@ defaultSnippets: # VS Code only

- label: ' Define with arguments'
markdownDescription: |
Define the provider config kind and `list` command for the resource when at least one
Define the adapter config kind and `list` command for the resource when at least one
argument is required.
body:
config: $1
Expand Down
10 changes: 5 additions & 5 deletions schemas/src/resource/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ defaultSnippets:
description: ${23:explanation of property purpose and usage}
type: ${24|string,integer,number,array,object,null|}

- label: ' Define a resource (provider)'
- label: ' Define a resource (adapter)'
markdownDescription: |-
Defines a provider resource that enables users to define non-command-based DSC Resources in
Defines an adapter resource that enables users to define non-command-based DSC Resources in
the configuration.
body:
$schema: <HOST>/<PREFIX>/<VERSION>/bundled/resource/manifest.yaml
Expand All @@ -117,7 +117,7 @@ defaultSnippets:
input: ${15:stdin}
implementsPretest: ^${16:false}
return: ${17:state}
provider:
adapter:
config: ${18|full,sequence|}
list:
executable: ${19:executable name}
Expand Down Expand Up @@ -373,8 +373,8 @@ properties:
$ref: /<PREFIX>/<VERSION>/resource/manifest.test.yaml
validate:
$ref: /<PREFIX>/<VERSION>/resource/manifest.validate.yaml
provider:
$ref: /<PREFIX>/<VERSION>/resource/manifest.provider.yaml
adapter:
$ref: /<PREFIX>/<VERSION>/resource/manifest.adapter.yaml
exitCodes:
# This setting in the root of the schema implies exit codes must have the
# same meaning across all executions. What about implementations that
Expand Down

0 comments on commit c3d2fb8

Please sign in to comment.