DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Allow conditional resource manifest args

Open SteveL-MSFT opened this issue 3 months ago • 2 comments

Summary of the new feature / enhancement

It would be useful to have conditional args passed to resources, like OS or architecture, for example.

Proposed technical implementation details (optional)

Add a new arg object:

{
  "condition": "<expression>",
  "args": [ <args> ]
}

condition would accept a valid expression and args is only appended if condition evaluates to true. Of course, some functions won't be available.

args would be an array and itself can take any valid arg string or object.

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

Will condition require the wrapping []?

I wonder whether we might want to provide some variants like os and commandExists - or manifest-only expressions (since they don't need to be ARM compatible). I suppose you could have multiple conditional argument object definitions and it's on the author to ensure the combinations are valid (and handle ensuring mutually exclusive options / preventing unintentional duplicate arguments).

I also wonder about being able to conditionally select not an argument but the executable.

michaeltlombardi avatar Sep 22 '25 14:09 michaeltlombardi

os is now exposed via the context() function so that is covered. We could add a commandExists() function. I don't think we need to specialize these functions to only work within a manifest. We could also allow for executable property to be an expression.

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