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

Add File resource #22

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Add File resource #22

wants to merge 12 commits into from

Conversation

nyanhp
Copy link

@nyanhp nyanhp commented Jan 18, 2023

Pull Request (PR) description

This PR adds a cross-platform File resource. Localization, Unit Tests pending. Local build worked, but I didn't see integration tests running. Tested all config on my local build VM.

Samples could be expanded a bit, Unix-specifics (user, group, mode) not implemented yet.

Module Manifest updated to support class-based resources (otherwise, Get-DscResource on PS7 was not finding any resources in the module).

This Pull Request (PR) fixes the following issues

None

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju self-requested a review January 18, 2023 16:28
@johlju
Copy link
Member

johlju commented Jan 18, 2023

I will fix the pipeline in another PR.

@johlju
Copy link
Member

johlju commented Jan 18, 2023

Fixed, if you rebase the pipeline should run correctly.


DscResourcesToExport = @(
'FileSystemAccessRule'
'File'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResourceName is FileSystemObject instead of File.

Copy link
Member

@johlju johlju Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is set automatically during build, so it should be @().

@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added wiki generation and publish to GitHub repository wiki.
- Added recommended VS Code extensions.
- Added settings for VS Code extension _Pester Test Adapter_.
- New File resource added to enable cross-platform file operations.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource name is FileSystemObject instead of File.

@DoLearnWhileAlive
Copy link

@nyanhp Could you please check my suggested changes? This should help for the tests.

@raandree raandree mentioned this pull request Jun 9, 2023
9 tasks
@@ -0,0 +1,382 @@
class FileSystemDscReason
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should be in a seperate file Classes/001.FileSystemDscReason.ps1.

Comment on lines 26 to -36

# Minimum version of the common language runtime (CLR) required by this module
CLRVersion = '4.0'

# Functions to export from this module
FunctionsToExport = @()

# Cmdlets to export from this module
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = @()

# Aliases to export from this module
AliasesToExport = @()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only remove the property CmdletsToExport (for it to show up in PowerShell), the other properties should remain.

Comment on lines 30 to 33
DscResourcesToExport = @(
'FileSystemAccessRule'
'File'
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DscResourcesToExport = @(
'FileSystemAccessRule'
'File'
)
DscResourcesToExport = @()

Comment on lines +152 to +166
Describe 'FileSystemObject\Set()' -Tag 'Set' -Skip {

}

Describe 'FileSystemObject\Test()' -Tag 'Test' -Skip {

}

Describe 'FileSystemObject\GetHash()' -Tag 'GetHash' -Skip {

}

Describe 'FileSystemObject\CompareHash()' -Tag 'CompareHash' -Skip {

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to test the functionality.


# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1'
PowerShellVersion = '5.1'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During my testing I've found that also RootModule must be defined in the module manifest. Otherwise the class based resources are not found.

RootModule           = 'FileSystemDsc.psm1'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see it's already added with this PR. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants