Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
7 changes: 6 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ if (!$SkipBuild) {
# make sure dependencies are built first so clippy runs correctly
$windows_projects = @("pal", "registry", "reboot_pending", "wmi-adapter")

$macOS_projects = @("resources/brew")

# projects are in dependency order
$projects = @(
"tree-sitter-dscexpression",
Expand All @@ -170,7 +172,6 @@ if (!$SkipBuild) {
"osinfo",
"powershell-adapter",
"process",
"resources/brew",
"runcommandonset",
"tools/dsctest",
"tools/test_group_resource",
Expand All @@ -187,6 +188,10 @@ if (!$SkipBuild) {
Get-ChildItem -Path $target -Recurse -Hidden | ForEach-Object { $_.Attributes = 'Normal' }
}

if ($IsMacOS) {
$projects += $macOS_projects
}

$failed = $false
foreach ($project in $projects) {
## Build format_json
Expand Down
14 changes: 7 additions & 7 deletions dsc/src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub fn validate_config(config: &str) -> Result<(), DscError> {

resource_types.push(type_name.to_lowercase().to_string());
}
dsc.discover_resources(&resource_types);
dsc.find_resources(&resource_types);

for resource_block in resources {
let Some(type_name) = resource_block["type"].as_str() else {
Expand Down Expand Up @@ -402,33 +402,33 @@ pub fn resource(subcommand: &ResourceSubCommand, stdin: &Option<String>) {
list_resources(&mut dsc, resource_name, adapter_name, description, tags, format);
},
ResourceSubCommand::Schema { resource , format } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
resource_command::schema(&dsc, resource, format);
},
ResourceSubCommand::Export { resource, format } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
resource_command::export(&mut dsc, resource, format);
},
ResourceSubCommand::Get { resource, input, path, all, format } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
if *all { resource_command::get_all(&dsc, resource, format); }
else {
let parsed_input = get_input(input, stdin, path);
resource_command::get(&dsc, resource, parsed_input, format);
}
},
ResourceSubCommand::Set { resource, input, path, format } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
let parsed_input = get_input(input, stdin, path);
resource_command::set(&dsc, resource, parsed_input, format);
},
ResourceSubCommand::Test { resource, input, path, format } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
let parsed_input = get_input(input, stdin, path);
resource_command::test(&dsc, resource, parsed_input, format);
},
ResourceSubCommand::Delete { resource, input, path } => {
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
dsc.find_resources(&[resource.to_lowercase().to_string()]);
let parsed_input = get_input(input, stdin, path);
resource_command::delete(&dsc, resource, parsed_input);
},
Expand Down
8 changes: 4 additions & 4 deletions dsc_lib/src/configure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,18 @@ impl Configurator {
resource_type: resource.resource_type.clone(),
result: set_result,
};
result.results.push(resource_result);
result.results.push(resource_result);
} else if dsc_resource.capabilities.contains(&Capability::Delete) {
debug!("Resource implements delete and _exist is false");
let before_result = dsc_resource.get(&desired)?;
let start_datetime = chrono::Local::now();
dsc_resource.delete(&desired)?;
let end_datetime = chrono::Local::now();
let after_result = dsc_resource.get(&desired)?;
// convert get result to set result
// convert get result to set result
let set_result = match before_result {
GetResult::Resource(before_response) => {
let GetResult::Resource(after_result) = after_result else {
let GetResult::Resource(after_result) = after_result else {
return Err(DscError::NotSupported("Group resources not supported for delete".to_string()))
};
let before_value = serde_json::to_value(&before_response.actual_state)?;
Expand Down Expand Up @@ -614,7 +614,7 @@ impl Configurator {
let mut required_resources = config.resources.iter().map(|p| p.resource_type.to_lowercase()).collect::<Vec<String>>();
required_resources.sort_unstable();
required_resources.dedup();
self.discovery.discover_resources(&required_resources);
self.discovery.find_resources(&required_resources);
Ok(config)
}

Expand Down
Loading