Skip to content

Commit a7954f5

Browse files
authored
Merge pull request #92 from PlagueHO/Issue-87-and-88
Fix BOM, Optin to Common Tests, Fix License Year, Add VSCode Styles - Fixes 87
2 parents 1bbbf03 + c1eb1b3 commit a7954f5

10 files changed

Lines changed: 104 additions & 44 deletions

.MetaTestOptIn.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[
22
"Common Tests - Validate Markdown Files",
3-
"Common Tests - Validate Example Files"
3+
"Common Tests - Validate Example Files",
4+
"Common Tests - Validate Module Files",
5+
"Common Tests - Validate Script Files"
46
]

.github/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
If you'd like to contribute to this project, please review the [Contribution Guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md).

.github/ISSUE_TEMPLATE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
Your feedback and support is greatly appreciated, thanks for contributing!
3+
4+
Please prefix the issue title with the resource name, i.e. 'xComputer: Short description of my issue'
5+
Please provide the following information regarding your issue (place N/A if the fields that don't apply to your issue):
6+
-->
7+
**Details of the scenario you tried and the problem that is occurring:**
8+
9+
**The DSC configuration that is using the resource (as detailed as possible):**
10+
11+
**Version of the Operating System and PowerShell the DSC Target Node is running:**
12+
13+
**Version of the DSC module you're using, or 'dev' if you're using current dev branch:**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!--
2+
Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated!
3+
4+
Please prefix the PR title with the resource name, i.e. 'xComputer: My short description'
5+
If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:', i.e. 'BREAKING CHANGE: xComputer: My short description'
6+
7+
To aid community reviewers in reviewing and merging your PR, please take the time to run through the below checklist.
8+
Change to [x] for each task in the task list that applies to this PR.
9+
-->
10+
**Pull Request (PR) description**
11+
<!-- Replace this with a description of your pull request -->
12+
13+
**This Pull Request (PR) fixes the following issues:**
14+
<!-- Replace this with the list of issues or n/a. Use format: Fixes #123 -->
15+
16+
**Task list:**
17+
- [ ] Change details added to Unreleased section of CHANGELOG.md?
18+
- [ ] Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
19+
- [ ] Examples appropriately updated?
20+
- [ ] New/changed code adheres to [Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md)?
21+
- [ ] [Unit and (optional) Integration tests](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md) created/updated where possible?

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"powershell.codeFormatting.openBraceOnSameLine": false,
4+
"powershell.codeFormatting.newLineAfterOpenBrace": false,
5+
"powershell.codeFormatting.newLineAfterCloseBrace": true,
6+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
7+
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
8+
"powershell.codeFormatting.whitespaceAroundOperator": true,
9+
"powershell.codeFormatting.whitespaceAfterSeparator": true,
10+
"powershell.codeFormatting.ignoreOneLineBlock": false,
11+
"powershell.codeFormatting.preset": "Custom",
12+
"files.trimTrailingWhitespace": true,
13+
"files.insertFinalNewline": true
14+
}

DSCResources/CommonResourceHelper.psm1

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
Retrieves the localized string data based on the machine's culture.
44
Falls back to en-US strings if the machine's culture is not supported.
@@ -87,25 +87,25 @@ function Test-DscParameterState
8787
[CmdletBinding()]
8888
param
8989
(
90-
[Parameter(Mandatory = $true)]
90+
[Parameter(Mandatory = $true)]
9191
[hashtable]
9292
$CurrentValues,
9393

94-
[Parameter(Mandatory = $true)]
94+
[Parameter(Mandatory = $true)]
9595
[object]
9696
$DesiredValues,
97-
97+
9898
[string[]]
9999
$ValuesToCheck,
100-
100+
101101
[switch]
102102
$TurnOffTypeChecking
103103
)
104104

105105
$returnValue = $true
106106

