Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

restructured tooling

  • Loading branch information...
smurawski committed Apr 1, 2014
1 parent 3a0d2ba commit 0bb20701bcbf660c453fb15882aa67712ae37dc8
Showing with 847 additions and 583 deletions.
  1. +2 −1 .gitignore
  2. BIN Resources/StackExchangeResources/StackExchangeResources.psd1
  3. BIN Tooling/DscConfiguration/Add-EncryptedPassword.ps1
  4. +15 −0 Tooling/DscConfiguration/Add-NodeRoleFromServiceConfigurationData.Tests.ps1
  5. BIN Tooling/DscConfiguration/Add-NodeRoleFromServiceConfigurationData.ps1
  6. 0 Tooling/{DscDeployment → DscConfiguration}/ConvertFrom-EncryptedFile.ps1
  7. BIN Tooling/DscConfiguration/ConvertTo-CredentialLookup.ps1
  8. 0 Tooling/{DscDeployment → DscConfiguration}/ConvertTo-EncryptedFile.ps1
  9. +32 −0 Tooling/DscConfiguration/DscConfiguration.psm1
  10. BIN Tooling/DscConfiguration/Get-AllNodesConfigurationData.ps1
  11. BIN Tooling/DscConfiguration/Get-ConfigurationData.ps1
  12. BIN Tooling/DscConfiguration/Get-CredentialConfigurationData.ps1
  13. 0 Tooling/{DscDeployment → DscConfiguration}/Get-DscResourceVersion.ps1
  14. BIN Tooling/DscConfiguration/Get-EncryptedPassword.ps1
  15. BIN Tooling/DscConfiguration/Get-Hashtable.ps1
  16. BIN Tooling/DscConfiguration/Get-ServiceConfigurationData.ps1
  17. BIN Tooling/DscConfiguration/Get-SiteDataConfigurationData.ps1
  18. BIN Tooling/DscConfiguration/New-Credential.ps1
  19. 0 Tooling/{DscDevelopment → DscConfiguration}/New-DscNodeMetadata.ps1
  20. BIN Tooling/DscConfiguration/Remove-PlainTextPassword.ps1
  21. +137 −0 Tooling/DscConfiguration/Resolve-ConfigurationProperty.Tests.ps1
  22. +186 −0 Tooling/DscConfiguration/Resolve-ConfigurationProperty.ps1
  23. BIN Tooling/DscConfiguration/Test-LocalCertificate.ps1
  24. 0 Tooling/{DscDeployment → DscConfiguration}/Update-ModuleMetadataVersion.ps1
  25. +0 −123 Tooling/DscDeployment/DscDeployment.Tests.ps1
  26. +0 −372 Tooling/DscDeployment/DscDeployment.psm1
  27. +0 −48 Tooling/DscDeployment/Publish-DscResource.ps1
  28. +165 −0 Tooling/DscDevelopment/Deserializer.ps1
  29. +0 −29 Tooling/DscDevelopment/DscDevelopment.psm1
  30. +2 −2 Tooling/DscDevelopment/Test-DscBuild.ps1
  31. 0 Tooling/{DscDeployment → DscOperations}/Clear-DscEventLog.ps1
  32. 0 Tooling/{DscDeployment → DscOperations}/Get-DscEventLog.ps1
  33. 0 Tooling/{DscDeployment → DscOperations}/Invoke-DscPull.ps1
  34. 0 Tooling/{DscDeployment → DscOperations}/Set-DscClient.ps1
  35. +40 −0 Tooling/dscbuild/Assert-DestinationDirectory.ps1
  36. +7 −0 Tooling/dscbuild/Clear-CachedDscResource.ps1
  37. +10 −0 Tooling/dscbuild/Clear-InstalledDscResource.ps1
  38. +14 −0 Tooling/dscbuild/Compress-DscResourceModule.ps1
  39. +10 −0 Tooling/dscbuild/Copy-CurrentDscResource.ps1
  40. BIN Tooling/dscbuild/DscBuild.psd1
  41. +20 −0 Tooling/dscbuild/DscBuild.psm1
  42. +28 −0 Tooling/dscbuild/DscResourceWmiClass.ps1
  43. +50 −0 Tooling/dscbuild/Invoke-DscBuild.ps1
  44. +32 −0 Tooling/dscbuild/Invoke-DscConfiguration.ps1
  45. +13 −0 Tooling/dscbuild/Invoke-DscResourceUnitTest.ps1
  46. 0 Tooling/{DscDeployment → dscbuild}/New-DscChecksumFile.ps1
  47. 0 Tooling/{DscDeployment → dscbuild}/New-DscZipFile.ps1
  48. +13 −0 Tooling/dscbuild/Publish-DscConfiguration.ps1
  49. +18 −0 Tooling/dscbuild/Publish-DscResourceModule.ps1
  50. +15 −0 Tooling/dscbuild/Test-DscResourceIsValid.ps1
  51. 0 Tooling/{DscDeployment → dscbuild}/Where-DscResource.Tests.ps1
  52. +38 −8 Tooling/{DscDeployment → dscbuild}/Where-DscResource.ps1
