-
Notifications
You must be signed in to change notification settings - Fork 55
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
[CIT-514] Add send software list via http #400
[CIT-514] Add send software list via http #400
Conversation
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
f0f3759
to
5f72151
Compare
…/CIT-514_sw_list_over_http
Codecov Report
@@ Coverage Diff @@
## main #400 +/- ##
==========================================
- Coverage 64.73% 64.06% -0.68%
==========================================
Files 105 106 +1
Lines 6667 6809 +142
==========================================
+ Hits 4316 4362 +46
- Misses 2351 2447 +96
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many unwraps, should replace them with proper error handling.
common/mqtt_client/src/lib.rs
Outdated
{ | ||
fn from(topic: T) -> Self { | ||
Topic { | ||
name: topic.to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use into() instead of to_string()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is a generic function over type T
and type T
is bound to Display
using into()
is not possible, you have to use lower level function as for example to_string()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more appropriate to implement TryFrom
and to call Topic::new()
.
Indeed a string might not be a valid topic name.
Thanks, yes, I'm working on it, this is still draft. |
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
c25eb52
to
3e3dc74
Compare
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
3e3dc74
to
c04813a
Compare
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
1287dcb
to
dd36cf8
Compare
@@ -27,7 +28,8 @@ impl TEdgeComponent for CumulocitySoftwareManagementMapper { | |||
let mqtt_config = mqtt_config(&tedge_config)?; | |||
let mqtt_client = Client::connect("SM-C8Y-Mapper", &mqtt_config).await?; | |||
|
|||
let sm_mapper = CumulocitySoftwareManagement::new(mqtt_client); | |||
let mut sm_mapper = CumulocitySoftwareManagement::new(mqtt_client, tedge_config); | |||
let () = sm_mapper.init().await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why init is async here, can it run without init?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little tricky one, this init
may fail and it seemed to be fair for it to be separated from the whole run
method such that if you need to handle any error with it it would be easier, additionally it requires &mut self
on the object to modify it (initialize c8y_client_id
from external sources) and to not need to make entire run
method mut
.
…/CIT-514_sw_list_over_http
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
common/mqtt_client/src/lib.rs
Outdated
{ | ||
fn from(topic: T) -> Self { | ||
Topic { | ||
name: topic.to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more appropriate to implement TryFrom
and to call Topic::new()
.
Indeed a string might not be a valid topic name.
match tokio::time::timeout(Duration::from_secs(10), subscriber.next()).await { | ||
Ok(Some(msg)) => msg.payload_str()?.to_string(), | ||
Ok(None) => return Err(SMCumulocityMapperError::InvalidMqttMessage), | ||
Err(err) => return Err(SMCumulocityMapperError::FromElapsed(err)), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we receive some msg that is not a JwtToken (i.e. with a code that is not 71)?
- Is there a guaranty to receive only JwtToken on
c8y/s/dat
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no explicit note that only the token can be send there, but also there is no mention in the documentation that the topic is used for anything else.
mapper/tedge_mapper/src/sm_c8y_mapper/smartrest_deserializer.rs
Outdated
Show resolved
Hide resolved
f27b78a
to
bb19293
Compare
add try_new to jwt struct, remove from for Topic Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
bb19293
to
44db750
Compare
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
c8726fd
to
ba4f913
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
@@ -157,6 +157,44 @@ impl SmartRestUpdateSoftwareModule { | |||
} | |||
} | |||
|
|||
type JwtToken = String; | |||
|
|||
#[derive(Debug, Serialize, Deserialize, PartialEq)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not get why do we need serialize, deserialize here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't, we only need deserialize.
…/CIT-514_sw_list_over_http
Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
a058605
to
fda085d
Compare
* Add send software list via http * Add tests for c8y structs * Add new tests, change pannicable string building to safe version Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com>
* [CIT-527] software management doc * update pics * move docs to tutorials * Update summary * fix typos * [CIT-471] Add mapper integration tests (#397) * [CIT-471] Add mapper integration tests Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com> Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com> Co-authored-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com> * [CIT-525] enable sm services (#396) * [CIT-525] extend tedge dis/connect to dis/enable sm services * enable services postinstall * fix minor issues * address review comments * update the println * remove to_do macro * add system tests * add use_agent flag * refactor common code * address review comments * address review comment * Update tedge/src/cli/connect/command.rs * update log Co-authored-by: Pradeep Kumar K J <pradeepkumar.kj@sofwareag.com> Co-authored-by: Sebastian Büttner <sebastian.buettner@softwareag.com> * Also build the tedge_agent debian package on github (#399) * Also build the sm agent package Signed-off-by: Michael Abel <info@abel-ikt.de> * Also build the package for amd64 * tenant-admin hint (#340) Introducing hint to check user rights in cumulocity on HTTP error 503 * [CIT-522] update the mqtt port document (#398) * update the mqtt port document * fix typo * address review comments Co-authored-by: Pradeep Kumar K J <pradeepkumar.kj@sofwareag.com> Co-authored-by: Sebastian Büttner <sebastian.buettner@softwareag.com> * [CIT-514] Add send software list via http (#400) * Add send software list via http * Add tests for c8y structs * Add new tests, change pannicable string building to safe version Signed-off-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com> * [CIT-542] tedge-agent requires apt plugin as dependency (#406) * [CIT-551] Make the workflow (temporarily) continue even when tarpaulin fails. (#407) Signed-off-by: Michael Abel <info@abel-ikt.de> * [CIT-532] Subscribe to cloud operations only after device creation (#404) * [CIT-532] Subscribe to cloud operations only after device creation * [CIT-551] Make the job pass (temporarily) on job level as well (#408) * Make it continue even when tarpaulin fails Signed-off-by: Michael Abel <info@abel-ikt.de> * [CIT-551] Make the job pass on job level as well * fix a typo * address review comments * Update software-management.md Co-authored-by: Pradeep Kumar K J <pradeepkumar.kj@sofwareag.com> Co-authored-by: Rina Fujino <18257209+rina23q@users.noreply.github.com> Co-authored-by: Lukasz Woznicki <lukasz.woznicki@softwareag.com> Co-authored-by: Sebastian Büttner <sebastian.buettner@softwareag.com> Co-authored-by: Michael Abel <75477722+abelikt@users.noreply.github.com> Co-authored-by: Lukasz Woznicki <75632179+makr11st@users.noreply.github.com> Co-authored-by: Albin Suresh <albin.suresh@softwareag.com>
Proposed changes
Add feature to publish software list to c8y via http.
Types of changes
What types of changes does your code introduce to
thin-edge.io
?Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINES