Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do OPENDAL_B2_* environment variables work? #4199

Closed
HaleTom opened this issue Feb 19, 2024 · 3 comments
Closed

Do OPENDAL_B2_* environment variables work? #4199

HaleTom opened this issue Feb 19, 2024 · 3 comments

Comments

@HaleTom
Copy link

HaleTom commented Feb 19, 2024

There are several B2 variables listed in this .env example:

OPENDAL_B2_ROOT=/path/to/dir
OPENDAL_B2_BUCKET=<bucket>
OPENDAL_B2_BUCKET_ID=<bucket_id>
OPENDAL_B2_APPLICATION_KEY_ID=<key_id>
OPENDAL_B2_APPLICATION_KEY=<application_key>

I can't find these anywhere else in the codebase. Do these actually work?

@Xuanwo
Copy link
Member

Xuanwo commented Feb 19, 2024

I can't find these anywhere else in the codebase. Do these actually work?

Yes. We actually have them tested in CI: https://github.com/apache/opendal/blob/main/.github/services/b2/b2/action.yml


The test logic happens here:

pub fn init_test_service() -> Result<Option<Operator>> {
let _ = dotenvy::dotenv();
let scheme = if let Ok(v) = env::var("OPENDAL_TEST") {
v
} else {
return Ok(None);
};
let scheme = Scheme::from_str(&scheme).unwrap();
let prefix = format!("opendal_{scheme}_");
let mut cfg = env::vars()
.filter_map(|(k, v)| {
k.to_lowercase()
.strip_prefix(&prefix)
.map(|k| (k.to_string(), v))
})
.collect::<HashMap<String, String>>();
// Use random root unless OPENDAL_DISABLE_RANDOM_ROOT is set to true.
let disable_random_root = env::var("OPENDAL_DISABLE_RANDOM_ROOT").unwrap_or_default() == "true";
if !disable_random_root {
let root = format!(
"{}{}/",
cfg.get("root").cloned().unwrap_or_else(|| "/".to_string()),
uuid::Uuid::new_v4()
);
cfg.insert("root".to_string(), root);
}
let op = Operator::via_map(scheme, cfg).expect("must succeed");
#[cfg(feature = "layers-chaos")]
let op = { op.layer(layers::ChaosLayer::new(0.1)) };
let mut op = op
.layer(layers::LoggingLayer::default().with_backtrace_output(true))
.layer(layers::TimeoutLayer::new())
.layer(layers::RetryLayer::new().with_max_times(4));
// Enable blocking layer if needed.
if !op.info().full_capability().blocking {
let _guard = TEST_RUNTIME.enter();
op = op.layer(layers::BlockingLayer::create().expect("blocking layer must be created"));
}
Ok(Some(op))

We will load the service credentials specified by OPENDAL_TEST, initialize this service, and use it for testing.


Are you encountering errors when testing against b2? I might be able to help.

@HaleTom
Copy link
Author

HaleTom commented Feb 19, 2024

Thanks @Xuanwo.

I linked to this issue from:

rustic: OPENDAL_B2_* variables don't work #1073
rustic-rs/rustic#1073

@Xuanwo
Copy link
Member

Xuanwo commented Feb 19, 2024

Sure, let's continue the discussion at rustic-rs/rustic#1073 instead. I believe this isn't an issue for opendal. Feel free to reopen this if you need further discussion.

@Xuanwo Xuanwo closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants