From 9cf510d26d106578eecc5bcddf83ee13b57eabc5 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Fri, 1 Mar 2024 20:28:25 -0800 Subject: [PATCH] rename PowerShell and WMI resources --- build.ps1 | 5 ++--- dsc/examples/powershell.dsc.yaml | 2 +- dsc/tests/dsc_resource_list.tests.ps1 | 2 +- .../TestPSRepository/TestPSRepository.psm1 | 0 .../TestPSRepository/TestPSRepository.schema.mof | 0 .../Tests/PSTestModule/PSTestModule.psd1 | 0 .../Tests/PSTestModule/TestClassResource.psm1 | 0 .../Tests/class_ps_resources.dsc.yaml | 2 +- .../Tests/native_and_powershell.dsc.yaml | 2 +- .../Tests/powershellgroup.config.tests.ps1 | 12 ++++++------ .../Tests/powershellgroup.resource.tests.ps1 | 4 ++-- .../Tests/winps_resource.dsc.yaml | 2 +- powershell-adapter/copy_files.txt | 1 + .../powershell.dsc.resource.json | 14 +++++++------- .../powershell.resource.ps1 | 6 +++--- .../windowspowershell.resource.json_todo | 10 +++++----- powershellgroup/copy_files.txt | 1 - .../Tests/test_wmi_config.dsc.yaml | 2 +- {wmigroup => wmi-adapter}/Tests/wmigroup.tests.ps1 | 2 +- wmi-adapter/copy_files.txt | 2 ++ .../wmi.dsc.resource.json.optout | 8 ++++---- .../wmi.resource.ps1 | 0 wmigroup/copy_files.txt | 2 -- 23 files changed, 39 insertions(+), 40 deletions(-) rename {powershellgroup => powershell-adapter}/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 (100%) rename {powershellgroup => powershell-adapter}/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.schema.mof (100%) rename {powershellgroup => powershell-adapter}/Tests/PSTestModule/PSTestModule.psd1 (100%) rename {powershellgroup => powershell-adapter}/Tests/PSTestModule/TestClassResource.psm1 (100%) rename {powershellgroup => powershell-adapter}/Tests/class_ps_resources.dsc.yaml (92%) rename {powershellgroup => powershell-adapter}/Tests/native_and_powershell.dsc.yaml (96%) rename {powershellgroup => powershell-adapter}/Tests/powershellgroup.config.tests.ps1 (96%) rename {powershellgroup => powershell-adapter}/Tests/powershellgroup.resource.tests.ps1 (97%) rename {powershellgroup => powershell-adapter}/Tests/winps_resource.dsc.yaml (89%) create mode 100644 powershell-adapter/copy_files.txt rename powershellgroup/powershellgroup.dsc.resource.json => powershell-adapter/powershell.dsc.resource.json (81%) rename powershellgroup/powershellgroup.resource.ps1 => powershell-adapter/powershell.resource.ps1 (98%) rename powershellgroup/windowspowershellgroup.resource.json_todo => powershell-adapter/windowspowershell.resource.json_todo (79%) delete mode 100644 powershellgroup/copy_files.txt rename {wmigroup => wmi-adapter}/Tests/test_wmi_config.dsc.yaml (93%) rename {wmigroup => wmi-adapter}/Tests/wmigroup.tests.ps1 (97%) create mode 100644 wmi-adapter/copy_files.txt rename wmigroup/wmigroup.dsc.resource.json.optout => wmi-adapter/wmi.dsc.resource.json.optout (84%) rename wmigroup/wmigroup.resource.ps1 => wmi-adapter/wmi.resource.ps1 (100%) delete mode 100644 wmigroup/copy_files.txt diff --git a/build.ps1 b/build.ps1 index d5290378..a501c1a7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -113,13 +113,12 @@ $projects = @( "file_lib", "dsc", "osinfo", - "powershellgroup", + "powershell-adapter", "process", "tools/dsctest", "tools/test_group_resource", "y2j", - "powershellgroup", - "wmigroup", + "wmi-adapter", "resources/brew" ) $pedantic_unclean_projects = @("ntreg") diff --git a/dsc/examples/powershell.dsc.yaml b/dsc/examples/powershell.dsc.yaml index 83b8ce9a..12483d2c 100644 --- a/dsc/examples/powershell.dsc.yaml +++ b/dsc/examples/powershell.dsc.yaml @@ -2,7 +2,7 @@ $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json resources: - name: Use class PowerShell resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: OpenSSH service diff --git a/dsc/tests/dsc_resource_list.tests.ps1 b/dsc/tests/dsc_resource_list.tests.ps1 index d7cad89b..6daea401 100644 --- a/dsc/tests/dsc_resource_list.tests.ps1 +++ b/dsc/tests/dsc_resource_list.tests.ps1 @@ -13,7 +13,7 @@ Describe 'Tests for listing resources' { $resources.type | Should -Contain 'Microsoft/OSInfo' ($resources | Where-Object { $_.type -eq 'DSC/Group' }).Kind | Should -BeExactly 'Group' ($resources | Where-Object { $_.type -eq 'Microsoft/OSInfo' }).Kind | Should -BeExactly 'Resource' - ($resources | Where-Object { $_.type -eq 'DSC/PowerShellGroup' }).Kind | Should -BeExactly 'Adapter' + ($resources | Where-Object { $_.type -eq 'Microsoft.DSC/PowerShell' }).Kind | Should -BeExactly 'Adapter' } It 'dsc resource list --tags "" and --description " work' -TestCases @( diff --git a/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 b/powershell-adapter/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 similarity index 100% rename from powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 rename to powershell-adapter/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.psm1 diff --git a/powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.schema.mof b/powershell-adapter/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.schema.mof similarity index 100% rename from powershellgroup/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.schema.mof rename to powershell-adapter/Tests/PSTestModule/DscResources/TestPSRepository/TestPSRepository.schema.mof diff --git a/powershellgroup/Tests/PSTestModule/PSTestModule.psd1 b/powershell-adapter/Tests/PSTestModule/PSTestModule.psd1 similarity index 100% rename from powershellgroup/Tests/PSTestModule/PSTestModule.psd1 rename to powershell-adapter/Tests/PSTestModule/PSTestModule.psd1 diff --git a/powershellgroup/Tests/PSTestModule/TestClassResource.psm1 b/powershell-adapter/Tests/PSTestModule/TestClassResource.psm1 similarity index 100% rename from powershellgroup/Tests/PSTestModule/TestClassResource.psm1 rename to powershell-adapter/Tests/PSTestModule/TestClassResource.psm1 diff --git a/powershellgroup/Tests/class_ps_resources.dsc.yaml b/powershell-adapter/Tests/class_ps_resources.dsc.yaml similarity index 92% rename from powershellgroup/Tests/class_ps_resources.dsc.yaml rename to powershell-adapter/Tests/class_ps_resources.dsc.yaml index fa601440..8eb72c44 100644 --- a/powershellgroup/Tests/class_ps_resources.dsc.yaml +++ b/powershell-adapter/Tests/class_ps_resources.dsc.yaml @@ -1,7 +1,7 @@ $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Working with classic DSC resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: Repository Info diff --git a/powershellgroup/Tests/native_and_powershell.dsc.yaml b/powershell-adapter/Tests/native_and_powershell.dsc.yaml similarity index 96% rename from powershellgroup/Tests/native_and_powershell.dsc.yaml rename to powershell-adapter/Tests/native_and_powershell.dsc.yaml index 3b0b6d7c..e99936b0 100644 --- a/powershellgroup/Tests/native_and_powershell.dsc.yaml +++ b/powershell-adapter/Tests/native_and_powershell.dsc.yaml @@ -2,7 +2,7 @@ $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Get info from classic DSC resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: Get PS Repository Info diff --git a/powershellgroup/Tests/powershellgroup.config.tests.ps1 b/powershell-adapter/Tests/powershellgroup.config.tests.ps1 similarity index 96% rename from powershellgroup/Tests/powershellgroup.config.tests.ps1 rename to powershell-adapter/Tests/powershellgroup.config.tests.ps1 index cb67c147..6a775029 100644 --- a/powershellgroup/Tests/powershellgroup.config.tests.ps1 +++ b/powershell-adapter/Tests/powershellgroup.config.tests.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe 'PowerShellGroup resource tests' { +Describe 'PowerShell adapter resource tests' { BeforeAll { $OldPSModulePath = $env:PSModulePath @@ -46,7 +46,7 @@ Describe 'PowerShellGroup resource tests' { $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Working with class-based resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: Class-resource Info @@ -67,13 +67,13 @@ Describe 'PowerShellGroup resource tests' { $OldPSModulePath = $env:PSModulePath Copy-Item -Recurse -Force -Path "$PSScriptRoot/PSTestModule" -Destination $TestDrive Rename-Item -Path "$PSScriptRoot/PSTestModule" -NewName "_PSTestModule" - + try { $yaml = @" `$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Working with class-based resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: psmodulepath: `$env:PSModulePath;$TestDrive resources: @@ -101,7 +101,7 @@ Describe 'PowerShellGroup resource tests' { `$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Working with class-based resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: Class-resource Info @@ -126,7 +126,7 @@ Describe 'PowerShellGroup resource tests' { `$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Working with class-based resources - type: DSC/PowerShellGroup + type: Microsoft.DSC/PowerShell properties: resources: - name: Class-resource Info diff --git a/powershellgroup/Tests/powershellgroup.resource.tests.ps1 b/powershell-adapter/Tests/powershellgroup.resource.tests.ps1 similarity index 97% rename from powershellgroup/Tests/powershellgroup.resource.tests.ps1 rename to powershell-adapter/Tests/powershellgroup.resource.tests.ps1 index 9ce6956a..5c7f0ea4 100644 --- a/powershellgroup/Tests/powershellgroup.resource.tests.ps1 +++ b/powershell-adapter/Tests/powershellgroup.resource.tests.ps1 @@ -1,11 +1,11 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe 'PowerShellGroup resource tests' { +Describe 'PowerShell adapter resource tests' { BeforeAll { $OldPSModulePath = $env:PSModulePath - $env:PSModulePath += ";" + $PSScriptRoot + $env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot } AfterAll { $env:PSModulePath = $OldPSModulePath diff --git a/powershellgroup/Tests/winps_resource.dsc.yaml b/powershell-adapter/Tests/winps_resource.dsc.yaml similarity index 89% rename from powershellgroup/Tests/winps_resource.dsc.yaml rename to powershell-adapter/Tests/winps_resource.dsc.yaml index ab5266fe..c4e04473 100644 --- a/powershellgroup/Tests/winps_resource.dsc.yaml +++ b/powershell-adapter/Tests/winps_resource.dsc.yaml @@ -2,7 +2,7 @@ $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Get info from classic DSC resources - type: DSC/WindowsPowerShellGroup + type: Microsoft.Windows/WindowsPowerShell properties: resources: - name: Get Info diff --git a/powershell-adapter/copy_files.txt b/powershell-adapter/copy_files.txt new file mode 100644 index 00000000..141bc529 --- /dev/null +++ b/powershell-adapter/copy_files.txt @@ -0,0 +1 @@ +powershell.resource.ps1 diff --git a/powershellgroup/powershellgroup.dsc.resource.json b/powershell-adapter/powershell.dsc.resource.json similarity index 81% rename from powershellgroup/powershellgroup.dsc.resource.json rename to powershell-adapter/powershell.dsc.resource.json index 7f9f9e22..c544640a 100644 --- a/powershellgroup/powershellgroup.dsc.resource.json +++ b/powershell-adapter/powershell.dsc.resource.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", - "type": "DSC/PowerShellGroup", + "type": "Microsoft.DSC/PowerShell", "version": "0.1.0", "description": "Resource adapter to classic DSC Powershell resources.", "tags": [ @@ -14,7 +14,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "./powershellgroup.resource.ps1 List" + "./powershell.resource.ps1 List" ] }, "config": "full" @@ -26,7 +26,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 Get" + "$Input | ./powershell.resource.ps1 Get" ], "input": "stdin" }, @@ -37,7 +37,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 Set" + "$Input | ./powershell.resource.ps1 Set" ], "input": "stdin", "implementsPretest": true, @@ -50,7 +50,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 Test" + "$Input | ./powershell.resource.ps1 Test" ], "input": "stdin", "return": "state" @@ -62,7 +62,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 Export" + "$Input | ./powershell.resource.ps1 Export" ], "input": "stdin", "return": "state" @@ -74,7 +74,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 Validate" + "$Input | ./powershell.resource.ps1 Validate" ] }, "exitCodes": { diff --git a/powershellgroup/powershellgroup.resource.ps1 b/powershell-adapter/powershell.resource.ps1 similarity index 98% rename from powershellgroup/powershellgroup.resource.ps1 rename to powershell-adapter/powershell.resource.ps1 index afa8f8c3..54b211a7 100644 --- a/powershellgroup/powershellgroup.resource.ps1 +++ b/powershell-adapter/powershell.resource.ps1 @@ -36,7 +36,7 @@ function RefreshCache if (($PSVersionTable.PSVersion.Major -eq 7) -and ($PSVersionTable.PSVersion.Minor -eq 4) ` -and ($PSVersionTable.PSVersion.PreReleaseLabel.StartsWith("preview"))) { - throw "PowerShell 7.4-previews are not supported by PowerShellGroup resource; please use PS 7.4.0-rc.1 or newer." + throw "PowerShell 7.4-previews are not supported by PowerShell adapter resource; please use PS 7.4.0-rc.1 or newer." } $inputobj_pscustomobj = $null @@ -98,7 +98,7 @@ if ($Operation -eq 'List') $fullResourceTypeName = "$moduleName/$($r.ResourceType)" $script:ResourceCache[$fullResourceTypeName] = $r - if ($WinPS) {$requiresString = "DSC/WindowsPowerShellGroup"} else {$requiresString = "DSC/PowerShellGroup"} + if ($WinPS) {$requiresString = "Microsoft.Windows/WindowsPowerShell"} else {$requiresString = "Microsoft.DSC/PowerShell"} $z = [pscustomobject]@{ type = $fullResourceTypeName; @@ -396,5 +396,5 @@ elseif ($Operation -eq 'Validate') } else { - "ERROR: Unsupported operation requested from powershellgroup.resource.ps1" + "ERROR: Unsupported operation requested from powershell.resource.ps1" } \ No newline at end of file diff --git a/powershellgroup/windowspowershellgroup.resource.json_todo b/powershell-adapter/windowspowershell.resource.json_todo similarity index 79% rename from powershellgroup/windowspowershellgroup.resource.json_todo rename to powershell-adapter/windowspowershell.resource.json_todo index d7828e13..78e93e23 100644 --- a/powershellgroup/windowspowershellgroup.resource.json_todo +++ b/powershell-adapter/windowspowershell.resource.json_todo @@ -1,6 +1,6 @@ { "manifestVersion": "1.0", - "type": "DSC/WindowsPowerShellGroup", + "type": "Microsoft.Windows/WindowsPowerShell", "version": "0.1.0", "description": "Resource adapter to classic DSC Powershell resources in Windows PowerShell.", "adapter": { @@ -11,7 +11,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "./powershellgroup.resource.ps1 -WinPS List" + "./powershell.resource.ps1 -WinPS List" ] }, "config": "full" @@ -23,7 +23,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 -WinPS Get" + "$Input | ./powershell.resource.ps1 -WinPS Get" ] }, "set": { @@ -33,7 +33,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 -WinPS Set" + "$Input | ./powershell.resource.ps1 -WinPS Set" ], "input": "stdin", "preTest": true, @@ -46,7 +46,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./powershellgroup.resource.ps1 -WinPS Test" + "$Input | ./powershell.resource.ps1 -WinPS Test" ], "input": "stdin", "return": "state" diff --git a/powershellgroup/copy_files.txt b/powershellgroup/copy_files.txt deleted file mode 100644 index 2b642cb3..00000000 --- a/powershellgroup/copy_files.txt +++ /dev/null @@ -1 +0,0 @@ -powershellgroup.resource.ps1 diff --git a/wmigroup/Tests/test_wmi_config.dsc.yaml b/wmi-adapter/Tests/test_wmi_config.dsc.yaml similarity index 93% rename from wmigroup/Tests/test_wmi_config.dsc.yaml rename to wmi-adapter/Tests/test_wmi_config.dsc.yaml index 3bac984f..2907c4c5 100644 --- a/wmigroup/Tests/test_wmi_config.dsc.yaml +++ b/wmi-adapter/Tests/test_wmi_config.dsc.yaml @@ -2,7 +2,7 @@ $schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json resources: - name: Get info from WMI - type: DSC/WMIGroup + type: Microsoft.Windows/WMI properties: resources: - name: Get OS Info diff --git a/wmigroup/Tests/wmigroup.tests.ps1 b/wmi-adapter/Tests/wmigroup.tests.ps1 similarity index 97% rename from wmigroup/Tests/wmigroup.tests.ps1 rename to wmi-adapter/Tests/wmigroup.tests.ps1 index aa940deb..ef009961 100644 --- a/wmigroup/Tests/wmigroup.tests.ps1 +++ b/wmi-adapter/Tests/wmigroup.tests.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe 'PowerShellGroup resource tests' { +Describe 'WMI adapter resource tests' { BeforeAll { if ($IsWindows) diff --git a/wmi-adapter/copy_files.txt b/wmi-adapter/copy_files.txt new file mode 100644 index 00000000..be7f7e31 --- /dev/null +++ b/wmi-adapter/copy_files.txt @@ -0,0 +1,2 @@ +wmi.resource.ps1 +wmi.dsc.resource.json.optout \ No newline at end of file diff --git a/wmigroup/wmigroup.dsc.resource.json.optout b/wmi-adapter/wmi.dsc.resource.json.optout similarity index 84% rename from wmigroup/wmigroup.dsc.resource.json.optout rename to wmi-adapter/wmi.dsc.resource.json.optout index 90fa32a3..d41a8440 100644 --- a/wmigroup/wmigroup.dsc.resource.json.optout +++ b/wmi-adapter/wmi.dsc.resource.json.optout @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/bundled/resource/manifest.json", - "type": "DSC/WMIGroup", + "type": "Microsoft.Windows/WMI", "version": "0.1.0", "description": "Resource adapter to WMI resources.", "tags": [ @@ -14,7 +14,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "./wmigroup.resource.ps1 List" + "./wmi.resource.ps1 List" ] }, "config": "full" @@ -26,7 +26,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./wmigroup.resource.ps1 Get" + "$Input | ./wmi.resource.ps1 Get" ], "input": "stdin" }, @@ -37,7 +37,7 @@ "-NonInteractive", "-NoProfile", "-Command", - "$Input | ./wmigroup.resource.ps1 Validate" + "$Input | ./wmi.resource.ps1 Validate" ] }, "exitCodes": { diff --git a/wmigroup/wmigroup.resource.ps1 b/wmi-adapter/wmi.resource.ps1 similarity index 100% rename from wmigroup/wmigroup.resource.ps1 rename to wmi-adapter/wmi.resource.ps1 diff --git a/wmigroup/copy_files.txt b/wmigroup/copy_files.txt deleted file mode 100644 index b00f55c8..00000000 --- a/wmigroup/copy_files.txt +++ /dev/null @@ -1,2 +0,0 @@ -wmigroup.resource.ps1 -wmigroup.dsc.resource.json.optout \ No newline at end of file