Skip to content

Update version to 3.1-preview.7, crate versions, fix clippy #856

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 4 commits into from
Jun 3, 2025
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
10 changes: 6 additions & 4 deletions dsc/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dsc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dsc"
version = "3.1.0-preview.6"
version = "3.1.0-preview.7"
edition = "2021"

[profile.release]
Expand Down
16 changes: 9 additions & 7 deletions dsc/locales/en-us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ Press any key to close this window"""
[resolve]
processingInclude = "Processing Include input"
invalidInclude = "Failed to deserialize Include input"
failedToReadFile = "Failed to read file"
failedToOpenFile = "Failed to open included file"
invalidFileContent = "Invalid UTF-8 sequence in included file"
invalidFile = "Failed to read the configuration file as YAML or JSON"
failedToReadFile = "Failed to read file '%{path}': %{error}"
failedToOpenFile = "Failed to open included file '%{path}': %{error}"
invalidFileContent = "Invalid UTF-8 sequence in included file '%{path}': %{error}"
invalidFile = "Failed to read the configuration file as YAML or JSON '%{path}': %{error}"
invalidContent = "Invalid content provided, expected JSON or YAML: %{error}"
resolvingParameters = "Resolving parameters from file"
failedParseParametersFile = "Failed to parse parameters file or content to JSON"
couldNotReadParametersFile = "Could not read parameters file"
invalidPath = "Include path must not contain '..'"
failedParseParametersFile = "Failed to parse parameters file '%{path}'or content to JSON: %{error}"
couldNotReadParametersFile = "Could not read parameters file '%{path}': %{error}"
invalidParametersContent = "Invalid parameters content provided, expected JSON or YAML: %{error}"
invalidPath = "Include path '%{path}' must not contain '..'"
failedGetCurrentDirectory = "Failed to get current directory"
noParameters = "No parameters specified"

Expand Down
18 changes: 9 additions & 9 deletions dsc/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,34 @@ pub fn get_contents(input: &str) -> Result<(Option<String>, String), String> {
match file.read_to_end(&mut buffer) {
Ok(_) => (),
Err(err) => {
return Err(format!("{} '{include_path:?}': {err}", t!("resolve.failedToReadFile")));
return Err(t!("resolve.failedToReadFile", path = include_path.to_string_lossy(), error = err.to_string()).to_string());
}
}
},
Err(err) => {
return Err(format!("{} '{include_path:?}': {err}", t!("resolve.failedToOpenFile")));
return Err(t!("resolve.failedToOpenFile", path = include_path.to_string_lossy(), error = err.to_string()).to_string());
}
}
// convert the buffer to a string
let include_content = match String::from_utf8(buffer) {
Ok(input) => input,
Err(err) => {
return Err(format!("{} '{include_path:?}': {err}", t!("resolve.invalidFileContent")));
return Err(t!("resolve.invalidFileContent", path = include_path.to_string_lossy(), error = err.to_string()).to_string());
}
};

match parse_input_to_json(&include_content) {
Ok(json) => json,
Err(err) => {
return Err(format!("{} '{include_path:?}': {err}", t!("resolve.invalidFile")));
return Err(t!("resolve.invalidFile", path = include_path.to_string_lossy(), error = err.to_string()).to_string());
}
}
},
IncludeKind::ConfigurationContent(text) => {
match parse_input_to_json(&text) {
Ok(json) => json,
Err(err) => {
return Err(format!("{}: {err}", t!("resolve.invalidFile")));
return Err(t!("resolve.invalidContent", error = err.to_string()).to_string());
}
}
}
Expand All @@ -120,21 +120,21 @@ pub fn get_contents(input: &str) -> Result<(Option<String>, String), String> {
let parameters_json = match parse_input_to_json(&parameters) {
Ok(json) => json,
Err(err) => {
return Err(format!("{} '{parameters_file:?}': {err}", t!("resolve.failedParseParametersFile")));
return Err(t!("resolve.failedParseParametersFile", path = parameters_file.to_string_lossy(), error = err.to_string()).to_string());
}
};
Some(parameters_json)
},
Err(err) => {
return Err(format!("{} '{parameters_file:?}': {err}", t!("resolve.couldNotReadParametersFile")));
return Err(t!("resolve.couldNotReadParametersFile", path = parameters_file.to_string_lossy(), error = err.to_string()).to_string());
}
}
},
Some(IncludeParametersKind::ParametersContent(text)) => {
let parameters_json = match parse_input_to_json(&text) {
Ok(json) => json,
Err(err) => {
return Err(format!("{}: {err}", t!("resolve.failedParseParametersFile")));
return Err(t!("resolve.invalidParametersContent", error = err.to_string()).to_string());
}
};
Some(parameters_json)
Expand All @@ -154,7 +154,7 @@ fn normalize_path(path: &Path) -> Result<PathBuf, String> {
} else {
// check that no components of the path are '..'
if path.components().any(|c| c == std::path::Component::ParentDir) {
return Err(format!("{}: {path:?}", t!("resolve.invalidPath")));
return Err(t!("resolve.invalidPath", path = path.to_string_lossy()).to_string());
}

// use DSC_CONFIG_ROOT env var as current directory
Expand Down
2 changes: 1 addition & 1 deletion dsc/tests/dsc_discovery.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Describe 'tests for resource discovery' {
Set-Content -Path "$testdrive/test.dsc.resource.json" -Value $manifest
$out = dsc resource list 2>&1
write-verbose -verbose ($out | Out-String)
$out | Should -Match 'WARN.*?Validation.*?Invalid manifest.*?version'
$out | Should -Match 'WARN.*?Validation.*?invalid version' -Because ($out | Out-String)
}
finally {
$env:DSC_RESOURCE_PATH = $oldPath
Expand Down
8 changes: 5 additions & 3 deletions dsc_lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dsc_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dsc_lib"
version = "3.0.0"
version = "3.1.0"
edition = "2021"

[profile.release]
Expand Down Expand Up @@ -38,7 +38,7 @@ tracing-indicatif = { version = "0.3" }
tree-sitter = "0.25"
tree-sitter-rust = "0.24"
tree-sitter-dscexpression = { path = "../tree-sitter-dscexpression" }
uuid = { version = "1.16", features = ["v4"] }
uuid = { version = "1.17", features = ["v4"] }
which = "7.0"

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions dsc_lib/locales/en-us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ invalidManifest = "Invalid manifest for resource '%{resource}'"
extensionResourceFound = "Extension found resource '%{resource}'"
callingExtension = "Calling extension '%{extension}' to discover resources"
extensionFoundResources = "Extension '%{extension}' found %{count} resources"
invalidManifestVersion = "Manifest '%{path}' has invalid version: %{err}"

[dscresources.commandResource]
invokeGet = "Invoking get for '%{resource}'"
Expand Down
6 changes: 3 additions & 3 deletions dsc_lib/src/discovery/command_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ pub fn load_manifest(path: &Path) -> Result<ImportedManifest, DscError> {
let manifest = match serde_yaml::from_str::<ExtensionManifest>(&contents) {
Ok(manifest) => manifest,
Err(err) => {
return Err(DscError::Validation(format!("Invalid manifest {path:?} version value: {err}")));
return Err(DscError::Validation(t!("discovery.commandDiscovery.invalidManifestVersion", path = path.to_string_lossy(), err = err).to_string()));
}
};
let extension = load_extension_manifest(path, &manifest)?;
Expand All @@ -628,7 +628,7 @@ pub fn load_manifest(path: &Path) -> Result<ImportedManifest, DscError> {

fn load_resource_manifest(path: &Path, manifest: &ResourceManifest) -> Result<DscResource, DscError> {
if let Err(err) = validate_semver(&manifest.version) {
return Err(DscError::Validation(format!("Invalid manifest {path:?} version value: {err}")));
return Err(DscError::Validation(t!("discovery.commandDiscovery.invalidManifestVersion", path = path.to_string_lossy(), err = err).to_string()));
}

let kind = if let Some(kind) = manifest.kind.clone() {
Expand Down Expand Up @@ -693,7 +693,7 @@ fn load_resource_manifest(path: &Path, manifest: &ResourceManifest) -> Result<Ds

fn load_extension_manifest(path: &Path, manifest: &ExtensionManifest) -> Result<DscExtension, DscError> {
if let Err(err) = validate_semver(&manifest.version) {
return Err(DscError::Validation(format!("Invalid manifest {path:?} version value: {err}")));
return Err(DscError::Validation(t!("discovery.commandDiscovery.invalidManifestVersion", path = path.to_string_lossy(), err = err).to_string()));
}

let mut capabilities: Vec<dscextension::Capability> = vec![];
Expand Down
2 changes: 1 addition & 1 deletion dscecho/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ split-debuginfo = "packed" # generates a seperate *.dwp/*.dSYM so the binary ca
strip = "symbols" # See split-debuginfo - allows us to drop the size by ~65%

[dependencies]
clap = { version = "4.1", features = ["derive"] }
clap = { version = "4.5", features = ["derive"] }
rust-i18n = { version = "3.1" }
schemars = { version = "0.8" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
Loading
Loading