-
Notifications
You must be signed in to change notification settings - Fork 52
DSC meta configuration #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d889da8
metaconfig 1
304815c
metaconfig 2
fa16c3e
metaconfig 3
78ebef5
metaconfig 4
6255d7c
metaconfig 5
f2479a1
metaconfig 6
2a02351
metaconfig 7
9ee49bd
metaconfig 8
fbb0c8e
metaconfig 9
b32ac65
metaconfig 10
ff1ae6f
feedback 1
210a010
feedback 1_1
7bc6202
feedback 1_2
2d2edc3
feedback 1_3
f1c44c7
feedback 1_4
65702f4
feedback 1_5
5979505
Merge branch 'main' of https://github.com/PowerShell/DSC into issue_282
ebb1e96
renamed file to dsc_default.settings.json
2b76fd1
updated schema in dsc_default.settings.json
da94e76
updated tests
4539986
added default tracer
0fef980
style fix 1
e98f65c
style fix 2
35768c4
style fix 3
a590112
style fix 4
7d5a4a0
new feedback
4085e32
new feedback 2
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dsc.settings.json | ||
dsc_default.settings.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"resourcePath": { | ||
"allowEnvOverride": true, | ||
"appendEnvPath": true, | ||
"directories": [] | ||
}, | ||
"tracing": { | ||
"level": "WARN", | ||
"format": "Default", | ||
"allowOverride": true | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"1": { | ||
"resourcePath": { | ||
"allowEnvOverride": true, | ||
"appendEnvPath": true, | ||
"directories": [] | ||
}, | ||
"tracing": { | ||
"level": "WARN", | ||
"format": "Default", | ||
"allowOverride": true | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
Describe 'tests for dsc settings' { | ||
BeforeAll { | ||
|
||
$script:policyFilePath = if ($IsWindows) { | ||
Join-Path $env:ProgramData "dsc" "dsc.settings.json" | ||
} else { | ||
"/etc/dsc/dsc.settings.json" | ||
} | ||
|
||
$script:dscHome = (Get-Command dsc).Path | Split-Path | ||
$script:dscSettingsFilePath = Join-Path $script:dscHome "dsc.settings.json" | ||
$script:dscDefaultSettingsFilePath = Join-Path $script:dscHome "dsc_default.settings.json" | ||
|
||
if ($IsWindows) { #"Setting policy on Linux requires sudo" | ||
$script:policyDirPath = $script:policyFilePath | Split-Path | ||
New-Item -ItemType Directory -Path $script:policyDirPath | Out-Null | ||
} | ||
|
||
#create backups of settings files | ||
$script:dscSettingsFilePath_backup = Join-Path $script:dscHome "dsc.settings.json.backup" | ||
$script:dscDefaultSettingsFilePath_backup = Join-Path $script:dscHome "dsc_default.settings.json.backup" | ||
Copy-Item -Force -Path $script:dscSettingsFilePath -Destination $script:dscSettingsFilePath_backup | ||
Copy-Item -Force -Path $script:dscDefaultSettingsFilePath -Destination $script:dscDefaultSettingsFilePath_backup | ||
} | ||
|
||
AfterAll { | ||
Remove-Item -Force -Path $script:dscSettingsFilePath_backup | ||
Remove-Item -Force -Path $script:dscDefaultSettingsFilePath_backup | ||
if ($IsWindows) { #"Setting policy on Linux requires sudo" | ||
Remove-Item -Recurse -Force -Path $script:policyDirPath | ||
} | ||
} | ||
|
||
BeforeEach { | ||
$script:dscDefaultSettings = Get-Content -Raw -Path $script:dscDefaultSettingsFilePath_backup | ConvertFrom-Json | ||
$script:dscDefaultv1Settings = (Get-Content -Raw -Path $script:dscDefaultSettingsFilePath_backup | ConvertFrom-Json)."1" | ||
} | ||
|
||
AfterEach { | ||
Copy-Item -Force -Path $script:dscSettingsFilePath_backup -Destination $script:dscSettingsFilePath | ||
Copy-Item -Force -Path $script:dscDefaultSettingsFilePath_backup -Destination $script:dscDefaultSettingsFilePath | ||
if ($IsWindows) { #"Setting policy on Linux requires sudo" | ||
Remove-Item -Path $script:policyFilePath -ErrorAction SilentlyContinue | ||
} | ||
} | ||
|
||
It 'ensure a new tracing value in settings has effect' { | ||
|
||
$script:dscDefaultv1Settings."tracing"."level" = "TRACE" | ||
$script:dscDefaultv1Settings | ConvertTo-Json -Depth 90 | Set-Content -Force -Path $script:dscSettingsFilePath | ||
|
||
dsc resource list 2> $TestDrive/tracing.txt | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Trace-level is Trace" | ||
} | ||
|
||
It 'ensure a new resource_path value in settings has effect' { | ||
|
||
$script:dscDefaultv1Settings."resourcePath"."directories" = @("TestDir1","TestDir2") | ||
$script:dscDefaultv1Settings | ConvertTo-Json -Depth 90 | Set-Content -Force -Path $script:dscSettingsFilePath | ||
dsc -l debug resource list 2> $TestDrive/tracing.txt | ||
$expectedString = 'Using Resource Path: "TestDir1'+[System.IO.Path]::PathSeparator+'TestDir2' | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly $expectedString | ||
} | ||
|
||
It 'Confirm settings override priorities' { | ||
|
||
if (! $IsWindows) { | ||
Set-ItResult -Skip -Because "Setting policy requires sudo" | ||
return | ||
} | ||
|
||
$script:dscDefaultv1Settings."tracing"."level" = "TRACE" | ||
$script:dscDefaultv1Settings."resourcePath"."directories" = @("PolicyDir") | ||
$script:dscDefaultv1Settings | ConvertTo-Json -Depth 90 | Set-Content -Force -Path $script:policyFilePath | ||
|
||
$script:dscDefaultv1Settings."tracing"."level" = "TRACE" | ||
$script:dscDefaultv1Settings."resourcePath"."directories" = @("SettingsDir") | ||
$script:dscDefaultv1Settings | ConvertTo-Json -Depth 90 | Set-Content -Force -Path $script:dscSettingsFilePath | ||
|
||
$script:dscDefaultSettings."1"."tracing"."level" = "TRACE" | ||
$script:dscDefaultSettings."1"."resourcePath"."directories" = @("Defaultv1SettingsDir") | ||
$script:dscDefaultSettings | ConvertTo-Json -Depth 90 | Set-Content -Force -Path $script:dscDefaultSettingsFilePath | ||
|
||
# ensure policy overrides everything | ||
dsc -l debug resource list 2> $TestDrive/tracing.txt | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Trace-level is Trace" | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Using Resource Path: "PolicyDir' | ||
|
||
# without policy, command-line args have priority | ||
Remove-Item -Path $script:policyFilePath | ||
dsc -l debug resource list 2> $TestDrive/tracing.txt | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Trace-level is Debug" | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Using Resource Path: "SettingsDir' | ||
|
||
# without policy and command-line args, settings file is used | ||
dsc resource list 2> $TestDrive/tracing.txt | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Trace-level is Trace" | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Using Resource Path: "SettingsDir' | ||
|
||
# without policy and command-line args and settings file, the default settings file is used | ||
Remove-Item -Path $script:dscSettingsFilePath | ||
dsc resource list 2> $TestDrive/tracing.txt | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly "Trace-level is Trace" | ||
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Using Resource Path: "Defaultv1SettingsDir' | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.