Skip to content

Latest commit

 

History

History
126 lines (92 loc) · 3.31 KB

adapter.md

File metadata and controls

126 lines (92 loc) · 3.31 KB
description ms.date ms.topic title
JSON schema reference for the 'adapter' property in a DSC Resource manifest
01/17/2024
reference
DSC Resource manifest adapter property schema reference

DSC Resource manifest adapter property schema reference

Synopsis

Defines a DSC Resource as a DSC Resource Adapter.

Metadata

SchemaDialect: https://json-schema.org/draft/2020-12/schema
SchemaID:      https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.adapter.json
Type:          object

Description

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 - Microsoft.DSC/PowerShell

This example is from the Microsoft.DSC/PowerShell DSC Resource Adapter.

"adapter": {
  "list": {
    "executable": "pwsh",
    "args": [
      "-NoLogo",
      "-NonInteractive",
      "-NoProfile",
      "-Command",
      "./powershell.resource.ps1 List"
    ]
    },
  "config": "full"
},

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 PowerShell:

  • Without the logo banner
  • In non-interactive mode
  • Without loading any profile scripts
  • To invoke the powershell.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 adapter by running:

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

Required Properties

The adapter definition must include these properties:

Properties

config

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 adapter expects a JSON blob containing the full and unprocessed configuration as a single JSON blob over stdin.
  • sequence - Indicates that the adapter expects each resource's configuration as a JSON Line over stdin.
Type:        string
ValidValues: [full, sequence]

list

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 sub-property.

Type:               object
Required:           true
RequiredProperties: [executable]

executable

The executable sub-property defines the name of the command to run. The value must be the name of a command discoverable in the system's PATH environment variable or the full path to the command. A file extension is only required when the command isn't recognizable by the operating system as an executable.

Type:     string
Required: true

args

The args sub-property defines an array of strings to pass as arguments to the command. DSC passes the arguments to the command in the order they're specified.

Type:     array
Required: false
Default:  []