PowerShell / DSC

This repo is for the DSC v3 project
MIT License
220 stars 30 forks source link

Export should allow resource to supply name to generated instance #598

Open SteveL-MSFT opened 2 weeks ago

SteveL-MSFT commented 2 weeks ago

Summary of the new feature / enhancement

Currently, when dsc calls export, for each returned instance, it generates the name property as an incrementing value prefixed by the resource type. This means the end user needs to manually modify each instance if they want it a bit more descriptive.

Proposed technical implementation details (optional)

Resources should be able to return a _name type metadata as part of export that would be used instead.

michaeltlombardi commented 1 week ago

Should the resources return the _metadata object with the name annotation instead, to keep all metadata processing limited to that field?

e.g. instead of returning an instance like:

scope: machine
updateAutomatically: false
_exist: true
_name: TSToy Machine Configuration

The instance would return:

scope: machine
updateAutomatically: false
_exist: true
_metadata:
  Microsoft.Dsc:
    export:
      _name: TSToy Machine Configuration

And DSC / other integrators would be able to handle it appropriately.

I've been thinking about the contract for metadata and I think having a single _metadata object is probably a good idea, especially if we scope the DSC-engine-specific metadata to a top-level property - then people can comfortably add whatever other metadata to that object, as long as whatever they return in metadata."Microsoft.DSC" matches our schemas.

SteveL-MSFT commented 4 days ago

Yeah, when I said "metadata", I literally meant metadata :)

I think we only want that as a means for resources to return this type of info back to DSC rather than as a property.