Skip to content

Commit

Permalink
Merge pull request #2905 from Ruadhri17/sm-plugin-download-empty-url
Browse files Browse the repository at this point in the history
feat(sm-plugin): skip package download if the url is empty
  • Loading branch information
Ruadhri17 authored May 29, 2024
2 parents 8bd6a3a + 05a644e commit 0b10fa0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions crates/common/download/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ impl DownloadInfo {
pub fn url(&self) -> &str {
self.url.as_str()
}

pub fn is_empty(&self) -> bool {
self.url.trim().is_empty()
}
}

/// Possible authentication schemes
Expand Down
15 changes: 8 additions & 7 deletions crates/core/tedge_api/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,14 @@ impl SoftwareUpdateCommand {
.find(|&items| items.plugin_type == module_type)
{
for item in items.modules.iter() {
let module = SoftwareModule {
module_type: Some(module_type.to_string()),
name: item.name.clone(),
version: item.version.clone(),
url: item.url.clone(),
file_path: None,
};
let module = SoftwareModule::new(
Some(module_type.to_string()),
item.name.clone(),
item.version.clone(),
item.url.clone(),
None,
);

match item.action {
None => {}
Some(SoftwareModuleAction::Install) => {
Expand Down
5 changes: 5 additions & 0 deletions crates/core/tedge_api/src/software.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ impl SoftwareModule {
Some(version) if version.is_empty() => self.version = None,
_ => {}
};

match &self.url {
Some(url) if url.is_empty() => self.url = None,
_ => {}
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ Manual software_update operation request
... expected_status=failed
... c8y_fragment=c8y_SoftwareUpdate

Manual software_update operation request with empty url
Publish and Verify Local Command
... topic=te/device/main///cmd/software_update/local-3333
... payload={"status":"init","updateList":[{"type":"apt","modules":[{"name":"tedge","version":"latest","url":"","action":"install"}]}]}
... expected_status=successful
... c8y_fragment=c8y_SoftwareUpdate

Operation log uploaded automatically with auto_log_upload setting as on-failure
Execute Command tedge config set c8y.operations.auto_log_upload on-failure
Restart Service tedge-mapper-c8y
Expand Down

0 comments on commit 0b10fa0

Please sign in to comment.