Files
scylladb/db/object_storage_endpoint_param.hh
Pavel Emelyanov a63508a6f7 object_storage: Temporarily handle pure endpoint addresses as endpoints
To keep backward compatibility, support

- old configs -- where endpoint is just an address and port is separate.
  When it happens, format the "new" endpoint name

- lookup by address-only. If it happens, scan all endpoints and see if
  any one matches the provided address

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2025-12-10 15:33:47 +03:00

83 lines
2.2 KiB
C++

/*
* Copyright (C) 2025-present ScyllaDB
*
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
#pragma once
#include <string>
#include <variant>
#include <compare>
#include <fmt/core.h>
namespace YAML {
class Node;
}
namespace db {
class object_storage_endpoint_param {
public:
struct s3_storage {
std::string endpoint;
std::string region;
std::string iam_role_arn;
std::strong_ordering operator<=>(const s3_storage&) const = default;
std::string to_json_string() const;
std::string key() const;
};
struct gs_storage {
std::string endpoint; // "default"/empty or an URI
std::string credentials_file; // optional
std::strong_ordering operator<=>(const gs_storage&) const = default;
std::string to_json_string() const;
std::string key() const;
};
object_storage_endpoint_param();
object_storage_endpoint_param(const object_storage_endpoint_param&);
object_storage_endpoint_param(s3_storage);
object_storage_endpoint_param(gs_storage);
std::strong_ordering operator<=>(const object_storage_endpoint_param&) const;
bool operator==(const object_storage_endpoint_param&) const;
std::string to_json_string() const;
std::string key() const;
const std::string& type() const;
bool is_s3_storage() const;
bool is_gs_storage() const;
bool is_storage_of_type(std::string_view) const;
const s3_storage& get_s3_storage() const;
const gs_storage& get_gs_storage() const;
static object_storage_endpoint_param decode(const YAML::Node&);
static const std::string s3_type; // "s3"
static const std::string gs_type; // "gs"
private:
friend fmt::formatter<object_storage_endpoint_param>;
std::variant<s3_storage, gs_storage> _data;
};
std::istream& operator>>(std::istream& is, object_storage_endpoint_param& f);
}
template <>
struct fmt::formatter<db::object_storage_endpoint_param> : fmt::formatter<std::string_view> {
auto format(const db::object_storage_endpoint_param&, fmt::format_context& ctx) const -> decltype(ctx.out());
};
inline bool maybe_legacy_endpoint_name(std::string_view ep) noexcept {
return !(ep.starts_with("http://") || ep.starts_with("https://"));
}