Skip to content

Commit

Permalink
Merge #841
Browse files Browse the repository at this point in the history
841: find: ensure supported alias before creating image info entry r=Saviq a=gerboland

Fixes #840 

Co-authored-by: Gerry Boland <[email protected]>
  • Loading branch information
bors[bot] and gerboland committed Jun 17, 2019
2 parents 4b5ff5c + 9cd8d8c commit 6cce16b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,20 @@ grpc::Status ssh_reboot(const std::string& hostname, int port, const std::string
return grpc::Status::OK;
}

QStringList filter_unsupported_aliases(const QStringList& aliases, const std::string& remote)
{
QStringList supported_aliases;

for (const auto& alias : aliases)
{
if (mp::platform::is_alias_supported(alias.toStdString(), remote))
{
supported_aliases.append(alias);
}
}
return supported_aliases;
}

} // namespace

mp::Daemon::Daemon(std::unique_ptr<const DaemonConfig> the_config)
Expand Down Expand Up @@ -875,14 +889,12 @@ try // clang-format on
{
if (image_found.find(info.release_title.toStdString()) == image_found.end())
{
if (!info.aliases.empty())
const auto supported_aliases = filter_unsupported_aliases(info.aliases, remote);
if (!supported_aliases.empty())
{
auto entry = response.add_images_info();
for (const auto& alias : info.aliases)
for (const auto& alias : supported_aliases)
{
if (!mp::platform::is_alias_supported(alias.toStdString(), remote))
return;

auto alias_entry = entry->add_aliases_info();
if (remote != default_remote)
alias_entry->set_remote_name(remote);
Expand Down

0 comments on commit 6cce16b

Please sign in to comment.