Repository navigation
[cli] Introduce images command to replace find
#5274
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
Merged
+552
−380
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
803e2df
[cli] Introduce `images` command to replace `find`
Laefy 3ead601
[cli] Introduce localization library
Laefy 49664ed
[cli] Uniformize `find` deprecation message
Laefy 9075212
[cli] Rename library to `user_messages`
Laefy aa2ec7a
[cli] Fix driver deprecation warning repetition
Laefy e51888c
[cli] Fix CLI tests
Laefy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright (C) Canonical, Ltd. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify it under | ||
| * the terms of the GNU Lesser General Public License version 3, as published by | ||
| * the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
| * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <fmt/format.h> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace multipass | ||
| { | ||
|
|
||
| template <typename DeprecatedFeature, typename AdviceMessage> | ||
| std::string make_deprecation_warning(DeprecatedFeature&& deprecated_feature, AdviceMessage&& advice) | ||
|
Laefy marked this conversation as resolved.
|
||
| { | ||
| return fmt::format( | ||
| "*** Warning: {} is deprecated and will be removed in an upcoming release. ***\n\n" | ||
| "{}\n\n", | ||
| std::forward<DeprecatedFeature>(deprecated_feature), | ||
| std::forward<AdviceMessage>(advice)); | ||
| } | ||
|
|
||
| } // namespace multipass | ||
68 changes: 68 additions & 0 deletions
68
include/multipass/user_messages/driver_deprecation_warning.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Copyright (C) Canonical, Ltd. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify it under | ||
| * the terms of the GNU Lesser General Public License version 3, as published by | ||
| * the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
| * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "deprecation_warning.h" | ||
|
|
||
| #include <fmt/format.h> | ||
| #include <regex> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace multipass | ||
| { | ||
|
|
||
| // TODO@deprecations remove | ||
| inline bool is_repeated_driver_deprecation_warning(const std::string& log_line) | ||
| { | ||
| static const std::regex warning{R"(^\*\*\* Warning: the \S+ driver is deprecated)"}; | ||
|
ricab marked this conversation as resolved.
|
||
| static bool warned = false; | ||
| return std::regex_search(log_line, warning) && std::exchange(warned, true); | ||
| } | ||
|
|
||
| template <typename DeprecatedDriverName, | ||
| typename RecommendedDriverName, | ||
| typename RecommendedDriverId> | ||
| std::string make_driver_deprecation_warning(DeprecatedDriverName&& deprecated_name, | ||
| RecommendedDriverName&& recommended_name, | ||
| RecommendedDriverId&& recommended_id, | ||
| bool migrationful) | ||
| { | ||
| const auto deprecated_feature = fmt::format( | ||
| "the {} driver", | ||
| std::forward<DeprecatedDriverName>(deprecated_name)); | ||
|
|
||
| constexpr auto migrationless_advice = | ||
| "We recommend switching to the new {0} driver as soon as possible (multipass set " | ||
| "local.driver={1}). Your instances will not be destroyed but they will be unreachable from " | ||
| "the new driver. You can switch back to the old driver for now, but you will need to " | ||
| "manually recreate any instances you want to keep in the next release."; | ||
|
|
||
| constexpr auto migrationful_advice = | ||
| "When you are ready to have your instances migrated, please stop them (multipass stop " | ||
| "--all) and switch to the new {0} driver (multipass set local.driver={1})."; | ||
|
|
||
| const auto deprecation_advice = fmt::format( | ||
| fmt::runtime(migrationful ? migrationful_advice : migrationless_advice), | ||
| std::forward<RecommendedDriverName>(recommended_name), | ||
| std::forward<RecommendedDriverId>(recommended_id)); | ||
|
|
||
| return make_deprecation_warning(deprecated_feature, deprecation_advice); | ||
| } | ||
|
|
||
| } // namespace multipass | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.