Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ java-properties = "2.0.0"
lazy_static = "1.4.0"
libc = "0.2.139"
log = { version = "0.4.17", features = ["std"] }
objectstore-client = { version = "0.1.2" , default-features = false, features = ["native-tls"] }
objectstore-client = { version = "0.1.6" , default-features = false, features = ["native-tls"] }
open = "3.2.0"
parking_lot = "0.12.1"
percent-encoding = "2.2.0"
Expand Down
1 change: 1 addition & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,5 +2065,6 @@ pub struct SnapshotsUploadOptions {
pub struct ObjectstoreUploadOptions {
pub url: String,
pub scopes: Vec<(String, String)>,
pub auth_token: Option<String>,
pub expiration_policy: String,
}
28 changes: 19 additions & 9 deletions src/commands/build/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,25 @@ fn upload_images(
let expiration = ExpirationPolicy::from_str(&options.objectstore.expiration_policy)
.context("Failed to parse expiration policy from upload options")?;

let client = ClientBuilder::new(options.objectstore.url)
.token({
// TODO: replace with auth from `ObjectstoreUploadOptions` when appropriate
let auth = match authenticated_api.auth() {
Auth::Token(token) => token.raw().expose_secret().to_owned(),
};
auth
let mut builder = ClientBuilder::new(options.objectstore.url);
if let Some(token) = options.objectstore.auth_token {
builder = builder.token(token);
}
Comment thread
sentry[bot] marked this conversation as resolved.
Comment thread
lcian marked this conversation as resolved.

let sentry_token = match authenticated_api.auth() {
Auth::Token(token) => token.raw().expose_secret().to_owned(),
};
let sentry_token = format!("Bearer {sentry_token}")
.parse()
// Ignore original error to avoid leaking the token (even though it's invalid)
.map_err(|_| anyhow::anyhow!("Invalid auth token"))?;
let client = builder
.configure_reqwest(|r| {
let mut headers = http::HeaderMap::new();
headers.insert(http::header::AUTHORIZATION, sentry_token);
r.connect_timeout(Duration::from_secs(10))
.default_headers(headers)
})
.configure_reqwest(|r| r.connect_timeout(Duration::from_secs(10)))
.build()?;

let mut scope = Usecase::new("preprod").scope();
Expand Down Expand Up @@ -400,7 +410,7 @@ fn upload_images(
warn!("Some images share identical file names. Only the first occurrence of each is included:{details}");
}

let result = runtime.block_on(async { many_builder.send().error_for_failures().await });
let result = runtime.block_on(async { many_builder.send().await.error_for_failures().await });
Comment thread
lcian marked this conversation as resolved.

let uploaded_count = manifest_entries.len();

Expand Down
Loading