DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Support `append`, `prepend`, `remove`

Open SteveL-MSFT opened this issue 4 months ago • 5 comments

Summary of the new feature / enhancement

For List type resources which are an array. There are use cases where the order matters in terms of how the underlying application applies them. sshd_config is one example for crypto algorithms. In that case, we need to allow the user to add to the list and set the order via append and prepend and also make sure the list excludes cretain values via remove.

Proposed technical implementation details (optional)

No response

SteveL-MSFT avatar Aug 20 '25 19:08 SteveL-MSFT

My initial thinking is a canonical property called _listOperation which is an enum accepting prepend, append, remove. If not specified, the default is append. This means that only resources that have this canonical property indicate it supports the semantics. If the resource doesn't support this, then the expectation is that it is essentially _clobber=true

SteveL-MSFT avatar Sep 18 '25 20:09 SteveL-MSFT

Would this work if a resource has more than one list style property? Does it apply to all or the first or do we specify which properties? What if one property need to be appended but another property is remove in the same resource instance

ThomasNieto avatar Sep 18 '25 21:09 ThomasNieto

@ThomasNieto current guidance is that each list type property that needs ore than clobber would be an individual resource type. The alternative would be that list properties would themselves need a wrapper object and we currently don't want to go down that path.

SteveL-MSFT avatar Sep 20 '25 03:09 SteveL-MSFT

Here's what I propose:

  • for remove, it's simply _exist = false
  • for prepend and append, we have a new _listOperation with enum values prepend and append. If not specified, it defaults to append

More advance scenarios should just specify exactly what they want and the order they want and use _clobber = true

Since _exist, _listOperation, and _clobber are distinct, you could use any combination or all of them. It's up to the resource author to advertise which they support via their schema.

SteveL-MSFT avatar Sep 26 '25 19:09 SteveL-MSFT

WG discussed this, we're going to defer this until a user/partner requires it. In the interim, configurations MUST specify the complete array.

SteveL-MSFT avatar Oct 01 '25 19:10 SteveL-MSFT