DSC
DSC copied to clipboard
Support enhanced export with `dsc config export`
Summary of the new feature / enhancement
As an operator generating an exportable configuration from an existing system, I want more control over the generation for my exported configuration document. I want to be able to specify whether specific instances should be passed through to the generated document, even if they don't exist on the current system, are in the incorrect state, or are instances of non-exportable resources.
For example, a user might want to generate a configuration that:
- Creates a file instance using the existing contents of a file, even thought the
Microsoft/File
resource isn't exportable. - Defines a set of registry keys, even though they don't exist on the current system.
- Retrieves and enumerates every instance of the
Microsoft.IIS/WebServer
resource in the output document.
Currently, only the last use case is supported.
Proposed technical implementation details (optional)
Add an export
keyword to the resource instance schema that takes an enumeration:
-
passthru
(default for non-exportable resources) - indicates that the instance will be added to the output document exactly as it's defined in the input document. -
current
- indicates that the instance will be added to the output document using its full current state. In this case, the required properties for the instance are used to get the current state of the instance instead of being ignored. -
all
(default for exportable resources) - indicates that the any defined properties for the instance will be ignored and every instance of the resource should be exported to the output document.
This would better support generative configuration with less work for the end user. This would also enable reliable deterministic behavior for including any instances in the input document, instead of throwing an error for resources that don't support the export operation.
For non-export operations, the keyword should be ignored.
[!NOTE] An optional future extension to this model could be supporting the
export
value as an object that has thekind
andproperties
keywords, wherekind
maps to the enums above andproperties
is an array of properties to keep for the output document. I bring this up to write it down somewhere, not to include it in the initial scope for this feature.
Alternative implementation: group resources
Instead of extending the keywords for the configuration, the same functionality could be accomplished by one or more group resources:
- A single
DSC/Export
group resource with properties for each kind of export:passthru
,current
, andall
. Possible later support forfiltered
. - A collection of
DSC.Export/*
resources, likeDSC.Export/PassThru
, one per kind of export.
This implementation might be a good alternative that modularizes the implementation and functionality for exporting away from core DSC, so it can use its own release cadence and be modified without affecting the versioning of DSC itself. I'm not sure whether this ends up being more work to maintain or roughly equivalent, but it does seem like it might be more resilient. I think there could be tradeoffs for UX here, but I haven't considered them deeply.