Basic support of "ARMv2" AKA resources as an object
#1210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Okay so I tried a bunch of different ways and settled on this being the simplest approach. In short, a custom serde deserializer function let's us take
resourcesas either an array or an object and produce what the existing implementation expects: aVec<Resource>such that after the initial deserialization, nothing else needs to change. This means that later ordering should work (though when I testeddependsOnin Bicep, I got a different error).I can at least now pass through this Bicep directly to DSC and it gets to the point that it attempts to execute the resource:
which produces this ARM/JSON:
{ "$schema": "https://aka.ms/dsc/schemas/v3/bundled/config/document.json", "languageVersion": "2.0", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.38.33.27573", "templateHash": "9007474339958309780" } }, "imports": { "dsc": { "provider": "DesiredStateConfiguration", "version": "0.1.0" } }, "resources": { "myEcho": { "import": "dsc", "type": "Microsoft.DSC.Debug/[email protected]", "properties": { "output": "Hello world!" } } } }Perhaps we should gate this behind a feature-flag, but between this and publishing a basic version of the Bicep extension to an MCR, we can resume demos but with fancy IntelliSense and working versions!
For the fields noted as irrelevant, I sure would like to use
#[serde(skip)]but it is incompatible withdeny_unknown_fields. Perhaps we should revisit that serde flag, possibly using the linked workaround withIgnoredAnyand warnings instead of failures.I have to admit that the additional tests were generated by Claude, though it was pretty good at it!