Skip to content

Commit 07dc880

Browse files
committed
[image] Filter unsupported images at manifest parsing
[image] Filter unsupported images at manifest parsing
1 parent 628dea7 commit 07dc880

File tree

15 files changed

+19
-130
lines changed

15 files changed

+19
-130
lines changed

include/multipass/exceptions/unsupported_image_exception.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

include/multipass/image_host/custom_image_host.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class CustomVMImageHost final : public BaseVMImageHost
4444

4545
std::optional<VMImageInfo> info_for(const Query& query) override;
4646
std::vector<std::pair<std::string, VMImageInfo>> all_info_for(const Query& query) override;
47-
std::vector<VMImageInfo> all_images_for(const std::string& remote_name,
48-
const bool allow_unsupported) override;
47+
std::vector<VMImageInfo> all_images_for(const std::string& remote_name) override;
4948
std::vector<std::string> supported_remotes() override;
5049

5150
private:

include/multipass/image_host/ubuntu_image_host.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class UbuntuVMImageHost final : public BaseVMImageHost
4040

4141
std::optional<VMImageInfo> info_for(const Query& query) override;
4242
std::vector<std::pair<std::string, VMImageInfo>> all_info_for(const Query& query) override;
43-
std::vector<VMImageInfo> all_images_for(const std::string& remote_name,
44-
const bool allow_unsupported) override;
43+
std::vector<VMImageInfo> all_images_for(const std::string& remote_name) override;
4544
std::vector<std::string> supported_remotes() override;
4645

4746
private:

include/multipass/image_host/vm_image_host.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ class VMImageHost : private DisabledCopyMove
3939
virtual std::optional<VMImageInfo> info_for(const Query& query) = 0;
4040
virtual std::vector<std::pair<std::string, VMImageInfo>> all_info_for(const Query& query) = 0;
4141
virtual VMImageInfo info_for_full_hash(const std::string& full_hash) = 0;
42-
virtual std::vector<VMImageInfo> all_images_for(const std::string& remote_name,
43-
const bool allow_unsupported) = 0;
42+
virtual std::vector<VMImageInfo> all_images_for(const std::string& remote_name) = 0;
4443
virtual void for_each_entry_do(const Action& action) = 0;
4544
virtual std::vector<std::string> supported_remotes() = 0;
4645
virtual void update_manifests(const bool force_update) = 0;

include/multipass/query.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ class Query
3636
bool persistent;
3737
std::string remote_name;
3838
Type query_type;
39-
bool allow_unsupported{false};
4039
};
4140
} // namespace multipass

src/client/cli/cmd/find.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ mp::ParseCode cmd::Find::parse_args(mp::ArgParser* parser)
7272
"then search ‘daily‘. <string> can be a partial image hash or a "
7373
"release version, codename or alias.",
7474
"[<remote:>][<string>]");
75-
QCommandLineOption unsupportedOption("show-unsupported",
76-
"Show unsupported cloud images as well");
7775
QCommandLineOption formatOption("format",
7876
"Output list in the requested format.\nValid formats are: "
7977
"table (default), json, csv and yaml",
@@ -82,7 +80,7 @@ mp::ParseCode cmd::Find::parse_args(mp::ArgParser* parser)
8280
const QCommandLineOption force_manifest_network_download(
8381
"force-update",
8482
"Force the image information to update from the network");
85-
parser->addOptions({unsupportedOption, formatOption, force_manifest_network_download});
83+
parser->addOptions({formatOption, force_manifest_network_download});
8684

8785
auto status = parser->commandParse(this);
8886

@@ -116,8 +114,7 @@ mp::ParseCode cmd::Find::parse_args(mp::ArgParser* parser)
116114
request.set_search_string(search_string.toStdString());
117115
}
118116
}
119-
120-
request.set_allow_unsupported(parser->isSet(unsupportedOption));
117+
121118
request.set_force_manifest_network_download(parser->isSet(force_manifest_network_download));
122119

123120
status = handle_format_option(parser, &chosen_formatter, cerr);

src/daemon/daemon.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mp::Query query_from(const mp::LaunchRequest* request, const std::string& name)
127127
else if (QString::fromStdString(image).startsWith("http"))
128128
query_type = mp::Query::Type::HttpDownload;
129129

130-
return {name, image, false, request->remote_name(), query_type, true};
130+
return {name, image, false, request->remote_name(), query_type};
131131
}
132132

