Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 committed Dec 26, 2024
1 parent a7275a7 commit 7993789
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 4 additions & 0 deletions crates/iceberg/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ use storage_fs::*;
mod storage_gcs;
#[cfg(feature = "storage-gcs")]
pub use storage_gcs::*;

fn is_truthy(value: &str) -> bool {
["true", "t", "1", "on"].contains(&value.to_lowercase().as_str())
}
5 changes: 1 addition & 4 deletions crates/iceberg/src/io/storage_gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use opendal::services::GcsConfig;
use opendal::Operator;
use url::Url;

use crate::io::is_truthy;
use crate::{Error, ErrorKind, Result};

// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java
Expand All @@ -48,10 +49,6 @@ pub const GCS_DISABLE_VM_METADATA: &str = "gcs.disable-vm-metadata";
/// Option to skip loading configuration from config file and the env.
pub const GCS_DISABLE_CONFIG_LOAD: &str = "gcs.disable-config-load";

fn is_truthy(value: &str) -> bool {
["true", "t", "1", "on"].contains(&value)
}

/// Parse iceberg properties to [`GcsConfig`].
pub(crate) fn gcs_config_parse(mut m: HashMap<String, String>) -> Result<GcsConfig> {
let mut cfg = GcsConfig::default();
Expand Down
5 changes: 1 addition & 4 deletions crates/iceberg/src/io/storage_s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use opendal::services::S3Config;
use opendal::{Configurator, Operator};
use url::Url;

use crate::io::is_truthy;
use crate::{Error, ErrorKind, Result};

/// Following are arguments for [s3 file io](https://py.iceberg.apache.org/configuration/#s3).
Expand Down Expand Up @@ -66,10 +67,6 @@ pub const S3_DISABLE_EC2_METADATA: &str = "s3.disable-ec2-metadata";
/// Option to skip loading configuration from config file and the env.
pub const S3_DISABLE_CONFIG_LOAD: &str = "s3.disable-config-load";

fn is_truthy(value: &str) -> bool {
["true", "t", "1", "on"].contains(&value)
}

/// Parse iceberg props to s3 config.
pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config> {
let mut cfg = S3Config::default();
Expand Down

0 comments on commit 7993789

Please sign in to comment.