Skip to content
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

Added DscResourceCache #432

Merged
merged 24 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9857ad2
Added DscResourceCache
anmenaga May 8, 2024
32015c7
Added PSModulePath check
anmenaga May 8, 2024
9366b56
Updated cache code for WinPS
anmenaga May 8, 2024
11cd173
Updated tests for WinPS
anmenaga May 8, 2024
78fbba1
Updated tests for WinPS 2
anmenaga May 8, 2024
236c283
Updated tests for WinPS 3
anmenaga May 8, 2024
c8cbfd7
Updates from code review feedback
anmenaga May 10, 2024
b47155a
Updatet tests
anmenaga May 10, 2024
18e78f4
Added DscResourceCache
anmenaga May 8, 2024
8a651bf
Added PSModulePath check
anmenaga May 8, 2024
1ca79db
Updated cache code for WinPS
anmenaga May 8, 2024
3e57c71
Updated tests for WinPS
anmenaga May 8, 2024
8975a0d
Updated tests for WinPS 2
anmenaga May 8, 2024
c50547b
Updated tests for WinPS 3
anmenaga May 8, 2024
88b33c1
Updates from code review feedback
anmenaga May 10, 2024
2a79104
Updatet tests
anmenaga May 10, 2024
51c3cc4
Merge branch 'ps_cache' of https://github.com/anmenaga/DSC-New into p…
anmenaga May 10, 2024
14c6084
Update powershell-adapter/psDscAdapter/psDscAdapter.psm1
anmenaga May 15, 2024
4049b5b
Update powershell-adapter/Tests/powershellgroup.config.tests.ps1
anmenaga May 15, 2024
d18839b
Update powershell-adapter/Tests/powershellgroup.resource.tests.ps1
anmenaga May 15, 2024
0f72693
Update powershell-adapter/psDscAdapter/psDscAdapter.psm1
anmenaga May 15, 2024
86bd66d
Merge branch 'ps_cache' of https://github.com/anmenaga/DSC-New into p…
anmenaga May 15, 2024
7de5ab9
Feedback 1
anmenaga May 16, 2024
81d27f7
Feedback 2
anmenaga May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dsc_lib/src/configure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn add_resource_export_results_to_configuration(resource: &DscResource, adap

for (i, instance) in export_result.actual_state.iter().enumerate() {
let mut r = config_doc::Resource::new();
r.resource_type = resource.type_name.clone();
r.resource_type.clone_from(&resource.type_name);
r.name = format!("{}-{i}", r.resource_type);
let props: Map<String, Value> = serde_json::from_value(instance.clone())?;
r.properties = escape_property_values(&props)?;
Expand Down
2 changes: 1 addition & 1 deletion osinfo/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::string::ToString;
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct OsInfo {
/// Returns the unique ID for the OSInfo instance data type.
/// Returns the unique ID for the `OSInfo` instance data type.
#[serde(rename = "$id")]
pub id: String,
family: Family,
Expand Down
14 changes: 14 additions & 0 deletions powershell-adapter/Tests/powershellgroup.config.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ Describe 'PowerShell adapter resource tests' {
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot
$pwshConfigPath = Join-path $PSScriptRoot "class_ps_resources.dsc.yaml"
$winpsConfigPath = Join-path $PSScriptRoot "winps_resource.dsc.yaml"

if ($IsLinux -or $IsMacOS) {
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
}
else
{
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
}

BeforeEach {
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
}

It 'Get works on config with class-based and script-based resources' -Skip:(!$IsWindows){

$r = Get-Content -Raw $pwshConfigPath | dsc config get
Expand Down
14 changes: 14 additions & 0 deletions powershell-adapter/Tests/powershellgroup.resource.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@ Describe 'PowerShell adapter resource tests' {
}
$OldPSModulePath = $env:PSModulePath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $PSScriptRoot

if ($IsLinux -or $IsMacOS) {
$cacheFilePath = Join-Path $env:HOME ".dsc" "PSAdapterCache.json"
}
else
{
$cacheFilePath = Join-Path $env:LocalAppData "dsc" "PSAdapterCache.json"
$cacheFilePath_v5 = Join-Path $env:LocalAppData "dsc" "WindowsPSAdapterCache.json"
}
}
AfterAll {
$env:PSModulePath = $OldPSModulePath
}

BeforeEach {
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath
Remove-Item -Force -ea SilentlyContinue -Path $cacheFilePath_v5
}

It 'Discovery includes class-based and script-based resources ' -Skip:(!$IsWindows){

$r = dsc resource list * -a Microsoft.DSC/PowerShell
Expand Down
Loading
Loading