data-partition-id header should not come from environment variable when the server calls Entilement service api
Open ETP server supports multi-partition capability. When open ETP server calls entitlement service API, it should add data-partition-id header in the request. Currently the codes get the data-partition-id value from the environment variable DATA_PARTITION_ID. This is strange. I think it is wrong. If data-partition-id comes from one specific environment variable, it is not possible to support multi-partition. If I create a new dataspace with a partition id "partition-A" as a command argument, the breakpoint I make in the following code shows it adds the value of environment variable DATA_PARTITION_ID in the http header when making calls to Entilement service, not the "partition-A" I pass in the client command line.
oes::core::HTTP::Response BaseClient::makeRequest(
oes::core::HTTP::Method method,
std::string& bearerToken,
const std::string& url,
const std::string& queryParams,
const oes::core::HTTP::Headers& additionalHeaders,
const oes::core::HTTP::Fields& params,
const std::string* body
)
{
oes::core::HTTP::Headers headers {
"content-type: application/json",
};
if (!_dataPartitionId.empty()) {
headers.push_back("data-partition-id: " + _dataPartitionId);
}
//some other codes below
}
class EntitlementOSDUConfigFromEnv::Impl {
public:
Impl(const std::string& delegateUri) {
auto from_env = [](const char* envName) {
const char* p = getenv(envName);
return p ? std::string(p) : std::string();
};
base_url_ = (!delegateUri.empty()) ? delegateUri : from_env("OSDU_HOST");
data_partition_id_ = from_env("DATA_PARTITION_ID");
schema_id_ = from_env("SCHEMA_ID");
domain_name_ = from_env("DOMAIN_NAME");
legal_tags_ = from_env("LEGAL_TAGS");;
legal_countries_ = from_env("LEGAL_COUNTRIES");;
}
}