Skip to content

Conversation

screamerbg
Copy link
Contributor

Now that the mbed cache is a default Mbed CLI feature (since v1.5.0), a new offline mode feature can take benefit from it. Offline mode is achieved by utilize the cache for various Mbed CLI operations and also preventing Mbed CLI to access remote repositories to avoid connection errors while in offline.

Workflow
No impact to existing workflows.

This feature adds --offline switch to mbed import, mbed add, mbed update and mbed new to enable offline mode as described above.

How this works
While using --offline for mbed import/add/update/new, Mbed CLI will look up for locally cached repositories and use them without fetching new content from remote repositories.

  • If a repository is not cached, an error will be printed that the repository cannot be imported due to offline mode being enabled (even if connection is present).
  • If a repository is cached, there might be a corner case where one cached repository references another cached repository, but the local cache for the later is older and therefore the referenced hash is missing.

Lastly, Mbed CLI will print a banner when --offline is used to inform the user that they are in offline mode.

$ mbed import https://github.com/ARMmbed/mbed-os-example-mesh-minimal --offline

.=============================== OFFLINE MODE ================================.
|   Offline mode is enabled. No connections to remote repositories will be    |
|           made and only locally cached repositories will be used.           |
|   This might break some actions if non-cached repositories are referenced.  |
'============================================================================='

[mbed] Importing program "mesh-minimal" from "https://github.com/ARMmbed/mbed-os-example-mesh-minimal" at latest revision in the current branch
[mbed] Adding library "atmel-rf-driver" from "https://github.com/ARMmbed/atmel-rf-driver" at rev #2cd9abba3e37
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at rev #ad284b28064b
[mbed] Adding library "mcr20a-rf-driver" from "https://github.com/ARMmbed/mcr20a-rf-driver" at rev #9aac10474702
[mbed] Adding library "sd-driver" from "https://github.com/ARMmbed/sd-driver" at rev #51dc1d2b2c07

Documentation
Documentation is not included with this PR. @AnotherButler please advise where offline mode should be mentioned. Perhaps in https://github.com/ARMmbed/mbed-cli#repository-caching or https://github.com/ARMmbed/mbed-cli#importing-an-existing-program, or both?

Tests
mbed new --offline and mbed update --offline is tested via circle.yml

Resolves #351

@screamerbg screamerbg requested review from sg- and theotherjimmy March 31, 2018 14:18
Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@theotherjimmy
Copy link
Contributor

Testing might be improved by forcing the network to not be accessible for the part of the tests that test this feature.

Copy link
Contributor

@sg- sg- left a comment

Choose a reason for hiding this comment

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

👍

@AnotherButler
Copy link
Contributor

I would think repository caching would be a good place.

@screamerbg screamerbg force-pushed the feature_offline_mode branch from cc25c9f to 21ddb46 Compare April 27, 2018 16:20
@screamerbg
Copy link
Contributor Author

screamerbg commented Apr 27, 2018

Just rebased this on top of master (1.5.1) and added documentation entry for offline mode. @AnotherButler please review and make changes where necessary.

@screamerbg
Copy link
Contributor Author

Bump @AnotherButler

@screamerbg screamerbg force-pushed the feature_offline_mode branch from 20cf79a to f5dd41e Compare May 9, 2018 09:17
@screamerbg screamerbg merged commit 0ca65a8 into ARMmbed:master May 14, 2018
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.

4 participants