Skip to content

Commit

Permalink
Merge pull request #97 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 2.1.0.0 of xComputerManagement
  • Loading branch information
kwirkykat authored Aug 23, 2017
2 parents e14f337 + 07660e8 commit 0c894a0
Show file tree
Hide file tree
Showing 33 changed files with 1,544 additions and 1,214 deletions.
6 changes: 6 additions & 0 deletions .MetaTestOptIn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"Common Tests - Validate Markdown Files",
"Common Tests - Validate Example Files",
"Common Tests - Validate Module Files",
"Common Tests - Validate Script Files"
]
26 changes: 26 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
codecov:
notify:
require_ci_to_pass: no
# dev should be the baseline for reporting
branch: dev

comment:
layout: "reach, diff"
behavior: default

coverage:
range: 50..80
round: down
precision: 0

status:
project:
default:
# Set the overall project code coverage requirement to 70%
target: 70
patch:
default:
# Set the pull request requirement to not regress overall coverage by more than 5%
# and let codecov.io set the goal for the code changed in the patch.
target: auto
threshold: 5
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If you'd like to contribute to this project, please review the [Contribution Guidelines](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md).
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--
Your feedback and support is greatly appreciated, thanks for contributing!
Please prefix the issue title with the resource name, i.e. 'xComputer: Short description of my issue'
Please provide the following information regarding your issue (place N/A if the fields that don't apply to your issue):
-->
**Details of the scenario you tried and the problem that is occurring:**

**The DSC configuration that is using the resource (as detailed as possible):**

**Version of the Operating System and PowerShell the DSC Target Node is running:**

**Version of the DSC module you're using, or 'dev' if you're using current dev branch:**
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project is greatly appreciated!
Please prefix the PR title with the resource name, i.e. 'xComputer: My short description'
If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:', i.e. 'BREAKING CHANGE: xComputer: My short description'
To aid community reviewers in reviewing and merging your PR, please take the time to run through the below checklist.
Change to [x] for each task in the task list that applies to this PR.
-->
**Pull Request (PR) description**
<!-- Replace this with a description of your pull request -->

**This Pull Request (PR) fixes the following issues:**
<!-- Replace this with the list of issues or n/a. Use format: Fixes #123 -->

**Task list:**
- [ ] Change details added to Unreleased section of CHANGELOG.md?
- [ ] Added/updated documentation, comment-based help and descriptions in .schema.mof files where appropriate?
- [ ] Examples appropriately updated?
- [ ] New/changed code adheres to [Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md)?
- [ ] [Unit and (optional) Integration tests](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md) created/updated where possible?
10 changes: 10 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": true,
"MD029": {
"style": "one"
},
"MD013": true,
"MD024": true,
"MD034": true,
"no-hard-tabs": true
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Place your settings in this file to overwrite default and user settings.
{
"powershell.codeFormatting.openBraceOnSameLine": false,
"powershell.codeFormatting.newLineAfterOpenBrace": false,
"powershell.codeFormatting.newLineAfterCloseBrace": true,
"powershell.codeFormatting.whitespaceBeforeOpenBrace": true,
"powershell.codeFormatting.whitespaceBeforeOpenParen": true,
"powershell.codeFormatting.whitespaceAroundOperator": true,
"powershell.codeFormatting.whitespaceAfterSeparator": true,
"powershell.codeFormatting.ignoreOneLineBlock": false,
"powershell.codeFormatting.preset": "Custom",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}
82 changes: 43 additions & 39 deletions DSCResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#
<#
.SYNOPSIS
Retrieves the localized string data based on the machine's culture.
Falls back to en-US strings if the machine's culture is not supported.
Expand Down Expand Up @@ -48,12 +48,12 @@ function Get-LocalizedData
#>
function Remove-CommonParameter
{
[OutputType([hashtable])]
[OutputType([System.Collections.Hashtable])]
[cmdletbinding()]
param
(
[Parameter(Mandatory = $true)]
[hashtable]
[System.Collections.Hashtable]
$Hashtable
)

Expand Down Expand Up @@ -87,25 +87,27 @@ function Test-DscParameterState
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[hashtable]
[Parameter(Mandatory = $true)]
[System.Collections.Hashtable]
$CurrentValues,

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[object]
$DesiredValues,


[Parameter()]
[string[]]
$ValuesToCheck,


[Parameter()]
[switch]
$TurnOffTypeChecking
)

$returnValue = $true

$types = 'System.Management.Automation.PSBoundParametersDictionary', 'System.Collections.Hashtable', 'Microsoft.Management.Infrastructure.CimInstance'

if ($DesiredValues.GetType().FullName -notin $types)
{
throw ("Property 'DesiredValues' in Test-DscParameterState must be either a Hashtable or CimInstance. Type detected was $($DesiredValues.GetType().FullName)")
Expand All @@ -115,13 +117,13 @@ function Test-DscParameterState
{
throw ("If 'DesiredValues' is a CimInstance then property 'ValuesToCheck' must contain a value")
}

$desiredValuesClean = Remove-CommonParameter -Hashtable $DesiredValues

if (-not $ValuesToCheck)
{
$keyList = $desiredValuesClean.Keys
}
}
else
{
$keyList = $ValuesToCheck
Expand All @@ -135,19 +137,19 @@ function Test-DscParameterState
}
else
{
$desiredType = [psobject]@{
Name = 'Unknown'
$desiredType = [psobject]@{
Name = 'Unknown'
}
}

if ($null -ne $CurrentValues.$key)
{
$currentType = $CurrentValues.$key.GetType()
}
else
{
$currentType = [psobject]@{
Name = 'Unknown'
$currentType = [psobject]@{
Name = 'Unknown'
}
}

Expand All @@ -164,7 +166,7 @@ function Test-DscParameterState
Write-Verbose -Message ('NOTMATCH: PSCredential username mismatch. Current state is {0} and desired state is {1}' -f $CurrentValues.$key.UserName, $desiredValuesClean.$key.UserName)
$returnValue = $false
}

# Assume the string is our username when the matching desired value is actually a credential
if ($currentType.Name -eq 'string' -and $CurrentValues.$key -eq $desiredValuesClean.$key.UserName)
{
Expand All @@ -177,10 +179,10 @@ function Test-DscParameterState
$returnValue = $false
}
}

if (-not $TurnOffTypeChecking)
{
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
{
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
$desiredType.FullName -ne $currentType.FullName)
{
Write-Verbose -Message "NOTMATCH: Type mismatch for property '$key' Current state type is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
Expand All @@ -193,22 +195,22 @@ function Test-DscParameterState
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
continue
}

if ($desiredValuesClean.GetType().Name -in 'HashTable', 'PSBoundParametersDictionary')
{
$checkDesiredValue = $desiredValuesClean.ContainsKey($key)
}
}
else
{
$checkDesiredValue = Test-DSCObjectHasProperty -Object $desiredValuesClean -PropertyName $key
}

if (-not $checkDesiredValue)
{
Write-Verbose -Message "MATCH: Value (type $($desiredType.Name)) for property '$key' does match. Current state is '$($CurrentValues.$key)' and desired state is '$($desiredValuesClean.$key)'"
continue
}

if ($desiredType.IsArray)
{
Write-Verbose -Message "Comparing values in property '$key'"
Expand Down Expand Up @@ -237,33 +239,33 @@ function Test-DscParameterState
}
else
{
$desiredType = [psobject]@{
$desiredType = [psobject]@{
Name = 'Unknown'
}
}

if ($null -ne $currentArrayValues[$i])
{
$currentType = $currentArrayValues[$i].GetType()
}
else
{
$currentType = [psobject]@{
Name = 'Unknown'
Name = 'Unknown'
}
}

if (-not $TurnOffTypeChecking)
{
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
if (($desiredType.Name -ne 'Unknown' -and $currentType.Name -ne 'Unknown') -and
$desiredType.FullName -ne $currentType.FullName)
{
Write-Verbose -Message "`tNOTMATCH: Type mismatch for property '$key' Current state type of element [$i] is '$($currentType.Name)' and desired type is '$($desiredType.Name)'"
$returnValue = $false
continue
}
}

if ($desiredArrayValues[$i] -ne $currentArrayValues[$i])
{
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])'"
Expand All @@ -276,20 +278,20 @@ function Test-DscParameterState
continue
}
}

}
}
else
}
else
{
if ($desiredValuesClean.$key -ne $CurrentValues.$key)
{
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)'"
$returnValue = $false
}
}

}
}

Write-Verbose -Message "Result is '$returnValue'"
return $returnValue
}
Expand All @@ -308,7 +310,7 @@ function Test-DSCObjectHasProperty
[OutputType([bool])]
param
(
[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[object]
$Object,

Expand All @@ -317,11 +319,11 @@ function Test-DSCObjectHasProperty
$PropertyName
)

if ($Object.PSObject.Properties.Name -contains $PropertyName)
if ($Object.PSObject.Properties.Name -contains $PropertyName)
{
return [bool] $Object.$PropertyName
}

return $false
}

Expand Down Expand Up @@ -377,10 +379,12 @@ function New-InvalidOperationException
[CmdletBinding()]
param
(
[Parameter()]
[ValidateNotNullOrEmpty()]
[String]
$Message,

[Parameter()]
[ValidateNotNull()]
[System.Management.Automation.ErrorRecord]
$ErrorRecord
Expand Down
Loading

0 comments on commit 0c894a0

Please sign in to comment.