Skip to content

Added DscResourceCache #432

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 24 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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