Skip to content

Commit ca3a1c9

Browse files
committed
Format and regenerate messages
1 parent 6bf609a commit ca3a1c9

File tree

2 files changed

+156
-123
lines changed

2 files changed

+156
-123
lines changed

include/vcpkg/binarycaching.h

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
#include <string>
2525
#include <thread>
2626
#include <unordered_map>
27-
#include <vector>
2827
#include <variant>
28+
#include <vector>
2929

30-
namespace vcpkg {
30+
namespace vcpkg
31+
{
3132
struct CacheStatus
3233
{
3334
bool should_attempt_precheck(const IReadBinaryProvider* sender) const noexcept;
@@ -131,60 +132,66 @@ namespace vcpkg {
131132
std::string feed;
132133
};
133134

134-
struct FilesBinaryProviderConfig {
135+
struct FilesBinaryProviderConfig
136+
{
135137
std::vector<Path> archives_to_read;
136138
std::vector<Path> archives_to_write;
137139
};
138140

139-
struct HttpBinaryProviderConfig {
141+
struct HttpBinaryProviderConfig
142+
{
140143
std::vector<std::string> secrets;
141144
std::vector<UrlTemplate> url_templates_to_get;
142145
std::vector<UrlTemplate> url_templates_to_put;
143146
};
144147

145-
struct GcsBinaryProviderConfig {
148+
struct GcsBinaryProviderConfig
149+
{
146150
std::vector<std::string> gcs_read_prefixes;
147151
std::vector<std::string> gcs_write_prefixes;
148152
};
149153

150-
struct AwsBinaryProviderConfig {
154+
struct AwsBinaryProviderConfig
155+
{
151156
std::vector<std::string> aws_read_prefixes;
152157
std::vector<std::string> aws_write_prefixes;
153158
};
154159

155-
struct CosBinaryProviderConfig {
160+
struct CosBinaryProviderConfig
161+
{
156162
std::vector<std::string> cos_read_prefixes;
157163
std::vector<std::string> cos_write_prefixes;
158164
};
159165

160-
struct GhaBinaryProviderConfig {
166+
struct GhaBinaryProviderConfig
167+
{
161168
bool gha_write = false;
162169
bool gha_read = false;
163170
};
164171

165-
struct NugetBinaryProviderConfig {
172+
struct NugetBinaryProviderConfig
173+
{
166174
std::vector<std::string> sources_to_read;
167175
std::vector<std::string> sources_to_write;
168176

169177
std::vector<Path> configs_to_read;
170178
std::vector<Path> configs_to_write;
171179
};
172180

173-
struct AzureUpkgBinaryProviderConfig {
181+
struct AzureUpkgBinaryProviderConfig
182+
{
174183
std::vector<AzureUpkgSource> upkg_templates_to_get;
175184
std::vector<AzureUpkgSource> upkg_templates_to_put;
176185
};
177186

178-
using BinaryProviderConfig = std::variant<
179-
FilesBinaryProviderConfig,
180-
HttpBinaryProviderConfig,
181-
GcsBinaryProviderConfig,
182-
AwsBinaryProviderConfig,
183-
CosBinaryProviderConfig,
184-
GhaBinaryProviderConfig,
185-
NugetBinaryProviderConfig,
186-
AzureUpkgBinaryProviderConfig
187-
>;
187+
using BinaryProviderConfig = std::variant<FilesBinaryProviderConfig,
188+
HttpBinaryProviderConfig,
189+
GcsBinaryProviderConfig,
190+
AwsBinaryProviderConfig,
191+
CosBinaryProviderConfig,
192+
GhaBinaryProviderConfig,
193+
NugetBinaryProviderConfig,
194+
AzureUpkgBinaryProviderConfig>;
188195

189196
struct BinaryConfigParserState
190197
{

src/vcpkg/binarycaching.cpp

Lines changed: 129 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,140 +2376,166 @@ namespace vcpkg
23762376

23772377
ZipTool zip_tool;
23782378
zip_tool.setup(tools, out_sink);
2379-
for (auto& config : s.binary_providers) {
2380-
auto ok = std::visit([&](auto&& c) {
2381-
using T = std::decay_t<decltype(c)>;
2382-
if constexpr (std::is_same_v<T, FilesBinaryProviderConfig>) {
2383-
for (auto&& dir : c.archives_to_read)
2384-
{
2385-
m_config.read.push_back(std::make_unique<FilesReadBinaryProvider>(zip_tool, fs, std::move(dir)));
2386-
}
2387-
if (!c.archives_to_write.empty())
2388-
{
2389-
m_config.write.push_back(std::make_unique<FilesWriteBinaryProvider>(fs, std::move(c.archives_to_write)));
2390-
}
2391-
} else if constexpr (std::is_same_v<T, HttpBinaryProviderConfig>) {
2392-
for (auto&& url : c.url_templates_to_get)
2379+
for (auto& config : s.binary_providers)
2380+
{
2381+
auto ok = std::visit(
2382+
[&](auto&& c) {
2383+
using T = std::decay_t<decltype(c)>;
2384+
if constexpr (std::is_same_v<T, FilesBinaryProviderConfig>)
23932385
{
2394-
m_config.read.push_back(
2395-
std::make_unique<HttpGetBinaryProvider>(zip_tool, fs, buildtrees, std::move(url), c.secrets));
2386+
for (auto&& dir : c.archives_to_read)
2387+
{
2388+
m_config.read.push_back(
2389+
std::make_unique<FilesReadBinaryProvider>(zip_tool, fs, std::move(dir)));
2390+
}
2391+
if (!c.archives_to_write.empty())
2392+
{
2393+
m_config.write.push_back(
2394+
std::make_unique<FilesWriteBinaryProvider>(fs, std::move(c.archives_to_write)));
2395+
}
23962396
}
2397-
if (!c.url_templates_to_put.empty())
2397+
else if constexpr (std::is_same_v<T, HttpBinaryProviderConfig>)
23982398
{
2399-
m_config.write.push_back(
2400-
std::make_unique<HTTPPutBinaryProvider>(std::move(c.url_templates_to_put), c.secrets));
2399+
for (auto&& url : c.url_templates_to_get)
2400+
{
2401+
m_config.read.push_back(std::make_unique<HttpGetBinaryProvider>(
2402+
zip_tool, fs, buildtrees, std::move(url), c.secrets));
2403+
}
2404+
if (!c.url_templates_to_put.empty())
2405+
{
2406+
m_config.write.push_back(std::make_unique<HTTPPutBinaryProvider>(
2407+
std::move(c.url_templates_to_put), c.secrets));
2408+
}
24012409
}
2402-
} else if constexpr (std::is_same_v<T, GcsBinaryProviderConfig>) {
2403-
if (!gcs_tool)
2410+
else if constexpr (std::is_same_v<T, GcsBinaryProviderConfig>)
24042411
{
2405-
gcs_tool = std::make_shared<GcsStorageTool>(tools, out_sink);
2406-
}
2412+
if (!gcs_tool)
2413+
{
2414+
gcs_tool = std::make_shared<GcsStorageTool>(tools, out_sink);
2415+
}
24072416

2408-
for (auto&& prefix : c.gcs_read_prefixes)
2409-
{
2410-
m_config.read.push_back(
2411-
std::make_unique<ObjectStorageProvider>(zip_tool, fs, buildtrees, std::move(prefix), gcs_tool));
2412-
}
2413-
if (!c.gcs_write_prefixes.empty())
2414-
{
2415-
m_config.write.push_back(
2416-
std::make_unique<ObjectStoragePushProvider>(std::move(c.gcs_write_prefixes), gcs_tool));
2417+
for (auto&& prefix : c.gcs_read_prefixes)
2418+
{
2419+
m_config.read.push_back(std::make_unique<ObjectStorageProvider>(
2420+
zip_tool, fs, buildtrees, std::move(prefix), gcs_tool));
2421+
}
2422+
if (!c.gcs_write_prefixes.empty())
2423+
{
2424+
m_config.write.push_back(std::make_unique<ObjectStoragePushProvider>(
2425+
std::move(c.gcs_write_prefixes), gcs_tool));
2426+
}
24172427
}
2418-
} else if constexpr (std::is_same_v<T, AwsBinaryProviderConfig>) {
2419-
if (!aws_tool)
2428+
else if constexpr (std::is_same_v<T, AwsBinaryProviderConfig>)
24202429
{
2421-
aws_tool = std::make_shared<AwsStorageTool>(tools, out_sink, s.aws_no_sign_request);
2422-
}
2430+
if (!aws_tool)
2431+
{
2432+
aws_tool = std::make_shared<AwsStorageTool>(tools, out_sink, s.aws_no_sign_request);
2433+
}
24232434

2424-
for (auto&& prefix : c.aws_read_prefixes)
2425-
{
2426-
m_config.read.push_back(
2427-
std::make_unique<ObjectStorageProvider>(zip_tool, fs, buildtrees, std::move(prefix), aws_tool));
2428-
}
2435+
for (auto&& prefix : c.aws_read_prefixes)
2436+
{
2437+
m_config.read.push_back(std::make_unique<ObjectStorageProvider>(
2438+
zip_tool, fs, buildtrees, std::move(prefix), aws_tool));
2439+
}
24292440

2430-
if (!c.aws_write_prefixes.empty())
2431-
{
2432-
m_config.write.push_back(
2433-
std::make_unique<ObjectStoragePushProvider>(std::move(c.aws_write_prefixes), aws_tool));
2441+
if (!c.aws_write_prefixes.empty())
2442+
{
2443+
m_config.write.push_back(std::make_unique<ObjectStoragePushProvider>(
2444+
std::move(c.aws_write_prefixes), aws_tool));
2445+
}
24342446
}
2435-
} else if constexpr (std::is_same_v<T, CosBinaryProviderConfig>) {
2436-
if (!cos_tool)
2447+
else if constexpr (std::is_same_v<T, CosBinaryProviderConfig>)
24372448
{
2438-
cos_tool = std::make_shared<CosStorageTool>(tools, out_sink);
2439-
}
2449+
if (!cos_tool)
2450+
{
2451+
cos_tool = std::make_shared<CosStorageTool>(tools, out_sink);
2452+
}
24402453

2441-
for (auto&& prefix : c.cos_read_prefixes)
2442-
{
2443-
m_config.read.push_back(
2444-
std::make_unique<ObjectStorageProvider>(zip_tool, fs, buildtrees, std::move(prefix), cos_tool));
2445-
}
2454+
for (auto&& prefix : c.cos_read_prefixes)
2455+
{
2456+
m_config.read.push_back(std::make_unique<ObjectStorageProvider>(
2457+
zip_tool, fs, buildtrees, std::move(prefix), cos_tool));
2458+
}
24462459

2447-
if (!c.cos_write_prefixes.empty())
2448-
{
2449-
m_config.write.push_back(
2450-
std::make_unique<ObjectStoragePushProvider>(std::move(c.cos_write_prefixes), cos_tool));
2460+
if (!c.cos_write_prefixes.empty())
2461+
{
2462+
m_config.write.push_back(std::make_unique<ObjectStoragePushProvider>(
2463+
std::move(c.cos_write_prefixes), cos_tool));
2464+
}
24512465
}
2452-
} else if constexpr (std::is_same_v<T, GhaBinaryProviderConfig>) {
2453-
if (c.gha_read || c.gha_write)
2466+
else if constexpr (std::is_same_v<T, GhaBinaryProviderConfig>)
24542467
{
2455-
if (!args.actions_cache_url.has_value() || !args.actions_runtime_token.has_value())
2468+
if (c.gha_read || c.gha_write)
24562469
{
2457-
status_sink.println(
2458-
Color::error,
2459-
msg::format_error(msgGHAParametersMissing, msg::url = docs::binarycaching_gha_url));
2460-
return false;
2470+
if (!args.actions_cache_url.has_value() || !args.actions_runtime_token.has_value())
2471+
{
2472+
status_sink.println(Color::error,
2473+
msg::format_error(msgGHAParametersMissing,
2474+
msg::url = docs::binarycaching_gha_url));
2475+
return false;
2476+
}
24612477
}
2462-
}
24632478

2464-
if (c.gha_read)
2465-
{
2466-
const auto& url = *args.actions_cache_url.get();
2467-
const auto& token = *args.actions_runtime_token.get();
2468-
m_config.read.push_back(std::make_unique<GHABinaryProvider>(zip_tool, fs, buildtrees, url, token));
2469-
}
2470-
if (c.gha_write)
2471-
{
2472-
const auto& url = *args.actions_cache_url.get();
2473-
const auto& token = *args.actions_runtime_token.get();
2474-
m_config.write.push_back(std::make_unique<GHABinaryPushProvider>(fs, url, token));
2475-
}
2476-
} else if constexpr (std::is_same_v<T, NugetBinaryProviderConfig>) {
2477-
if (!c.sources_to_read.empty() || !c.configs_to_read.empty() || !c.sources_to_write.empty() || !c.configs_to_write.empty())
2478-
{
2479-
NugetBaseBinaryProvider nuget_base(
2480-
fs, NuGetTool(tools, out_sink, s), paths.packages(), buildtrees, s.nuget_prefix);
2481-
if (!c.sources_to_read.empty())
2482-
m_config.read.push_back(
2483-
std::make_unique<NugetReadBinaryProvider>(nuget_base, nuget_sources_arg(c.sources_to_read)));
2484-
for (auto&& config : c.configs_to_read)
2479+
if (c.gha_read)
2480+
{
2481+
const auto& url = *args.actions_cache_url.get();
2482+
const auto& token = *args.actions_runtime_token.get();
24852483
m_config.read.push_back(
2486-
std::make_unique<NugetReadBinaryProvider>(nuget_base, nuget_configfile_arg(config)));
2487-
if (!c.sources_to_write.empty() || !c.configs_to_write.empty())
2484+
std::make_unique<GHABinaryProvider>(zip_tool, fs, buildtrees, url, token));
2485+
}
2486+
if (c.gha_write)
24882487
{
2489-
m_config.write.push_back(std::make_unique<NugetBinaryPushProvider>(
2490-
nuget_base, std::move(c.sources_to_write), std::move(c.configs_to_write)));
2488+
const auto& url = *args.actions_cache_url.get();
2489+
const auto& token = *args.actions_runtime_token.get();
2490+
m_config.write.push_back(std::make_unique<GHABinaryPushProvider>(fs, url, token));
24912491
}
24922492
}
2493-
} else if constexpr (std::is_same_v<T, AzureUpkgBinaryProviderConfig>) {
2494-
if (!c.upkg_templates_to_get.empty())
2493+
else if constexpr (std::is_same_v<T, NugetBinaryProviderConfig>)
24952494
{
2496-
for (auto&& src : c.upkg_templates_to_get)
2495+
if (!c.sources_to_read.empty() || !c.configs_to_read.empty() ||
2496+
!c.sources_to_write.empty() || !c.configs_to_write.empty())
24972497
{
2498-
m_config.read.push_back(
2499-
std::make_unique<AzureUpkgGetBinaryProvider>(tools, out_sink, std::move(src)));
2498+
NugetBaseBinaryProvider nuget_base(fs,
2499+
NuGetTool(tools, out_sink, s),
2500+
paths.packages(),
2501+
buildtrees,
2502+
s.nuget_prefix);
2503+
if (!c.sources_to_read.empty())
2504+
m_config.read.push_back(std::make_unique<NugetReadBinaryProvider>(
2505+
nuget_base, nuget_sources_arg(c.sources_to_read)));
2506+
for (auto&& config : c.configs_to_read)
2507+
m_config.read.push_back(std::make_unique<NugetReadBinaryProvider>(
2508+
nuget_base, nuget_configfile_arg(config)));
2509+
if (!c.sources_to_write.empty() || !c.configs_to_write.empty())
2510+
{
2511+
m_config.write.push_back(std::make_unique<NugetBinaryPushProvider>(
2512+
nuget_base, std::move(c.sources_to_write), std::move(c.configs_to_write)));
2513+
}
25002514
}
25012515
}
2502-
if (!c.upkg_templates_to_put.empty())
2516+
else if constexpr (std::is_same_v<T, AzureUpkgBinaryProviderConfig>)
25032517
{
2504-
m_config.write.push_back(
2505-
std::make_unique<AzureUpkgPutBinaryProvider>(tools, out_sink, std::move(c.upkg_templates_to_put)));
2518+
if (!c.upkg_templates_to_get.empty())
2519+
{
2520+
for (auto&& src : c.upkg_templates_to_get)
2521+
{
2522+
m_config.read.push_back(std::make_unique<AzureUpkgGetBinaryProvider>(
2523+
tools, out_sink, std::move(src)));
2524+
}
2525+
}
2526+
if (!c.upkg_templates_to_put.empty())
2527+
{
2528+
m_config.write.push_back(std::make_unique<AzureUpkgPutBinaryProvider>(
2529+
tools, out_sink, std::move(c.upkg_templates_to_put)));
2530+
}
25062531
}
2507-
}
25082532

2509-
return true;
2510-
}, config);
2533+
return true;
2534+
},
2535+
config);
25112536

2512-
if (!ok) {
2537+
if (!ok)
2538+
{
25132539
return false;
25142540
}
25152541
}

0 commit comments

Comments
 (0)