107107
$types = 'System.Management.Automation.PSBoundParametersDictionary', 'System.Collections.Hashtable', 'Microsoft.Management.Infrastructure.CimInstance'
108-
108+
109109
if ($DesiredValues.GetType().FullName -notin $types)
110110
{
111111
throw ("Property 'DesiredValues' in Test-DscParameterState must be either a Hashtable or CimInstance. Type detected was $($DesiredValues.GetType().FullName)")
@@ -115,13 +115,13 @@ function Test-DscParameterState
115115
{
116116
throw ("If 'DesiredValues' is a CimInstance then property 'ValuesToCheck' must contain a value")
117117
}
118-
118+
119119
$desiredValuesClean = Remove-CommonParameter -Hashtable $DesiredValues
120120

121121
if (-not $ValuesToCheck)
122122
{
123123
$keyList = $desiredValuesClean.Keys
124-
}
124+
}
125125
else
126126
{
127127
$keyList = $ValuesToCheck
@@ -135,19 +135,19 @@ function Test-DscParameterState
135135
}
136136
else
137137
{
138-
$desiredType = [psobject]@{
139-
Name = 'Unknown'
138+
$desiredType = [psobject]@{
139+
Name = 'Unknown'
140140
}
141141
}
142-
142+
143143
if ($null -ne $CurrentValues.$key)
144144
{
145145
$currentType = $CurrentValues.$key.GetType()
146146
}
147147
else
148148
{
149-
$currentType = [psobject]@{
150-
Name = 'Unknown'
149+
$currentType = [psobject]@{
150+
Name = 'Unknown'
151151
}
152152
}
153153

@@ -164,7 +164,7 @@ function Test-DscParameterState
164164
Write-Verbose -Message ('NOTMATCH: PSCredential username mismatch. Current state is {0} and desired state is {1}' -f $CurrentValues.$key.UserName, $desiredValuesClean.$key.UserName)
165165
$returnValue = $false
166166
}
167-
167+
168168
# Assume the string is our username when the matching desired value is actually a credential
169169
if ($currentType.Name -eq 'string' -and $CurrentValues.$key -eq $desiredValuesClean.$key.UserName)
170170
{
@@ -177,10 +177,10 @@ function Test-DscParameterState
177177
$returnValue = $false
178178
}
179179
}
180-
180+
181181
if (-not $TurnOffTypeChecking)
182-
{
183-
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
182+
{
183+
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
184184
$desiredType.FullName -ne $currentType.FullName)
185185
{
186186
Write-Verbose -Message "NOTMATCH: Type mismatch for property '$key' Current state type is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
@@ -193,22 +193,22 @@ function Test-DscParameterState
193193
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
194194
continue
195195
}
196-
196+
197197
if ($desiredValuesClean.GetType().Name -in 'HashTable', 'PSBoundParametersDictionary')
198198
{
199199
$checkDesiredValue = $desiredValuesClean.ContainsKey($key)
200-
}
200+
}
201201
else
202202
{
203203
$checkDesiredValue = Test-DSCObjectHasProperty -Object $desiredValuesClean -PropertyName $key
204204
}
205-
205+
206206
if (-not $checkDesiredValue)
207207
{
208208
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
209209
continue
210210
}
211-
211+
212212
if ($desiredType.IsArray)
213213
{
214214
Write-Verbose -Message "Comparing values in property '$key'"
@@ -237,33 +237,33 @@ function Test-DscParameterState
237237
}
238238
else
239239
{
240-
$desiredType = [psobject]@{
240+
$desiredType = [psobject]@{
241241
Name = 'Unknown'
242242
}
243243
}
244-
244+
245245
if ($null -ne $currentArrayValues[$i])
246246
{
247247
$currentType = $currentArrayValues[$i].GetType()
248248
}
249249
else
250250
{
251251
$currentType = [psobject]@{
252-
Name = 'Unknown'
252+
Name = 'Unknown'
253253
}
254254
}
255-
255+
256256
if (-not $TurnOffTypeChecking)
257257
{
258-
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
258+
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
259259
$desiredType.FullName -ne $currentType.FullName)
260260
{
261261
Write-Verbose -Message "`tNOTMATCH: Type mismatch for property '$key' Current state type of element [$i] is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
262262
$returnValue = $false
263263
continue
264264
}
265265
}
266-
266+
267267
if ($desiredArrayValues[$i] -ne $currentArrayValues[$i])
268268
{
269269
Write-Verbose -Message "`tNOTMATCH: Value [$i] (type $($desiredType.Name)) for property '$key' does match. Current state is '$($currentArrayValues[$i])' and desired state is '$($desiredArrayValues[$i])'"
@@ -276,20 +276,20 @@ function Test-DscParameterState
276276
continue
277277
}
278278
}
279-
279+
280280
}
281-
}
282-
else
281+
}
282+
else
283283
{
284284
if ($desiredValuesClean.$key -ne $CurrentValues.$key)
285285
{
286286
Write-Verbose -Message "NOTMATCH: Value (type $($desiredType.Name)) for property '$key' does not match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
287287
$returnValue = $false
288288
}
289-
290-
}
289+
290+
}
291291
}
292-
292+
293293
Write-Verbose -Message "Result is '$returnValue'"
294294
return $returnValue
295295
}
@@ -308,7 +308,7 @@ function Test-DSCObjectHasProperty
308308
[OutputType([bool])]
309309
param
310310
(
311-
[Parameter(Mandatory = $true)]
311+
[Parameter(Mandatory = $true)]
312312
[object]
313313
$Object,
314314

@@ -317,11 +317,11 @@ function Test-DSCObjectHasProperty
317317
$PropertyName
318318
)
319319

