Skip to content

Commit 9073d00

Browse files
committed
refactor finding resources and adapted resources, update list to use
1 parent 9ee037a commit 9073d00

File tree

7 files changed

+200
-115
lines changed

7 files changed

+200
-115
lines changed

dsc/src/subcommand.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub fn validate_config(config: &str) -> Result<(), DscError> {
337337

338338
resource_types.push(type_name.to_lowercase().to_string());
339339
}
340-
dsc.discover_resources(&resource_types);
340+
dsc.find_resources(&resource_types);
341341

342342
for resource_block in resources {
343343
let Some(type_name) = resource_block["type"].as_str() else {
@@ -402,33 +402,33 @@ pub fn resource(subcommand: &ResourceSubCommand, stdin: &Option<String>) {
402402
list_resources(&mut dsc, resource_name, adapter_name, description, tags, format);
403403
},
404404
ResourceSubCommand::Schema { resource , format } => {
405-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
405+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
406406
resource_command::schema(&dsc, resource, format);
407407
},
408408
ResourceSubCommand::Export { resource, format } => {
409-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
409+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
410410
resource_command::export(&mut dsc, resource, format);
411411
},
412412
ResourceSubCommand::Get { resource, input, path, all, format } => {
413-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
413+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
414414
if *all { resource_command::get_all(&dsc, resource, format); }
415415
else {
416416
let parsed_input = get_input(input, stdin, path);
417417
resource_command::get(&dsc, resource, parsed_input, format);
418418
}
419419
},
420420
ResourceSubCommand::Set { resource, input, path, format } => {
421-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
421+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
422422
let parsed_input = get_input(input, stdin, path);
423423
resource_command::set(&dsc, resource, parsed_input, format);
424424
},
425425
ResourceSubCommand::Test { resource, input, path, format } => {
426-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
426+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
427427
let parsed_input = get_input(input, stdin, path);
428428
resource_command::test(&dsc, resource, parsed_input, format);
429429
},
430430
ResourceSubCommand::Delete { resource, input, path } => {
431-
dsc.discover_resources(&[resource.to_lowercase().to_string()]);
431+
dsc.find_resources(&[resource.to_lowercase().to_string()]);
432432
let parsed_input = get_input(input, stdin, path);
433433
resource_command::delete(&dsc, resource, parsed_input);
434434
},

dsc_lib/src/configure/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,18 @@ impl Configurator {
335335
resource_type: resource.resource_type.clone(),
336336
result: set_result,
337337
};
338-
result.results.push(resource_result);
338+
result.results.push(resource_result);
339339
} else if dsc_resource.capabilities.contains(&Capability::Delete) {
340340
debug!("Resource implements delete and _exist is false");
341341
let before_result = dsc_resource.get(&desired)?;
342342
let start_datetime = chrono::Local::now();
343343
dsc_resource.delete(&desired)?;
344344
let end_datetime = chrono::Local::now();
345345
let after_result = dsc_resource.get(&desired)?;
346-
// convert get result to set result
346+
// convert get result to set result
347347
let set_result = match before_result {
348348
GetResult::Resource(before_response) => {
349-
let GetResult::Resource(after_result) = after_result else {
349+
let GetResult::Resource(after_result) = after_result else {
350350
return Err(DscError::NotSupported("Group resources not supported for delete".to_string()))
351351
};
352352
let before_value = serde_json::to_value(&before_response.actual_state)?;
@@ -614,7 +614,7 @@ impl Configurator {
614614
let mut required_resources = config.resources.iter().map(|p| p.resource_type.to_lowercase()).collect::<Vec<String>>();
615615
required_resources.sort_unstable();
616616
required_resources.dedup();
617-
self.discovery.discover_resources(&required_resources);
617+
self.discovery.find_resources(&required_resources);
618618
Ok(config)
619619
}
620620

0 commit comments

Comments
 (0)