Skip to content
Open
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
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
files: ./coverage.lcov
files: ./coverage.lcov

semver:
name: semverver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v1
with:
crate-name: hawkbit
3 changes: 3 additions & 0 deletions .vscode/settings.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addition of this file, the .vscode/settings.json feels wrong.
I think it should NOT be added.
(If it must be added, it should be done in a separate commit.)

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.cargo.allFeatures": true
}
24 changes: 12 additions & 12 deletions hawkbit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "hawkbit"
version = "0.6.0"
version = "0.7.0"
authors = ["Guillaume Desmottes <[email protected]>"]
edition = "2018"
edition = "2021"
categories = ["api-bindings"]
description = "Client side API to interact with Eclipse hawkBit"
license = "MIT OR Apache-2.0"
Expand All @@ -12,29 +12,29 @@ documentation = "https://docs.rs/hawkbit_mock/"

[dependencies]
reqwest = { version = "0.11", features = ["json", "stream"] }
tokio = { version = "1.1", features = ["time", "fs"] }
tokio = { version = "1.21", features = ["time", "fs"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
url = "2.2"
strum = { version = "0.21", features = ["derive"] }
url = "2.3"
strum = { version = "0.24", features = ["derive"] }
cfg-if = "1.0"
digest = { version = "0.9", optional = true }
md-5 = { version = "0.9", optional = true }
sha-1 = { version = "0.9", optional = true }
sha2 = { version = "0.9", optional = true }
digest = { version = "0.10", optional = true }
md-5 = { version = "0.10", optional = true }
sha-1 = { version = "0.10", optional = true }
sha2 = { version = "0.10", optional = true }
generic-array = {version = "0.14", optional = true }
futures = "0.3"
bytes = "1.0"
bytes = "1.2"

[dev-dependencies]
hawkbit_mock = { path = "../hawkbit_mock/" }
structopt = "0.3"
anyhow = "1.0"
log = "0.4"
env_logger = "0.8"
env_logger = "0.9"
tempdir = "0.3"
assert_matches = "1.4"
assert_matches = "1.5"

[features]
hash-digest= ["digest", "generic-array"]
Expand Down
1 change: 1 addition & 0 deletions hawkbit/src/ddi/cancel_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl CancelAction {

#[derive(Debug, Deserialize)]
struct CancelReply {
#[allow(dead_code)]
id: String,
#[serde(rename = "cancelAction")]
cancel_action: CancelActionReply,
Expand Down
39 changes: 25 additions & 14 deletions hawkbit/src/ddi/deployment_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct Reply {
id: String,
deployment: Deployment,
#[serde(rename = "actionHistory")]
#[allow(dead_code)]
action_history: Option<ActionHistory>,
}

Expand All @@ -61,7 +62,7 @@ struct Deployment {
}

/// How the download or update should be processed by the target.
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum Type {
/// Do not process yet
Expand All @@ -73,7 +74,7 @@ pub enum Type {
}

/// Separation of download and installation by defining a maintenance window for the installation.
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum MaintenanceWindow {
/// Maintenance window is available
Expand Down Expand Up @@ -109,8 +110,11 @@ struct ArtifactInternal {

#[derive(Debug, Deserialize, Clone)]
struct Hashes {
#[cfg(feature = "hash-sha1")]
sha1: String,
#[cfg(feature = "hash-md5")]
md5: String,
#[cfg(feature = "hash-sha256")]
sha256: String,
}

Expand Down Expand Up @@ -192,6 +196,7 @@ impl<'de> Deserialize<'de> for Links {
#[derive(Debug)]
struct Download {
content: Link,
#[allow(dead_code)]
md5sum: Option<Link>,
}

Expand All @@ -205,8 +210,10 @@ struct Links {

#[derive(Debug, Deserialize)]
struct ActionHistory {
#[allow(dead_code)]
status: String,
#[serde(default)]
#[allow(dead_code)]
messages: Vec<String>,
}

Expand Down Expand Up @@ -396,7 +403,7 @@ impl<'a> Artifact<'a> {
.links
.https
.as_ref()
.or_else(|| self.artifact.links.http.as_ref())
.or(self.artifact.links.http.as_ref())
.expect("Missing content link in for artifact");

let resp = self
Expand Down Expand Up @@ -506,6 +513,7 @@ impl<'a> Artifact<'a> {
#[derive(Debug)]
pub struct DownloadedArtifact {
file: PathBuf,
#[allow(dead_code)]
hashes: Hashes,
}

Expand All @@ -516,6 +524,7 @@ cfg_if::cfg_if! {
task::Poll,
};
use digest::Digest;
use digest::OutputSizeUser;

const HASH_BUFFER_SIZE: usize = 4096;

Expand All @@ -538,8 +547,9 @@ cfg_if::cfg_if! {
struct DownloadHasher<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as OutputSizeUser>::OutputSize: core::ops::Add,
<<T as OutputSizeUser>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,

{
hasher: T,
expected: String,
Expand All @@ -549,8 +559,8 @@ cfg_if::cfg_if! {
impl<T> DownloadHasher<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>
<T as OutputSizeUser>::OutputSize: core::ops::Add,
<<T as OutputSizeUser>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
{
fn update(&mut self, data: impl AsRef<[u8]>) {
self.hasher.update(data);
Expand Down Expand Up @@ -603,8 +613,8 @@ cfg_if::cfg_if! {
struct DownloadStreamHash<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as OutputSizeUser>::OutputSize: core::ops::Add,
<<T as OutputSizeUser>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
{
stream: Box<dyn Stream<Item = Result<Bytes, Error>> + Unpin + Send + Sync>,
hasher: DownloadHasher<T>,
Expand All @@ -613,10 +623,10 @@ cfg_if::cfg_if! {
impl<T> Stream for DownloadStreamHash<T>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
T: Unpin,
T: Clone,
<T as OutputSizeUser>::OutputSize: core::ops::Add,
<<T as OutputSizeUser>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
{
type Item = Result<Bytes, Error>;

Expand Down Expand Up @@ -648,7 +658,7 @@ cfg_if::cfg_if! {
}
}

impl<'a> DownloadedArtifact {
impl DownloadedArtifact {
fn new(file: PathBuf, hashes: Hashes) -> Self {
Self { file, hashes }
}
Expand All @@ -662,8 +672,9 @@ impl<'a> DownloadedArtifact {
async fn hash<T>(&self, mut hasher: DownloadHasher<T>) -> Result<(), Error>
where
T: Digest,
<T as Digest>::OutputSize: core::ops::Add,
<<T as Digest>::OutputSize as core::ops::Add>::Output: generic_array::ArrayLength<u8>,
<T as OutputSizeUser>::OutputSize: core::ops::Add,
<<T as OutputSizeUser>::OutputSize as core::ops::Add>::Output:
generic_array::ArrayLength<u8>,
{
use tokio::io::AsyncReadExt;

Expand Down
4 changes: 2 additions & 2 deletions hawkbit_mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/collabora/hawkbit-rs"
documentation = "https://docs.rs/hawkbit/"

[dependencies]
hawkbit = { version = "0.6.0", path = "../hawkbit/" }
httpmock = "0.5.4"
hawkbit = { version = "0.7.0", path = "../hawkbit/" }
httpmock = "0.6.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
18 changes: 9 additions & 9 deletions hawkbit_mock/src/ddi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{

use httpmock::{
Method::{GET, POST, PUT},
MockRef, MockRefExt, MockServer,
Mock, MockExt, MockServer,
};
use serde_json::{json, Map, Value};

Expand Down Expand Up @@ -178,7 +178,7 @@ impl Target {
self.cancel_action.borrow().as_ref(),
));

let mut old = MockRef::new(old, &self.server);
let mut old = Mock::new(old, &self.server);
old.delete();
}

Expand Down Expand Up @@ -349,7 +349,7 @@ impl Target {
finished: Finished,
progress: Option<serde_json::Value>,
details: Vec<&str>,
) -> MockRef<'_> {
) -> Mock<'_> {
self.server.mock(|when, then| {
let expected = match progress {
Some(progress) => json!({
Expand Down Expand Up @@ -471,7 +471,7 @@ impl Target {
execution: Execution,
finished: Finished,
details: Vec<&str>,
) -> MockRef<'_> {
) -> Mock<'_> {
self.server.mock(|when, then| {
let expected = json!({
"id": cancel_id,
Expand Down Expand Up @@ -499,30 +499,30 @@ impl Target {

/// Return the number of times the poll API has been called by the client.
pub fn poll_hits(&self) -> usize {
let mock = MockRef::new(self.poll.get(), &self.server);
let mock = Mock::new(self.poll.get(), &self.server);
mock.hits()
}

/// Return the number of times the target configuration has been uploaded by the client.
pub fn config_data_hits(&self) -> usize {
self.config_data.borrow().as_ref().map_or(0, |m| {
let mock = MockRef::new(m.mock, &self.server);
let mock = Mock::new(m.mock, &self.server);
mock.hits()
})
}

/// Return the number of times the deployment details have been fetched by the client.
pub fn deployment_hits(&self) -> usize {
self.deployment.borrow().as_ref().map_or(0, |m| {
let mock = MockRef::new(m.mock, &self.server);
let mock = Mock::new(m.mock, &self.server);
mock.hits()
})
}

/// Return the number of times the cancel action URL has been fetched by the client.
pub fn cancel_action_hits(&self) -> usize {
self.cancel_action.borrow().as_ref().map_or(0, |m| {
let mock = MockRef::new(m.mock, &self.server);
let mock = Mock::new(m.mock, &self.server);
mock.hits()
})
}
Expand All @@ -536,7 +536,7 @@ struct PendingAction {

impl Drop for PendingAction {
fn drop(&mut self) {
let mut mock = MockRef::new(self.mock, &self.server);
let mut mock = Mock::new(self.mock, &self.server);
mock.delete();
}
}
Expand Down