From 1150d6618ac559edc7b033223cc230bc9199247a Mon Sep 17 00:00:00 2001 From: Jan Kaul Date: Sun, 8 Dec 2024 09:44:00 +0100 Subject: [PATCH] remove credential provider --- Cargo.lock | 2 - iceberg-rust/Cargo.toml | 2 - iceberg-rust/src/object_store/mod.rs | 69 ++-------------------------- 3 files changed, 3 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53c24c17..b42f47d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2981,8 +2981,6 @@ dependencies = [ "apache-avro", "arrow", "async-trait", - "aws-config", - "aws-credential-types", "chrono", "derive-getters", "derive_builder", diff --git a/iceberg-rust/Cargo.toml b/iceberg-rust/Cargo.toml index ed3bdc05..1f371a70 100644 --- a/iceberg-rust/Cargo.toml +++ b/iceberg-rust/Cargo.toml @@ -31,8 +31,6 @@ thiserror = { workspace = true } derive-getters = { workspace = true } iceberg-rust-spec = { path = "../iceberg-rust-spec", version = "0.5.8" } smallvec = { version = "1.13.2", features = ["const_generics"] } -aws-config = "1.5.10" -aws-credential-types = "1.2.1" [dev-dependencies] chrono = { workspace = true } diff --git a/iceberg-rust/src/object_store/mod.rs b/iceberg-rust/src/object_store/mod.rs index 94d9ae49..a3c38c41 100644 --- a/iceberg-rust/src/object_store/mod.rs +++ b/iceberg-rust/src/object_store/mod.rs @@ -2,19 +2,14 @@ Defining the [Bucket] struct for specifying buckets for the ObjectStore. */ -use std::{fmt::Display, ops::Deref, path::Path, str::FromStr, sync::Arc, time::SystemTime}; +use std::{fmt::Display, path::Path, str::FromStr, sync::Arc}; -use async_trait::async_trait; -use aws_config::SdkConfig; -use aws_credential_types::{provider::ProvideCredentials, Credentials}; -use futures::lock::Mutex; -use object_store::Error as ObjectStoreError; use object_store::{ - aws::{AmazonS3Builder, AmazonS3ConfigKey, AwsCredential}, + aws::{AmazonS3Builder, AmazonS3ConfigKey}, gcp::{GoogleCloudStorageBuilder, GoogleConfigKey}, local::LocalFileSystem, memory::InMemory, - CredentialProvider, ObjectStore, + ObjectStore, }; use crate::error::Error; @@ -151,61 +146,3 @@ impl ObjectStoreBuilder { } } } - -/// AWS Sdk credential provider for object_store -#[derive(Debug)] -#[allow(clippy::type_complexity)] -pub struct AwsCredentialProvider { - config: SdkConfig, - cache: Arc, Credentials)>>>, -} - -#[async_trait] -impl CredentialProvider for AwsCredentialProvider { - type Credential = AwsCredential; - - async fn get_credential(&self) -> Result, ObjectStoreError> { - let mut guard = self.cache.lock().await; - - let is_valid = if let Some((Some(time), _)) = guard.deref() { - *time >= SystemTime::now() - } else { - false - }; - - if !is_valid { - let provider = self - .config - .credentials_provider() - .ok_or(ObjectStoreError::NotImplemented)?; - - let credentials = - provider - .provide_credentials() - .await - .map_err(|err| ObjectStoreError::Generic { - store: "s3", - source: Box::new(err), - })?; - *guard = Some((credentials.expiry(), credentials)); - }; - - let credentials = &guard.as_ref().unwrap().1; - - Ok(Arc::new(AwsCredential { - key_id: credentials.access_key_id().to_string(), - secret_key: credentials.secret_access_key().to_string(), - token: credentials.session_token().map(ToString::to_string), - })) - } -} - -impl AwsCredentialProvider { - /// Create new credential provider - pub fn new(config: &SdkConfig) -> Self { - Self { - config: config.clone(), - cache: Arc::new(Mutex::new(None)), - } - } -}