133133
auto make_cloud_init_vendor_config(const mp::SSHKeyProvider& key_provider,
@@ -282,7 +282,7 @@ auto fetch_image_for(const std::string& name,
282282
auto stub_prepare = [](const mp::VMImage&) -> mp::VMImage { return {}; };
283283
auto stub_progress = [](int download_type, int progress) { return true; };
284284

285-
mp::Query query{name, "", false, "", mp::Query::Type::Alias, false};
285+
mp::Query query{name, "", false, "", mp::Query::Type::Alias};
286286

287287
return vault.fetch_image(factory.fetch_type(),
288288
query,
@@ -1621,8 +1621,7 @@ try
16211621
request->search_string(),
16221622
false,
16231623
request->remote_name(),
1624-
Query::Type::Alias,
1625-
request->allow_unsupported()});
1624+
Query::Type::Alias});
16261625
}
16271626
catch (const std::exception& e)
16281627
{
@@ -1658,7 +1657,7 @@ try
16581657
auto action = [&images_found, request, &response](const std::string& remote,
16591658
const mp::VMImageInfo& info) {
16601659
if (remote != mp::snapcraft_remote &&
1661-
(info.supported || request->allow_unsupported()) && !info.aliases.empty() &&
1660+
!info.aliases.empty() &&
16621661
images_found.find(info.release_title.toStdString()) == images_found.end())
16631662
{
16641663
add_aliases(response.mutable_images_info(), remote, info);
@@ -1675,7 +1674,7 @@ try
16751674
request->force_manifest_network_download());
16761675
const auto& remote = request->remote_name();
16771676
auto image_host = config->vault->image_host_for(remote);
1678-
auto vm_images_info = image_host->all_images_for(remote, request->allow_unsupported());
1677+
auto vm_images_info = image_host->all_images_for(remote);
16791678

16801679
for (const auto& info : vm_images_info)
16811680
add_aliases(response.mutable_images_info(), remote, info);

src/daemon/default_vm_image_vault.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <multipass/exceptions/aborted_download_exception.h>
2121
#include <multipass/exceptions/create_image_exception.h>
2222
#include <multipass/exceptions/image_vault_exceptions.h>
23-
#include <multipass/exceptions/unsupported_image_exception.h>
2423
#include <multipass/file_ops.h>
2524
#include <multipass/format.h>
2625
#include <multipass/json_utils.h>
@@ -564,10 +563,6 @@ void mp::DefaultVMImageVault::update_images(const FetchType& fetch_type,
564563
keys_to_update.push_back(record.first);
565564
}
566565
}
567-
catch (const mp::UnsupportedImageException& e)
568-
{
569-
mpl::warn(category, "Skipping update: {}", e.what());
570-
}
571566
catch (const mp::ImageNotFoundException& e)
572567
{
573568
mpl::warn(category, "Skipping update: {}", e.what());

src/image_host/custom_image_host.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ std::vector<std::pair<std::string, mp::VMImageInfo>> mp::CustomVMImageHost::all_
166166
return images;
167167
}
168168

169-
std::vector<mp::VMImageInfo> mp::CustomVMImageHost::all_images_for(const std::string& remote_name,
170-
const bool allow_unsupported)
169+
std::vector<mp::VMImageInfo> mp::CustomVMImageHost::all_images_for(const std::string& remote_name)
171170
{
172171
if (auto custom_manifest = manifest_from(remote_name))
173172
return custom_manifest->products;

src/image_host/ubuntu_image_host.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <multipass/exceptions/download_exception.h>
2020
#include <multipass/exceptions/image_not_found_exception.h>
2121
#include <multipass/exceptions/manifest_exceptions.h>
22-
#include <multipass/exceptions/unsupported_image_exception.h>
2322
#include <multipass/image_host/ubuntu_image_host.h>
2423
#include <multipass/platform.h>
2524
#include <multipass/query.h>
@@ -110,9 +109,6 @@ std::vector<std::pair<std::string, mp::VMImageInfo>> mp::UbuntuVMImageHost::all_
110109

111110
if (const auto* info = match_alias(key, *manifest); info)
112111
{
113-
if (!info->supported && !query.allow_unsupported)
114-
throw mp::UnsupportedImageException(query.release);
115-
116112
images.emplace_back(remote_name, *info);
117113
}
118114
else
@@ -121,7 +117,7 @@ std::vector<std::pair<std::string, mp::VMImageInfo>> mp::UbuntuVMImageHost::all_
121117

122118
for (const auto& entry : manifest->products)
123119
{
124-
if (entry.id.startsWith(key) && (entry.supported || query.allow_unsupported) &&
120+
if (entry.id.startsWith(key) &&
125121
found_hashes.find(entry.id.toStdString()) == found_hashes.end())
126122
{
127123
images.emplace_back(remote_name, entry);
@@ -150,18 +146,14 @@ mp::VMImageInfo mp::UbuntuVMImageHost::info_for_full_hash_impl(const std::string
150146
throw mp::ImageNotFoundException(full_hash);
151147
}
152148

153-
std::vector<mp::VMImageInfo> mp::UbuntuVMImageHost::all_images_for(const std::string& remote_name,
154-
const bool allow_unsupported)
149+
std::vector<mp::VMImageInfo> mp::UbuntuVMImageHost::all_images_for(const std::string& remote_name)
155150
{
156151
std::vector<mp::VMImageInfo> images;
157152
auto manifest = manifest_from(remote_name);
158153

159154
for (const auto& entry : manifest->products)
160155
{
161-
if (entry.supported || allow_unsupported)
162-
{
163-
images.push_back(entry);
164-
}
156+
images.push_back(entry);
165157
}
166158

167159
if (images.empty())

0 commit comments

Comments
 (0)