Skip to content

Commit

Permalink
Merge pull request #93 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 1.12.0.0 of xDnsServer
  • Loading branch information
kwirkykat authored May 15, 2019
2 parents e2a372a + 25332b1 commit 13657e4
Show file tree
Hide file tree
Showing 19 changed files with 1,032 additions and 724 deletions.
24 changes: 24 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
codecov:
notify:
require_ci_to_pass: no

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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Needed for publishing of examples, build worker defaults to core.autocrlf=input.
* text eol=crlf
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/General.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: General question or documentation update
about: If you have a general question or documentation update suggestion around the resource module.
---
<!--
Your feedback and support is greatly appreciated, thanks for contributing!
-->
57 changes: 57 additions & 0 deletions .github/ISSUE_TEMPLATE/Problem_with_resource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Problem with a resource
about: If you have a problem, bug, or enhancement with a resource in this resource module.
---
<!--
Your feedback and support is greatly appreciated, thanks for contributing!
ISSUE TITLE:
Please prefix the issue title with the resource name, e.g.
'ResourceName: Short description of my issue'
ISSUE DESCRIPTION (this template):
Please provide information regarding your issue under each header below.
Write N/A under any headers that do not apply to your issue, or if the
information is not available.
NOTE! Sensitive information should be obfuscated.
PLEASE KEEP THE HEADERS.
You may remove this comment block, and the other comment blocks,
but please keep the headers.
-->
#### Details of the scenario you tried and the problem that is occurring

#### Verbose logs showing the problem

#### Suggested solution to the issue

#### The DSC configuration that is used to reproduce the issue (as detailed as possible)
```powershell
# insert configuration here
```

#### The operating system the target node is running
<!--
Please provide as much as possible about the target node, for example
edition, version, build and language.
On OS with WMF 5.1 the following command can help get this information.
Get-ComputerInfo -Property @(
'OsName',
'OsOperatingSystemSKU',
'OSArchitecture',
'WindowsVersion',
'WindowsBuildLabEx',
'OsLanguage',
'OsMuiLanguages')
-->

#### Version and build of PowerShell the target node is running
<!--
To help with this information, please run this command:
$PSVersionTable
-->

#### Version of the DSC module that was used ('dev' if using current dev branch)
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/Resource_proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: New resource proposal
about: If you have a new resource proposal that you think should be added to this resource module.
---
<!--
Thank you for contributing and making this resource module better!
ISSUE TITLE:
Please prefix the issue title with a proposed resource name,
e.g. 'NewResourceName: New resource proposal'
ISSUE DESCRIPTION (this template):
Please propose the new resource under each header below.
PLEASE KEEP THE HEADERS, but you may remove this comment block.
-->
### Description

### Proposed properties

### Special considerations or limitations
47 changes: 47 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--
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,
e.g. 'ResourceName: My short description'.
If this is a breaking change, then also prefix the PR title
with 'BREAKING CHANGE:',
e.g. 'BREAKING CHANGE: ResourceName: My short description'.
You may remove this comment block, and the other comment blocks, but please
keep the headers and the task list.
-->
#### Pull Request (PR) description
<!--
Replace this comment block with a description of your PR.
-->

#### This Pull Request (PR) fixes the following issues
<!--
If this PR does not fix an open issue, replace this comment block with None.
If this PR resolves one or more open issues, replace this comment block with
a list the issues using a GitHub closing keyword, e.g.:
- Fixes #123
- Fixes #124
-->

