thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
211 stars 55 forks source link

feat: create bridge configuration in offline mode #2843

Closed Ruadhri17 closed 1 month ago

Ruadhri17 commented 2 months ago

Proposed changes

This PR adds a --offline flag to tedge connect c8y that skips connection checks and device registration, which allows the creation of bridge configuration and enables all services while offline.

TODO:

Types of changes

Paste Link to the issue

Checklist

Further comments

github-actions[bot] commented 2 months ago

Robot Results

:white_check_mark: Passed :x: Failed :next_track_button: Skipped Total Pass % :stopwatch: Duration
433 0 3 433 100 0s
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 50 lines in your changes are missing coverage. Please review.

Project coverage is 77.3%. Comparing base (33e6890) to head (d0a5ff1). Report is 8 commits behind head on main.

Additional details and impacted files | [Files](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2843?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge) | Coverage Δ | | |---|---|---| | [crates/core/tedge/src/cli/reconnect/command.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2843?src=pr&el=tree&filepath=crates%2Fcore%2Ftedge%2Fsrc%2Fcli%2Freconnect%2Fcommand.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvcmUvdGVkZ2Uvc3JjL2NsaS9yZWNvbm5lY3QvY29tbWFuZC5ycw==) | `0.0% <0.0%> (ø)` | | | [crates/core/tedge/src/cli/connect/cli.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2843?src=pr&el=tree&filepath=crates%2Fcore%2Ftedge%2Fsrc%2Fcli%2Fconnect%2Fcli.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvcmUvdGVkZ2Uvc3JjL2NsaS9jb25uZWN0L2NsaS5ycw==) | `0.0% <0.0%> (ø)` | | | [crates/core/tedge/src/cli/connect/command.rs](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2843?src=pr&el=tree&filepath=crates%2Fcore%2Ftedge%2Fsrc%2Fcli%2Fconnect%2Fcommand.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge#diff-Y3JhdGVzL2NvcmUvdGVkZ2Uvc3JjL2NsaS9jb25uZWN0L2NvbW1hbmQucnM=) | `0.0% <0.0%> (ø)` | | ... and [11 files with indirect coverage changes](https://app.codecov.io/gh/thin-edge/thin-edge.io/pull/2843/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thin-edge)
reubenmiller commented 2 months ago

This correctly implements what is described by #2831.

However, looking at the code and the command help, I find the connect command more complicated than required. One cause of this complexity is that the bridge file is removed when the connection check fails.

What about:

  • stop removing the bridge configuration on failed connection check
  • perform no connection check on connect unless explicitly requested with --test.

So:

  • tedge connect c8y would behave as tedge connect c8y --offline as implemented here
  • tedge connect c8y --test would behave as tedge connect c8y as currently implemented when there is no c8y bridge configuration and as tedge connect c8y --test when there is a c8y bridge configuration.

I like the suggestions, though changing the behaviour of tedge connect c8y would be a breaking change, as some people might already rely on the "connect test" on the configuration before proceeding.