diff options
| author | Dan Engelbrecht <[email protected]> | 2025-06-04 12:41:43 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-06-04 12:41:43 +0200 |
| commit | 99814bacd1788bfd670f6abd9dd017dbdf483d70 (patch) | |
| tree | 07d1cec6842e25dff9d7f751241d6d2b23f3ef14 /src | |
| parent | faster scavenge (#417) (diff) | |
| download | zen-99814bacd1788bfd670f6abd9dd017dbdf483d70.tar.xz zen-99814bacd1788bfd670f6abd9dd017dbdf483d70.zip | |
new builds search (#418)
* don't require bucket for search operations to allow multi-bucket search
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/builds_cmd.cpp | 44 | ||||
| -rw-r--r-- | src/zenutil/jupiter/jupitersession.cpp | 7 |
2 files changed, 32 insertions, 19 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index fbcb6b900..372291fcc 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -9433,7 +9433,6 @@ BuildsCommand::BuildsCommand() auto AddCloudOptions = [this, &AddAuthOptions](cxxopts::Options& Ops) { AddAuthOptions(Ops); - Ops.add_option("cloud build", "", "override-host", "Cloud Builds URL", cxxopts::value(m_OverrideHost), "<override-host>"); Ops.add_option("cloud build", "", @@ -9829,17 +9828,21 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) }; ParseSystemOptions(); - auto ParseStorageOptions = [&]() { + auto ParseStorageOptions = [&](bool RequireBucket) { if (!m_OverrideHost.empty() || !m_Host.empty()) { if (!m_StoragePath.empty()) { - throw zen::OptionParseException(fmt::format("url is not compatible with the storage-path option\n{}", m_Options.help())); + throw zen::OptionParseException( + fmt::format("host/url/override-host is not compatible with the storage-path option\n{}", m_Options.help())); } - if (SubOption != &m_ListNamespacesOptions && (m_Namespace.empty() || m_Bucket.empty())) + if (m_Namespace.empty()) { - throw zen::OptionParseException( - fmt::format("namespace and bucket options are required for url option\n{}", m_Options.help())); + throw zen::OptionParseException(fmt::format("namespace option is required for this storage option\n{}", m_Options.help())); + } + if (RequireBucket && m_Bucket.empty()) + { + throw zen::OptionParseException(fmt::format("bucket option is required for this storage option\n{}", m_Options.help())); } } else if (m_StoragePath.empty()) @@ -9986,8 +9989,9 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) auto CreateBuildStorage = [&](BuildStorage::Statistics& StorageStats, BuildStorageCache::Statistics& StorageCacheStats, - const std::filesystem::path& TempPath) -> StorageInstance { - ParseStorageOptions(); + const std::filesystem::path& TempPath, + bool RequireBucket) -> StorageInstance { + ParseStorageOptions(RequireBucket); StorageInstance Result; @@ -10396,7 +10400,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } }); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(ZenFolderPath), /*RequireBucket*/ false); CbObject Response = Storage.BuildStorage->ListNamespaces(m_ListNamespacesRecursive); ZEN_ASSERT(ValidateCompactBinary(Response.GetView(), CbValidateMode::All) == CbValidateError::None); @@ -10480,7 +10485,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } }); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ false); CbObject Response = Storage.BuildStorage->ListBuilds(QueryObject); ZEN_ASSERT(ValidateCompactBinary(Response.GetView(), CbValidateMode::All) == CbValidateError::None); @@ -10548,7 +10554,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } }); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); CbObject MetaData = ParseBuildMetadata(); @@ -10627,7 +10634,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) BuildStorage::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); DownloadFolder(Storage, BuildId, @@ -10679,7 +10687,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } }); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); uint64_t CompressedSize; uint64_t DecompressedSize; @@ -10724,7 +10733,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } }); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); const Oid BuildPartId = m_BuildPartName.empty() ? Oid::Zero : ParseBuildPartId(); @@ -10753,7 +10763,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) BuildStorage::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); Stopwatch Timer; for (const std::string& BuildIdString : m_BuildIds) @@ -10838,7 +10849,8 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } MakeSafeAbsolutePathÍnPlace(m_ZenFolderPath); - StorageInstance Storage = CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath)); + StorageInstance Storage = + CreateBuildStorage(StorageStats, StorageCacheStats, ZenTempFolderPath(m_ZenFolderPath), /*RequireBucket*/ true); auto MakeMetaData = [](const Oid& BuildId) -> CbObject { CbObjectWriter BuildMetaDataWriter; diff --git a/src/zenutil/jupiter/jupitersession.cpp b/src/zenutil/jupiter/jupitersession.cpp index 01a703a1b..1fd59acdf 100644 --- a/src/zenutil/jupiter/jupitersession.cpp +++ b/src/zenutil/jupiter/jupitersession.cpp @@ -379,9 +379,10 @@ JupiterResult JupiterSession::ListBuilds(std::string_view Namespace, std::string_view BucketId, const IoBuffer& Payload) { ZEN_ASSERT(Payload.GetContentType() == ZenContentType::kCbObject); - HttpClient::Response Response = m_HttpClient.Post(fmt::format("/api/v2/builds/{}/{}/search", Namespace, BucketId), - Payload, - {HttpClient::Accept(ZenContentType::kCbObject)}); + std::string OptionalBucketPath = BucketId.empty() ? "" : fmt::format("/{}", BucketId); + HttpClient::Response Response = m_HttpClient.Post(fmt::format("/api/v2/builds/{}{}/search", Namespace, OptionalBucketPath), + Payload, + {HttpClient::Accept(ZenContentType::kCbObject)}); return detail::ConvertResponse(Response, "JupiterSession::ListBuilds"sv); } |