#### Task list
<!--
To aid community reviewers in reviewing and merging your PR, please take
the time to run through the below checklist and make sure your PR has
everything updated as required.
Change to [x] for each task in the task list that applies to your PR.
For those task that don't apply to you PR, leave those as is.
-->
- [ ] Added an entry under the Unreleased section of the change log in the README.md.
Entry should say what was changed, and how that affects users (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 Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md).
- [ ] Integration tests added/updated (where possible). See [DSC Resource Testing Guidelines](https://github.com/PowerShell/DscResources/blob/master/TestsGuidelines.md).
- [ ] New/changed code adheres to [DSC Resource Style Guidelines](https://github.com/PowerShell/DscResources/blob/master/StyleGuidelines.md) and [Best Practices](https://github.com/PowerShell/DscResources/blob/master/BestPractices.md).
44 changes: 44 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Configuration for probot-stale - https://github.com/probot/stale

limitPerRun: 30

pulls:
daysUntilStale: 14
daysUntilClose: false
exemptProjects: true
exemptMilestones: true
staleLabel: abandoned
exemptLabels:
- needs review
- on hold
- waiting for CLA pass

markComment: >
Labeling this pull request (PR) as abandoned since it has gone 14 days or more
since the last update. An abandoned PR can be continued by another contributor.
The abandoned label will be removed if work on this PR is taken up again.
issues:
daysUntilStale: 30
daysUntilClose: 40
exemptProjects: true
exemptMilestones: true
staleLabel: stale
exemptLabels:
- bug
- enhancement
- tests
- documentation
- resource proposal
- on hold

markComment: >
This issue has been automatically marked as stale because
it has not had activity from the community in the last 30 days. It will be
closed if no further activity occurs within 10 days. If the issue is labelled
with any of the work labels (e.g bug, enhancement, documentation, or tests)
then the issue will not auto-close.
closeComment: >
This issue has been automatically closed because it is has not had activity
from the community in the last 40 days.
53 changes: 53 additions & 0 deletions .vscode/analyzersettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@{
<#
For the custom rules to work, the DscResource.Tests repo must be
cloned. It is automatically clone as soon as any unit or
integration tests are run.
#>
CustomRulePath = '.\DSCResource.Tests\DscResource.AnalyzerRules'

IncludeRules = @(
# DSC Resource Kit style guideline rules.
'PSAvoidDefaultValueForMandatoryParameter',
'PSAvoidDefaultValueSwitchParameter',
'PSAvoidInvokingEmptyMembers',
'PSAvoidNullOrEmptyHelpMessageAttribute',
'PSAvoidUsingCmdletAliases',
'PSAvoidUsingComputerNameHardcoded',
'PSAvoidUsingDeprecatedManifestFields',
'PSAvoidUsingEmptyCatchBlock',
'PSAvoidUsingInvokeExpression',
'PSAvoidUsingPositionalParameters',
'PSAvoidShouldContinueWithoutForce',
'PSAvoidUsingWMICmdlet',
'PSAvoidUsingWriteHost',
'PSDSCReturnCorrectTypesForDSCFunctions',
'PSDSCStandardDSCFunctionsInResource',
'PSDSCUseIdenticalMandatoryParametersForDSC',
'PSDSCUseIdenticalParametersForDSC',
'PSMisleadingBacktick',
'PSMissingModuleManifestField',
'PSPossibleIncorrectComparisonWithNull',
'PSProvideCommentHelp',
'PSReservedCmdletChar',
'PSReservedParams',
'PSUseApprovedVerbs',
'PSUseCmdletCorrectly',
'PSUseOutputTypeCorrectly',
'PSAvoidGlobalVars',
'PSAvoidUsingConvertToSecureStringWithPlainText',
'PSAvoidUsingPlainTextForPassword',
'PSAvoidUsingUsernameAndPasswordParams',
'PSDSCUseVerboseMessageInDSCResource',
'PSShouldProcess',
'PSUseDeclaredVarsMoreThanAssignments',
'PSUsePSCredentialType',

<#
This is to test all the DSC Resource Kit custom rules.
The name of the function-blocks of each custom rule start
with 'Measure*'.
#>
'Measure-*'
)
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"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,
"powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1"
}
22 changes: 11 additions & 11 deletions DSCResources/MSFT_xDnsRecord/MSFT_xDnsRecord.schema.mof
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[ClassVersion("1.0.0.0"), FriendlyName("xDnsRecord")]
class MSFT_xDnsRecord : OMI_BaseResource
{
[Key, Description("Specifies the name of the DNS server resource record object.")] string Name;
[Key, Description("Specifies the name of a DNS zone.")] string Zone;
[Required, Description("Specifies the type of DNS record."), ValueMap{"ARecord","CName","Ptr"}, Values{"ARecord","CName","Ptr"}] string Type;
[Key, Description("Specifies the Target Hostname or IP Address.")] string Target;
[Write, Description("Name of the DnsServer to create the record on.")] string DnsServer;
[Write, Description("Should this DNS resource record be present or absent"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
};
[ClassVersion("1.0.0.0"), FriendlyName("xDnsRecord")]
class MSFT_xDnsRecord : OMI_BaseResource
{
[Key, Description("Specifies the name of the DNS server resource record object.")] string Name;
[Key, Description("Specifies the name of a DNS zone.")] string Zone;
[Required, Description("Specifies the type of DNS record."), ValueMap{"ARecord","CName","Ptr"}, Values{"ARecord","CName","Ptr"}] string Type;
[Key, Description("Specifies the Target Hostname or IP Address.")] string Target;
[Write, Description("Name of the DnsServer to create the record on.")] string DnsServer;
[Write, Description("Should this DNS resource record be present or absent"), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
};

43 changes: 30 additions & 13 deletions DSCResources/MSFT_xDnsServerForwarder/MSFT_xDnsServerForwarder.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ function Get-TargetResource
[Parameter(Mandatory = $true)]
[ValidateSet('Yes')]
[string]
$IsSingleInstance,

[Parameter()]
[string[]]
$IPAddresses
$IsSingleInstance
)
Write-Verbose 'Getting current DNS forwarders.'
[array]$currentIPs = (Get-CimInstance -Namespace root\MicrosoftDNS -ClassName microsoftdns_server).Forwarders
$CurrentServerForwarders = Get-DnsServerForwarder
[array]$currentIPs = $CurrentServerForwarders.IPAddress
$CurrentUseRootHint = $CurrentServerForwarders.UseRootHint
$targetResource = @{
IsSingleInstance = $IsSingleInstance
IPAddresses = @()
UseRootHint = $CurrentUseRootHint
}
if ($currentIPs)
{
Expand All @@ -36,19 +35,27 @@ function Set-TargetResource

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

[Parameter()]
[System.Boolean]
$UseRootHint
)
if (!$IPAddresses)
{
$IPAddresses = @()
}
Write-Verbose -Message 'Setting DNS forwarders.'
$setParams = @{
Namespace = 'root\MicrosoftDNS'
Query = 'select * from microsoftdns_server'
Property = @{Forwarders = $IPAddresses}
IPAddress = $IPAddresses
}

if ($PSBoundParameters.ContainsKey('UseRootHint'))
{
$setParams.Add('UseRootHint', $UseRootHint)
}
Set-CimInstance @setParams

Set-DnsServerForwarder @setParams -WarningAction 'SilentlyContinue'
}

function Test-TargetResource
Expand All @@ -63,10 +70,16 @@ function Test-TargetResource

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

[Parameter()]
[System.Boolean]
$UseRootHint
)

Write-Verbose -Message 'Validate IP addresses.'
[array]$currentIPs = (Get-TargetResource @PSBoundParameters).IPAddresses
$currentConfiguration = Get-TargetResource -IsSingleInstance $IsSingleInstance
[array]$currentIPs = $currentConfiguration.IPAddresses
if ($currentIPs.Count -ne $IPAddresses.Count)
{
return $false
Expand All @@ -78,5 +91,9 @@ function Test-TargetResource
return $false
}
}
if($currentConfiguration.UseRootHint -ne $UseRootHint){
return $false
}

return $true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ class MSFT_xDnsServerForwarder : OMI_BaseResource
{
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"), ValueMap{"Yes"}, Values{"Yes"}] String IsSingleInstance;
[Write] String IPAddresses[];
[Write, Description("Validate if you want to use root hint on DNS Server.")] Boolean UseRootHint;
};
Loading

0 comments on commit 13657e4

Please sign in to comment.