Export should allow resource to supply name to generated instance
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.
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.
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.
To pile on here, there may be other types of metadata that the export wishes to add. For example, securityContext in the case of tagging which packages need to be installed elevated. Although it is possible that Exporter type resources are more flexible way to handle this.
I'm thinking instead of using metadata (which is still good for other scenarios), it may make sense to have canonical properties like _name and _securityContext which export will bubble up into the config in the appropriate places. Also add _kind as a string for another partner.