DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Implement schema option for PsDscAdapter

Open Gijsreyn opened this issue 1 year ago • 1 comments

PR Summary

This pull request adresses partially the option to call dsc resource schema -r <resourceName> for PowerShell adapters. If I'm not wrong, there is also an overarching issue but I couldn't find it. Pardon me on it.

There are other questions popping up with this pull request:

  • How to define properties with types and description (proposal at 508)?
  • Should definition metadata be included?
  • How does the engine handle adapter resources to call schema executable through resource manifest?

PR Context

Gijsreyn avatar Sep 30 '24 11:09 Gijsreyn

Please add some tests

@SteveL-MSFT I added one test now with a hardcoded resource manifest. I'm struggling to find out the logic how dsc.exe handles adapter resources types. For now to not break the tests, i have hardcoded the type.

Do you mind helping me out and point me in the right direction? I would have expected the engine to call the dsc schema command on adapter resources directly.

Gijsreyn avatar Oct 02 '24 02:10 Gijsreyn

@Gijsreyn to confirm this enhancement works for both Windows PowerShell and PowerShell adapters correct?

ThomasNieto avatar Jun 06 '25 15:06 ThomasNieto

@Gijsreyn to confirm this enhancement works for both Windows PowerShell and PowerShell adapters correct?

It's been a while, but yes, I have explicitly added it to the powershell.resource.ps1.

Gijsreyn avatar Jun 06 '25 15:06 Gijsreyn

@Gijsreyn can you resolve the merge conflict?

SteveL-MSFT avatar Jun 06 '25 17:06 SteveL-MSFT

@SteveL-MSFT The merge conflicts are resolved. I have hardcoded a resource manifest now to let the test pass, but I still need help with the earlier question. Can you guide me in the right direction, or can we pull it in for now?

Gijsreyn avatar Jun 07 '25 03:06 Gijsreyn

Please add some tests

@SteveL-MSFT I added one test now with a hardcoded resource manifest. I'm struggling to find out the logic how dsc.exe handles adapter resources types. For now to not break the tests, i have hardcoded the type.

Do you mind helping me out and point me in the right direction? I would have expected the engine to call the dsc schema command on adapter resources directly.

For adapters, dsc engine simply expects the adapter to handle schema validation and reject (as in error) if it doesn't match. However, this design pre-dates the current work in Bicep and we now have a need to get JSONSchema for all resources (adapted or otherwise) so that intellisense can work. I created https://github.com/PowerShell/DSC/issues/872 to discuss.

For now, I think we should hold this PR until we resolve how it should work for any type of adapter.

SteveL-MSFT avatar Jun 07 '25 22:06 SteveL-MSFT