mirror of
https://github.com/lancedb/lancedb.git
synced 2026-08-28 08:58:41 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c8f9e4c9c |
@@ -921,8 +921,15 @@ pub struct ConnectBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "remote")]
|
#[cfg(feature = "remote")]
|
||||||
const ENV_VARS_TO_STORAGE_OPTS: [(&str, &str); 1] =
|
const ENV_VARS_TO_STORAGE_OPTS: [(&str, &str); 4] = [
|
||||||
[("AZURE_STORAGE_ACCOUNT_NAME", "azure_storage_account_name")];
|
("AZURE_STORAGE_ACCOUNT_NAME", "azure_storage_account_name"),
|
||||||
|
("AZURE_TENANT_ID", "azure_tenant_id"),
|
||||||
|
("AZURE_CLIENT_ID", "azure_client_id"),
|
||||||
|
(
|
||||||
|
"AZURE_FEDERATED_TOKEN_FILE",
|
||||||
|
"azure_federated_token_file",
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
impl ConnectBuilder {
|
impl ConnectBuilder {
|
||||||
/// Create a new [`ConnectOptions`] with the given database URI.
|
/// Create a new [`ConnectOptions`] with the given database URI.
|
||||||
|
|||||||
@@ -438,21 +438,26 @@ impl<S: HttpSend> RestfulLanceDbClient<S> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(v) = options.0.get("account_name") {
|
// Map storage options to HTTP headers for Azure configuration.
|
||||||
|
const OPTION_TO_HEADER: &[(&str, &str)] = &[
|
||||||
|
("account_name", "x-azure-storage-account-name"),
|
||||||
|
("azure_storage_account_name", "x-azure-storage-account-name"),
|
||||||
|
("azure_tenant_id", "x-azure-tenant-id"),
|
||||||
|
("azure_client_id", "x-azure-client-id"),
|
||||||
|
(
|
||||||
|
"azure_federated_token_file",
|
||||||
|
"x-azure-federated-token-file",
|
||||||
|
),
|
||||||
|
];
|
||||||
|
for (opt_key, header_name) in OPTION_TO_HEADER {
|
||||||
|
if let Some(v) = options.get(opt_key) {
|
||||||
headers.insert(
|
headers.insert(
|
||||||
HeaderName::from_static("x-azure-storage-account-name"),
|
HeaderName::from_static(header_name),
|
||||||
HeaderValue::from_str(v).map_err(|_| Error::InvalidInput {
|
HeaderValue::from_str(v).map_err(|_| Error::InvalidInput {
|
||||||
message: format!("non-ascii storage account name '{}' provided", db_name),
|
message: format!("non-ascii value for '{}' provided", opt_key),
|
||||||
})?,
|
})?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Some(v) = options.0.get("azure_storage_account_name") {
|
|
||||||
headers.insert(
|
|
||||||
HeaderName::from_static("x-azure-storage-account-name"),
|
|
||||||
HeaderValue::from_str(v).map_err(|_| Error::InvalidInput {
|
|
||||||
message: format!("non-ascii storage account name '{}' provided", db_name),
|
|
||||||
})?,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (key, value) in &config.extra_headers {
|
for (key, value) in &config.extra_headers {
|
||||||
|
|||||||
@@ -792,11 +792,21 @@ impl RemoteOptions {
|
|||||||
pub fn new(options: HashMap<String, String>) -> Self {
|
pub fn new(options: HashMap<String, String>) -> Self {
|
||||||
Self(options)
|
Self(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get(&self, key: &str) -> Option<&String> {
|
||||||
|
self.0.get(key)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StorageOptions> for RemoteOptions {
|
impl From<StorageOptions> for RemoteOptions {
|
||||||
fn from(options: StorageOptions) -> Self {
|
fn from(options: StorageOptions) -> Self {
|
||||||
let supported_opts = vec!["account_name", "azure_storage_account_name"];
|
let supported_opts = vec![
|
||||||
|
"account_name",
|
||||||
|
"azure_storage_account_name",
|
||||||
|
"azure_tenant_id",
|
||||||
|
"azure_client_id",
|
||||||
|
"azure_federated_token_file",
|
||||||
|
];
|
||||||
let mut filtered = HashMap::new();
|
let mut filtered = HashMap::new();
|
||||||
for opt in supported_opts {
|
for opt in supported_opts {
|
||||||
if let Some(v) = options.0.get(opt) {
|
if let Some(v) = options.0.get(opt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user