DSC
DSC copied to clipboard
Resource DevX: Enable rust projects to reuse well-known properties
Summary of the new feature / enhancement
As a rust developer implementing a DSC Resource, I want to be able to reuse the definition for well-known properties in my resources without having to check the implementation in DSC and copy it into my projects, so that I can reduce the effort required to participate in DSC's semantics.
For example, implementing a resource with the _exist
property requires me to define the struct field, rename it, define the default as true
, and set the JSON schema as a reference to the canonical schema for the property. This also applies to resources implementing metadata for returning what-if messages and so on.
Proposed technical implementation details (optional)
I'm not familiar enough with rust to know what the right workaround is, but it doesn't seem like rust supports inheritance in structs. In go, I would use struct embedding for this purpose, but the way to do this in rust seems like using a macro or attributes, which is beyond my current expertise to propose usefully.
I think this also speaks to the (eventual, post v3.0.0 stable release) need for development kit libraries - being able to define a struct something like:
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
#[serde(deny_unknown_fields)]
#[schemars(
title = "TailspinToys/TSToy"
description = "Manage the machine and user scope TSToy application configuration files"
)]
pub struct TSToy{
#[dsc(well_known_property)]
exist: dsc::properties::exist
// specific properties for this resource
}
And having it get all of the right things