Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are there any plans or is anyone working on xFile? #260

Open
alx9r opened this issue Oct 26, 2016 · 6 comments
Open

Are there any plans or is anyone working on xFile? #260

alx9r opened this issue Oct 26, 2016 · 6 comments
Labels
help wanted The issue is up for grabs for anyone in the community. resource proposal The issue is proposing a new resource in the resource module.

Comments

@alx9r
Copy link

alx9r commented Oct 26, 2016

PSDesiredStateConfiguration\File is rather opaque to my usual Pester-based testing techniques, so I'm looking for a more testable implementation of a file resource. It seems that xFile would fit that bill but it is conspicuously missing from xPSDesiredStateConfiguration. The only mention of xFile I have found is in #202. It seems from that thread that PSDesiredStateConfiguration\File won't be open-sourced.

I could implement a basic xFile but, while it would be more testable, I expect its capabilities would be much less than PSDesiredStateConfiguration\File. (Although that's hard for me to establish because it's closed.) I'd really rather contribute to an existing xFile if one exists.

Is anyone already working on xFile? If so, how can I get involved in that effort?

If I implemented a basic xFile, is there a chance it would get accepted into xPSDesiredStateConfiguration?

Thanks for your help,

Alex

@kwirkykat
Copy link
Contributor

@alx9r
Short answer: Yes you can write it, just name it something else.

The built-in File resource in PSDesiredStateConfiguration cannot be open-sourced because it is built into DSC/Windows. There is no code/file I can provide to actually edit/see the resource.

I've actually asked the team why we don't implement a more visible/testable version of File, and the answer they gave me for the moment was performance. The File resource needs to be able to perform super-fast so it is built-in the DSC/Windows code. If we could show that a not-built-in File resource still performs as well or better than the built-in one, they would consider replacing the built-in one by providing a new File in PSDscResources. But actually replacing the File resource would require extensive testing, review, and a very very strict schema

Just provided here and not in PSDscResources won't really work either. The goal for this module is to move almost all the resources to a high quality resource module (PSDscResources) and then deprecate this module.

I got the "ok" though that we could add a more flexible, testable, open-source "File" resource here as long as it has a different name (ex: xAdvancedFile, xAlternativeFile, xSuperFile...). Then we would consider later either moving it to a separate module or moving it to PSDscResources. (Or maybe eventually I could convince them that replacing the built-in File with it is an option if it was amazing and fit the exact schema they want...)

@kwirkykat kwirkykat added the resource proposal The issue is proposing a new resource in the resource module. label Oct 26, 2016
@alx9r
Copy link
Author

alx9r commented Oct 27, 2016

@kwirkykat
Thanks for the clear answer. I share the concerns about replacing PSDscResources\File. If I end up writing another file resource, I'll try to have it meet this project's contribution guidelines so you can consider including it.

There might be another way to address my testability concerns: I'm having success testing the behavior of the other "PowerShell" PSDscResources like Archive and Environment by directly invoking their respective Get-, Set-, and Test-TargetResource functions. I'd like to be able to do the same thing with the File resource, but I haven't figured out how to do that. Are there entry points somewhere that correspond to the get, set, and test commands for that special File resource?

@kwirkykat
Copy link
Contributor

@alx9r The implementation of File is actually a registered CIM class called MSFT_FileDirectoryConfiguration in the root/microsoft/windows/DesiredStateConfiguration namespace.
You can see the class by calling Get-CimClass -Namespace root/microsoft/windows/DesiredStateConfiguration -ClassName MSFT_FileDirectoryConfiguration.

The class then has the three static methods Get-TargetResource, Test-TargetResource, and Set-TargetResource which you can see under the class's CimClassMethods property. You should be able to call Get/Set/Test from there using the Invoke-CimMethod cmdlet.

See the "Calling a static method" section in this blog post for more info on how to class these static methods.

@alx9r
Copy link
Author

alx9r commented Oct 28, 2016

@kwirkykat
Good news! I have a proof-of-concept working for direct invocation of the File resource:

image

This means it's possible to test the File resource's behavior as a unit separate from the LCM.

It seems like the MSFT_FileDirectoryConfiguration class can only be accessed by privileged users. This complicates testing a bit since it looks like all tests must be invoked as a local administrator. Is there a way to access and invoke methods on MSFT_FileDirectoryConfiguration as less-privileged user?

Thanks very much for your help,

Alex

@kwirkykat
Copy link
Contributor

@alx9r I'm pretty sure you cannot access the CIM registry without privileged access. Sorry 😕

@kwirkykat kwirkykat added question The issue is a question. and removed resource proposal The issue is proposing a new resource in the resource module. labels Oct 28, 2016
@johlju
Copy link
Member

johlju commented May 14, 2018

I relabeling this as resource proposal and help wanted if someone want to work on a "SuperFile" resource according to @kwirkykat's #260 (comment).

@johlju johlju added help wanted The issue is up for grabs for anyone in the community. resource proposal The issue is proposing a new resource in the resource module. and removed question The issue is a question. labels May 14, 2018
@SteveL-MSFT SteveL-MSFT added this to Help Wanted in powershell/dscresources May 14, 2019
@SteveL-MSFT SteveL-MSFT removed this from Help Wanted in powershell/dscresources Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted The issue is up for grabs for anyone in the community. resource proposal The issue is proposing a new resource in the resource module.
Projects
None yet
Development

No branches or pull requests

3 participants