Skip to content
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

Use serde tag enum representation for CommandStatus #2290

Merged

Conversation

didier-wenzek
Copy link
Contributor

As suggested by @Bravo555 with #2245 (comment), the reason field makes sense only for a Failed command.

Proposed changes

Attached the reason field to the only case where it makes sense: a Failed command.

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "camelCase", tag = "status")]
pub enum CommandStatus {
    Init,
    Executing,
    Successful,
    Failed { reason: String },
}

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

As suggested by thin-edge#2245 (comment),
the reason field makes sense only for a Failed command.

Signed-off-by: Didier Wenzek <[email protected]>
@didier-wenzek didier-wenzek temporarily deployed to Test Pull Request September 25, 2023 14:39 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #2290 (90d05dd) into main (3ba5851) will decrease coverage by 0.1%.
The diff coverage is 66.6%.

Additional details and impacted files
Files Changed Coverage Δ
...tedge_agent/src/tedge_operation_converter/tests.rs 90.5% <ø> (-0.2%) ⬇️
crates/extensions/c8y_mapper_ext/src/converter.rs 77.8% <0.0%> (-0.1%) ⬇️
...rates/extensions/tedge_config_manager/src/actor.rs 69.4% <0.0%> (ø)
crates/extensions/tedge_log_manager/src/actor.rs 69.2% <0.0%> (ø)
crates/core/tedge_api/src/messages.rs 92.3% <66.6%> (+0.2%) ⬆️
...ates/core/tedge_agent/src/restart_manager/tests.rs 93.9% <100.0%> (-0.2%) ⬇️
crates/extensions/c8y_mapper_ext/src/log_upload.rs 76.5% <100.0%> (ø)
...rates/extensions/tedge_config_manager/src/tests.rs 91.9% <100.0%> (ø)
crates/extensions/tedge_log_manager/src/tests.rs 92.2% <100.0%> (ø)

... and 4 files with indirect coverage changes

@github-actions
Copy link
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
288 0 3 288 100 1h0m25.244s

Copy link
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

LGTM

@didier-wenzek didier-wenzek merged commit 0d11c2d into thin-edge:main Sep 25, 2023
@didier-wenzek didier-wenzek deleted the refactor/improve-command-status branch September 25, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants