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

PowerShellGroup resource #82

Merged
merged 39 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4e9466a
Group code 1
anmenaga Apr 20, 2023
b7ee70e
fixes after merge conflicts 1
anmenaga Apr 20, 2023
e49f134
Fixed warnings after fixing merge conflicts
anmenaga Apr 20, 2023
55e36aa
Update to powershellgroup.resource.json
anmenaga Apr 20, 2023
890a566
Fixed List operation on powershellgroup resource
anmenaga Apr 21, 2023
9cc05c0
Added PowerShellGroup processing of config Get
anmenaga Apr 21, 2023
4bbd5bc
update to use built-in resources
SteveL-MSFT Apr 22, 2023
7003711
Add more info to DscResource deserialization error
May 27, 2023
8e9e2f6
Added ResourceCache to PSGR
May 27, 2023
24decf3
Initial PSGroupResource
anmenaga Jun 7, 2023
56e6d0a
Added WindowsPowerShellGroup resource
anmenaga Jun 8, 2023
a17ee78
Feedback 1
anmenaga Jun 15, 2023
3c0e900
Fixed clippy pedantic failures
anmenaga Jun 20, 2023
2447fb8
Fixed tests
anmenaga Jun 20, 2023
17a0c04
Updated tests 1
anmenaga Jun 20, 2023
f04b0a4
Updated tests 2
anmenaga Jun 21, 2023
36a62e7
Updated tests 3
anmenaga Jun 21, 2023
c84dcae
Updated tests 4
anmenaga Jun 21, 2023
06481e9
Updated tests 5
anmenaga Jun 21, 2023
099840f
Updated tests 6
anmenaga Jun 21, 2023
360ea6a
Updated tests 7
anmenaga Jun 21, 2023
3d5901c
Updated tests 8
anmenaga Jun 21, 2023
75e70cf
Added test resources
anmenaga Jun 21, 2023
f28d001
Added powershellgroup.resource.tests
anmenaga Jun 21, 2023
eb1f713
Fixed test failures
anmenaga Jun 21, 2023
e5c04bc
Updated config tests
anmenaga Jun 21, 2023
cbf5edc
Updated config tests 1
anmenaga Jun 21, 2023
591d013
Updated test setup
anmenaga Jun 21, 2023
df5d3d6
Updated test setup
anmenaga Jun 21, 2023
749342d
Updated test setup 3
anmenaga Jun 21, 2023
d183e98
Updated build.ps1 per feedback
anmenaga Jun 27, 2023
7716e70
Merge branch 'main' into PSGroupResource1
anmenaga Jun 27, 2023
724d443
Updated build.ps1 per feedback 2
anmenaga Jun 27, 2023
1e31b35
Merge branch 'PSGroupResource1' of https://github.com/PowerShell/DSCv…
anmenaga Jun 27, 2023
27cac44
Updated build.ps1 per feedback 2
anmenaga Jun 27, 2023
912bb3f
Feedback 3
anmenaga Jun 30, 2023
8bca1c3
Feedback 4
anmenaga Jul 4, 2023
8d0feb1
Feedback 5
anmenaga Jul 4, 2023
51f88ea
Feedback 6
anmenaga Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 65 additions & 14 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ else {
}

$windows_projects = @("pal", "ntreg", "ntstatuserror", "ntuserinfo", "registry")
$projects = @("dsc_lib", "dsc", "osinfo", "test_group_resource", "y2j")
$projects = @("dsc_lib", "dsc", "osinfo", "test_group_resource", "y2j", "powershellgroup")
$pedantic_clean_projects = @("dsc_lib", "dsc", "osinfo", "y2j", "pal", "ntstatuserror", "ntuserinfo", "test_group_resource", "sshdconfig")

if ($IsWindows) {
Expand All @@ -103,19 +103,23 @@ foreach ($project in $projects) {
Write-Host -ForegroundColor Cyan "Building $project ..."
try {
Push-Location "$PSScriptRoot/$project" -ErrorAction Stop
if ($Clippy) {
if ($pedantic_clean_projects -contains $project) {
Write-Verbose -Verbose "Running clippy with pedantic for $project"
cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic

if (Test-Path "./Cargo.toml")
{
if ($Clippy) {
if ($pedantic_clean_projcets -contains $project) {
Write-Verbose -Verbose "Running clippy with pedantic for $project"
cargo clippy @flags --% -- -Dwarnings -Dclippy::pedantic
}
else {
Write-Verbose -Verbose "Running clippy for $project"
cargo clippy @flags -- -Dwarnings
}
}
else {
Write-Verbose -Verbose "Running clippy for $project"
cargo clippy @flags -- -Dwarnings
cargo build @flags
}
}
else {
cargo build @flags
}

if ($LASTEXITCODE -ne 0) {
$failed = $true
Expand All @@ -129,6 +133,7 @@ foreach ($project in $projects) {
}

Copy-Item "*.resource.json" $target -Force -ErrorAction Ignore
Copy-Item "*.resource.ps1" $target -Force -ErrorAction Ignore
Copy-Item "*.command.json" $target -Force -ErrorAction Ignore

} finally {
Expand Down Expand Up @@ -169,15 +174,38 @@ if (!$found) {

if ($Test) {
$failed = $false

$FullyQualifiedName = @{ModuleName="PSDesiredStateConfiguration";ModuleVersion="2.0.7"}
if (-not(Get-Module -ListAvailable -FullyQualifiedName $FullyQualifiedName))
{ "Installing module PSDesiredStateConfiguration 2.0.7"
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Module PSDesiredStateConfiguration -RequiredVersion 2.0.7
}

if (-not(Get-Module -ListAvailable -Name Pester))
{ "Installing module Pester"
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Module Pester -WarningAction Ignore
}

"For debug - env:PATH is:"
$env:PATH

foreach ($project in $projects) {
## Build format_json
Write-Host -ForegroundColor Cyan "Testing $project ..."
try {
Push-Location "$PSScriptRoot/$project"
cargo test

if ($LASTEXITCODE -ne 0) {
$failed = $true
if (Test-Path "./Cargo.toml")
{
if (Test-Path "./Cargo.toml")
{
cargo test

if ($LASTEXITCODE -ne 0) {
$failed = $true
}
}
}
} finally {
Pop-Location
Expand All @@ -188,6 +216,29 @@ if ($Test) {
throw "Test failed"
}

"PSModulePath is:"
$env:PSModulePath
"Pester module located in:"
(Get-Module -Name Pester -ListAvailable).Path

# On Windows disable duplicated WinPS resources that break PSDesiredStateConfiguration module
anmenaga marked this conversation as resolved.
Show resolved Hide resolved
if ($IsWindows) {
$a = $env:PSModulePath -split ";" | ? { $_ -notmatch 'WindowsPowerShell' }
$env:PSModulePath = $a -join ';'

"Updated PSModulePath is:"
$env:PSModulePath

if (-not(Get-Module -ListAvailable -Name Pester))
{ "Installing module Pester"
$InstallTargetDir = ($env:PSModulePath -split ";")[0]
Find-Module -Name 'Pester' -Repository 'PSGallery' | Save-Module -Path $InstallTargetDir
}

"Updated Pester module location:"
(Get-Module -Name Pester -ListAvailable).Path
}

Invoke-Pester -ErrorAction Stop
}

Expand Down
39 changes: 14 additions & 25 deletions dsc/examples/powershell.dsc.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
# Example on how concurrency would be defined in the configuration.
# Example configuration mixing native app resources with classic PS resources
$schema: https://schemas.microsoft.com/dsc/2023/03/configuration.schema.json
resources:
- name: PS7
type: DSC/PowerShell
- name: Use class PowerShell resources
type: DSC/PowerShellGroup
properties:
resources:
- name: psgallery
type: Microsoft.PowerShell.PSGallery/PSGallery
- name: OpenSSH service
type: PsDesiredStateConfiguration/MSFT_ServiceResource
properties:
name: foo
url: http://bar
- name: my file
type: xFile/File
Name: sshd
- name: Administrator
type: PsDesiredStateConfiguration/MSFT_UserResource
properties:
path: xyz
content: hello world
- name: WinPS
type: DSC/WindowsPowerShell
UserName: administrator
- name: current user registry
type: Microsoft.Windows/Registry
properties:
resources:
- name: psgallery
type: Microsoft.PowerShell.PSGallery/PSGallery
properties:
name: foo
url: http://bar
- name: my file
type: xFile/File
properties:
path: xyz
content: hello world

keyPath: HKLM\Software\Microsoft\Windows NT\CurrentVersion
valueName: ProductName
_ensure: Present
Loading