320-
if ($Object.PSObject.Properties.Name -contains $PropertyName)
320+
if ($Object.PSObject.Properties.Name -contains $PropertyName)
321321
{
322322
return [bool] $Object.$PropertyName
323323
}
324-
324+
325325
return $false
326326
}
327327

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Microsoft Corporation.
3+
Copyright (c) 2017 Microsoft Corporation.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ xVirtualMemory has the following properties:
212212
* Change examples to meet HQRM standards and optin to Example validation
213213
tests.
214214
* Replaced examples in README.MD to links to Example files.
215+
* Added the VS Code PowerShell extension formatting settings that cause PowerShell
216+
files to be formatted as per the DSC Resource kit style guidelines - [Issue #91](https://github.com/PowerShell/xComputerManagement/issues/91).
217+
* Opted into Common Tests 'Validate Module Files' and 'Validate Script Files'.
218+
* Converted files with UTF8 with BOM over to UTF8 - fixes [Issue #90](https://github.com/PowerShell/xComputerManagement/issues/90).
219+
* Updated Year to 2017 in License and Manifest - fixes [Issue #87](https://github.com/PowerShell/xComputerManagement/issues/87).
220+
* Added .github support files - fixes [Issue #88](https://github.com/PowerShell/xComputerManagement/issues/88):
221+
* CONTRIBUTING.md
222+
* ISSUE_TEMPLATE.md
223+
* PULL_REQUEST_TEMPLATE.md
215224

216225
### 2.0.0.0
217226

Tests/Unit/MSFT_xComputer.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$Global:DSCModuleName = 'xComputerManagement'
1+
$Global:DSCModuleName = 'xComputerManagement'
22
$Global:DSCResourceName = 'MSFT_xComputer'
33

44
#region HEADER
@@ -16,7 +16,7 @@ Import-Module (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Tests\TestHel
1616
$TestEnvironment = Initialize-TestEnvironment `
1717
-DSCModuleName $Global:DSCModuleName `
1818
-DSCResourceName $Global:DSCResourceName `
19-
-TestType Unit
19+
-TestType Unit
2020
#endregion
2121

2222
# Begin Testing
@@ -31,7 +31,7 @@ try
3131
$SecPassword = New-Object -Type SecureString
3232
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'USER',$SecPassword
3333
$NotComputerName = if($env:COMPUTERNAME -ne 'othername'){'othername'}else{'name'}
34-
34+
3535
Context "$($Global:DSCResourceName)\Test-TargetResource" {
3636
Mock Get-WMIObject {[PSCustomObject]@{DomainName = 'ContosoLtd'}} -ParameterFilter {$Class -eq 'Win32_NTDomain'}
3737
It 'Throws if both DomainName and WorkGroupName are specified' {
@@ -121,7 +121,7 @@ try
121121
It 'Should not Throw if name is localhost' {
122122
{Test-TargetResource -Name "localhost"} | Should Not Throw
123123
}
124-
124+
125125
}
126126
Context "$($Global:DSCResourceName)\Get-TargetResource" {
127127
It 'should not throw' {

xComputerManagement.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Author = 'Microsoft Corporation'
1212
CompanyName = 'Microsoft Corporation'
1313

1414
# Copyright statement for this module
15-
Copyright = '(c) 2014 Microsoft Corporation. All rights reserved.'
15+
Copyright = '(c) 2017 Microsoft Corporation. All rights reserved.'
1616

1717
# Description of the functionality provided by this module
1818
Description = 'The xComputerManagement module is originally part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit. This version has been modified for use in Azure. This module contains the xComputer and xDisk resources. These DSC Resources allow you to perform computer management tasks, like joining a domain or initializing disks.

0 commit comments

Comments
 (0)