@@ -6,4 +6,5 @@ Configuration/**
Resources/StackExchangeConfigurations/
Resources/StackExchangeResources/DSCResources/StackExchange_IISKeys/
Resources/StackExchangeResources/DSCResources/StackExchange_MetaConfiguration/
Resources/StackExchangeResources/DSCResources/StackExchange_ScollectorInstaller/
Resources/StackExchangeResources/DSCResources/StackExchange_ScollectorInstaller/
Tooling/Pester/
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.ps1", ".psm1")
if (-not (Test-Path $sut))
{
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.ps1", ".ps1")
}
if (-not (Test-Path $sut))
{
Write-Error "Failed to find script to test at $sut"
}
$pathtosut = join-path $here $sut

describe 'how Add-NodeRoleFromServiceConfigurationData works' {
context 'when ' {}
}
Binary file not shown.
@@ -0,0 +1,32 @@
param
(
[string]
$ConfigurationDataPath = (Join-path (split-path (split-path $PSScriptRoot)) 'Configuration'),
[string]
$LocalCertificateThumbprint = "$((Get-DscLocalConfigurationManager).CertificateId)"
)

$LocalCertificatePath = "cert:\LocalMachine\My\$LocalCertificateThumbprint"
$ConfigurationData = $null

. $psscriptroot\Add-EncryptedPassword.ps1
. $psscriptroot\Add-NodeRoleFromServiceConfigurationData.ps1
. $psscriptroot\ConvertFrom-EncryptedFile.ps1
. $psscriptroot\ConvertTo-CredentialLookup.ps1
. $psscriptroot\ConvertTo-EncryptedFile.ps1
. $psscriptroot\Get-AllNodesConfigurationData.ps1
. $psscriptroot\Get-ConfigurationData.ps1
. $psscriptroot\Get-CredentialConfigurationData.ps1
. $psscriptroot\Get-DscResourceVersion.ps1
. $psscriptroot\Get-EncryptedPassword.ps1
. $psscriptroot\Get-Hashtable.ps1
. $psscriptroot\Get-ServiceConfigurationData.ps1
. $psscriptroot\Get-SiteDataConfigurationData.ps1
. $psscriptroot\New-Credential.ps1
. $psscriptroot\Remove-PlainTextPassword.ps1
. $psscriptroot\Resolve-ConfigurationProperty.ps1
. $psscriptroot\Test-LocalCertificate.ps1
. $psscriptroot\Update-ModuleMetadataVersion.ps1
. $psscriptroot\New-DscNodeMetadata.ps1


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,137 @@
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.ps1", ".psm1")
if (-not (Test-Path $sut))
{
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.ps1", ".ps1")
}
if (-not (Test-Path $sut))
{
Write-Error "Failed to find script to test at $sut"
}
$pathtosut = join-path $here $sut

iex ( gc $pathtosut -Raw )

describe 'how Resolve-ConfigurationProperty responds' {
$ConfigurationData = @{
SiteData = @{
All = @{
PullServerPath = 'ConfiguredByDefault'
}
NY = @{
PullServerPath = 'ConfiguredBySite'
}
}
PullServerPath = 'ShouldNotReturn'
}
context 'when a node has an override for a site property' {

$Node = @{
Location = 'NY'
PullServerPath = 'OverrideValue'
}

$result = Resolve-ConfigurationProperty -PropertyName 'PullServerPath'

it "should return the node's override" {
$result | should be 'OverrideValue'
}
}

context 'when a node does not override the site property' {

$Node = @{
Location = 'NY'
}

$result = Resolve-ConfigurationProperty -PropertyName 'PullServerPath'
it "should return the site's default value" {
$result | should be 'ConfiguredBySite'
}
}

context 'when a site does not have the property but the base configuration data does' {

$Node = @{
Location = 'OR'
}

$result = Resolve-ConfigurationProperty -PropertyName 'PullServerPath'
it "should return the site's default value" {
$result | should be 'ConfiguredByDefault'
}
}
}


describe 'how Resolve-ConfigurationProperty responds' {
$ConfigurationData = @{
Services = @{
MyTestService = @{
DataSource = 'MyDefaultValue'
}
}
}
context 'when a default value is supplied for a service and node has a property override' {

$Node = @{
Location = 'NY'
Services = @{
MyTestService = @{
DataSource = 'MyCustomValue'
}
}
}

$result = Resolve-ConfigurationProperty -ServiceName MyTestService -PropertyName DataSource

it 'should return the override from the node' {
$result | should be 'MyCustomValue'

}
}

context 'when a site level override is present' {
$ConfigurationData.SiteData = @{
NY = @{
Services = @{
MyTestService = @{
DataSource = 'MySiteValue'
}
}
}
}
$Node = @{
Location = 'NY'
}

$result = Resolve-ConfigurationProperty -ServiceName MyTestService -PropertyName DataSource

it 'should return the override from the site' {
$result | should be 'MySiteValue'

}
}

context 'when no node or site level override is present' {
$ConfigurationData.SiteData = @{
NY = @{
Services = @{
MyTestService = @{}
}
}
}
$Node = @{
Location = 'NY'
}

$result = Resolve-ConfigurationProperty -ServiceName MyTestService -PropertyName DataSource

it 'should return the override from the site' {
$result | should be 'MyDefaultValue'

}
}


}
@@ -0,0 +1,186 @@
function Resolve-ConfigurationProperty {
[cmdletbinding()]
param (
[string[]]
$ServiceName,
[string]
$PropertyName
)

$Value = $null
$Value = Assert-NodeOverride @psboundparameters
if ($Value -eq $null) {
$Value = Assert-SiteOverride @psboundparameters
}
if ($Value -eq $null) {
$Value = Assert-GlobalSetting @psboundparameters
}
$Value = $Value | where-object {-not [string]::IsNullOrEmpty($_)}

return $Value
}

function Assert-NodeOverride {
[cmdletbinding()]
param (
[string[]]
$ServiceName,
[string]
$PropertyName
)
$Value = $null

if (Test-NodeOverride @psboundparameters) {
Write-Verbose "Found a Node Override for $PropertyName."
if ($ServiceName.count -eq 0) {
$Value = $Node[$PropertyName]
}
else {
$value = @()
foreach ($Service in $ServiceName) {
$Value += $Node.Services[$Service][$PropertyName]
}
}
return $Value
}
}

function Assert-SiteOverride {
[cmdletbinding()]
param (
[string[]]
$ServiceName,
[string]
$PropertyName
)
$Value = $null

if (Test-SiteOverride @psboundparameters){
if ($ServiceName.count -eq 0) {
$Value = $ConfigurationData.SiteData[$Node.Location][$PropertyName]
}
else {
$value = @()
foreach ($Service in $ServiceName) {
$Value += $ConfigurationData.SiteData[$Node.Location].Services[$Service][$PropertyName]
}
}
return $Value
}
}

function Assert-GlobalSetting {
[cmdletbinding()]
param (
[string[]]
$ServiceName,
[string]
$PropertyName
)
$Value = $null
if ($ServiceName.count -eq 0) {
if (Test-GlobalSetting @psboundparameters) {
$Value = $ConfigurationData.SiteData.All[$PropertyName]
}
return $Value
}
else {
$value = @()
foreach ($Service in $ServiceName)
{
$psboundparameters.ServiceName = $Service
if (Test-GlobalSetting @psboundparameters){
$Value += $ConfigurationData.Services[$Service][$PropertyName]
}
}
return $Value
}
}

function Test-NodeOverride {
[cmdletbinding()]
param (
[string[]]
$ServiceName,
$PropertyName
)
$IsPresent = $false
if (($ServiceName.count -eq 0)) {
Write-Verbose "First Check if the Node has a key of $PropertyName"
$IsPresent = (test-path variable:\Node) -and
$Node.ContainsKey($PropertyName)
}
else {
foreach ($Service in $ServiceName) {
Write-Verbose "First Check if the Node has a key of $PropertyName for service $Service"
$IsPresent = (test-path variable:\Node) -and
$Node.ContainsKey('Services') -and
$Node.Services.ContainsKey($Service) -and
$Node.Services[$Service].ContainsKey($PropertyName)
if ($IsPresent) {
return $IsPresent
}
}
}
return $IsPresent
}

function Test-SiteOverride {
[cmdletbinding()]
param (
$ServiceName,
$PropertyName
)
$IsPresent = $false
if ([string]::IsNullOrEmpty($ServiceName)) {
Write-Verbose "Next Check if the Site has a key of $PropertyName"
$IsPresent = (test-path variable:ConfigurationData) -and
$ConfigurationData.ContainsKey('SiteData') -and
$ConfigurationData.SiteData.ContainsKey($Node.Location) -and
$ConfigurationData.SiteData[$Node.Location].ContainsKey($PropertyName)
}
else {
Write-Verbose "Next Check if the Site has a key of $PropertyName for service $ServiceName"
foreach ($Service in $ServiceName) {
$IsPresent = (test-path variable:ConfigurationData) -and
$ConfigurationData.ContainsKey('SiteData') -and
$ConfigurationData.SiteData.ContainsKey($Node.Location) -and
$ConfigurationData.SiteData[$Node.Location].ContainsKey('Services') -and
$ConfigurationData.SiteData[$Node.Location].Services.ContainsKey($Service) -and
$ConfigurationData.SiteData[$Node.Location].Services[$Service].ContainsKey($PropertyName)
if ($IsPresent) {
return $IsPresent
}
}
}
return $IsPresent
}

function Test-GlobalSetting {
[cmdletbinding()]
param (
$ServiceName,
$PropertyName
)
$IsPresent = $false
if ([string]::IsNullOrEmpty($ServiceName)) {
Write-Verbose "Finally Check if the 'All' Site has a key of $PropertyName"
$IsPresent = (test-path variable:ConfigurationData) -and
$ConfigurationData.ContainsKey('SiteData') -and
$ConfigurationData.SiteData.ContainsKey('All') -and
$ConfigurationData.SiteData.All.ContainsKey($PropertyName)
}
else {
Write-Verbose "Finally Check if the Service has a Default Value"
foreach ($Service in $ServiceName) {
$IsPresent = (test-path variable:ConfigurationData) -and
$ConfigurationData.ContainsKey('Services') -and
$ConfigurationData.Services.ContainsKey($Service) -and
$ConfigurationData.Services[$Service].ContainsKey($PropertyName)
if ($IsPresent) {
return $IsPresent
}
}
}
return $IsPresent
}
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0bb2070

Please sign in to comment.
You can’t perform that action at this time.