From 003167765a6f66a1816a577b2aa75919933c41dc Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 14 Jan 2025 14:43:42 -0800 Subject: [PATCH 1/3] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 6d40124d..3cdeb34c 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,11 @@ With DSCv3, you can: ### Differences from PowerShell DSC -This project is the next generation of DSC and leverages the -[PSDesiredStateConfiguration module][00] to maintain compatibility with existing PowerShell based -resources. - DSCv3 differs from PowerShell DSC in a few important ways: - DSCv3 doesn't depend on PowerShell. You can use DSCv3 without PowerShell installed and manage resources written in bash, python, C#, Go, or any other language. +- DSCv3 use of PowerShell based resources does not depend on PSDesiredStateConfiguration module - DSCv3 doesn't include a local configuration manager. DSCv3 is invoked as a command. It doesn't run as a service. - Non-PowerShell resources define their schemas with JSON files, not MOF files. From 4ca98bfe9fad725f6a435f15b9eceb1e36da0261 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 14 Jan 2025 21:46:21 -0800 Subject: [PATCH 2/3] Fix builtin resource/settings discovery when dsc is invoked using a symlink --- dsc_lib/src/discovery/command_discovery.rs | 3 ++- dsc_lib/src/util.rs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dsc_lib/src/discovery/command_discovery.rs b/dsc_lib/src/discovery/command_discovery.rs index 61f9a682..060536e1 100644 --- a/dsc_lib/src/discovery/command_discovery.rs +++ b/dsc_lib/src/discovery/command_discovery.rs @@ -24,6 +24,7 @@ use tracing::{debug, info, trace, warn, warn_span}; use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::util::get_setting; +use crate::util::get_exe_path; pub struct CommandDiscovery { // use BTreeMap so that the results are sorted by the typename, the Vec is sorted by version @@ -135,7 +136,7 @@ impl CommandDiscovery { // if exe home is not already in PATH env var then add it to env var and list of searched paths if !using_custom_path { - if let Some(exe_home) = env::current_exe()?.parent() { + if let Some(exe_home) = get_exe_path()?.parent() { let exe_home_pb = exe_home.to_path_buf(); if paths.contains(&exe_home_pb) { trace!("Exe home is already in path: {}", exe_home.to_string_lossy()); diff --git a/dsc_lib/src/util.rs b/dsc_lib/src/util.rs index 177d9549..ed110efe 100644 --- a/dsc_lib/src/util.rs +++ b/dsc_lib/src/util.rs @@ -3,6 +3,7 @@ use crate::dscerror::DscError; use serde_json::Value; +use std::fs; use std::fs::File; use std::io::BufReader; use std::path::PathBuf; @@ -79,7 +80,7 @@ pub fn get_setting(value_name: &str) -> Result { let mut result: DscSettingValue = DscSettingValue::default(); let mut settings_file_path : PathBuf; - if let Some(exe_home) = env::current_exe()?.parent() { + if let Some(exe_home) = get_exe_path()?.parent() { // First, get setting from the default settings file settings_file_path = exe_home.join(DEFAULT_SETTINGS_FILE_NAME); if let Ok(v) = load_value_from_json(&settings_file_path, DEFAULT_SETTINGS_SCHEMA_VERSION) { @@ -141,6 +142,19 @@ fn load_value_from_json(path: &PathBuf, value_name: &str) -> Result Result { + if let Ok(exe) = env::current_exe() { + if let Ok(target_path) = fs::read_link(exe.clone()) { + return Ok(target_path); + } + else { + return Ok(exe); + } + } + + Err(DscError::NotSupported("Can't get the path to dsc executable".to_string())) +} + #[cfg(target_os = "windows")] fn get_settings_policy_file_path() -> String { From 956aefecc9d8f58f2f85d72e6cdd3697feb6b7d2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 15 Jan 2025 10:47:02 -0800 Subject: [PATCH 3/3] Clippy fix --- dsc_lib/src/util.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dsc_lib/src/util.rs b/dsc_lib/src/util.rs index ed110efe..0ff323a9 100644 --- a/dsc_lib/src/util.rs +++ b/dsc_lib/src/util.rs @@ -142,14 +142,19 @@ fn load_value_from_json(path: &PathBuf, value_name: &str) -> Result Result { if let Ok(exe) = env::current_exe() { if let Ok(target_path) = fs::read_link(exe.clone()) { return Ok(target_path); - } - else { - return Ok(exe); - } + }; + + return Ok(exe); } Err(DscError::NotSupported("Can't get the path to dsc executable".to_string()))