Skip to content

feat: Bump OpenDAL and remove hyperx #1591

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

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 9 additions & 30 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ bincode = "1"
blake3 = "1"
byteorder = "1.0"
bytes = "1"
opendal = { version= "0.24.6", optional=true }
reqsign = {version="0.7.3", optional=true}
opendal = { version= "0.26.2", optional=true }
reqsign = {version="0.8.1", optional=true}
chrono = { version = "0.4.23", optional = true }
clap = { version = "4.0.32", features = ["derive", "env", "wrap_help"] }
directories = "4.0.1"
Expand All @@ -44,7 +44,6 @@ futures = "0.3"
gzp = { version = "0.11.1", default-features = false, features = ["deflate_rust"] }
http = "0.2"
hyper = { version = "0.14.10", optional = true, features = ["server"] }
hyperx = { version = "1.0", optional = true }
jobserver = "0.1"
jsonwebtoken = { version = "8", optional = true }
lazy_static = "1.0.0"
Expand All @@ -66,6 +65,7 @@ serde_json = "1.0"
strip-ansi-escapes = "0.1"
tar = "0.4.36"
tempfile = "3"
mime = "0.3"
tokio = { version = "1", features = ["rt-multi-thread", "io-util", "time", "net", "process", "macros"] }
tokio-serde = "0.8"
tokio-util = { version = "0.7", features = ["codec", "io"] }
Expand Down Expand Up @@ -131,9 +131,9 @@ redis = ["url", "opendal/services-redis"]
# Enable features that require unstable features of Nightly Rust.
unstable = []
# Enables distributed support in the sccache client
dist-client = ["flate2", "hyper", "hyperx", "reqwest", "url", "sha2"]
dist-client = ["flate2", "hyper", "reqwest", "url", "sha2"]
# Enables the sccache-dist binary
dist-server = ["crossbeam-utils", "jsonwebtoken", "flate2", "hyperx", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void", "version-compare"]
dist-server = ["crossbeam-utils", "jsonwebtoken", "flate2", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void", "version-compare"]
# Enables dist tests with external requirements
dist-tests = ["dist-client", "dist-server"]

Expand Down
1 change: 0 additions & 1 deletion src/bin/sccache-dist/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ extern crate base64;
extern crate crossbeam_utils;
extern crate env_logger;
extern crate flate2;
extern crate hyperx;
extern crate jsonwebtoken as jwt;

#[cfg(not(target_os = "freebsd"))]
Expand Down
12 changes: 3 additions & 9 deletions src/bin/sccache-dist/token_check.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::jwt;
use anyhow::{bail, Context, Result};
use sccache::dist::http::{ClientAuthCheck, ClientVisibleMsg};
use sccache::util::RequestExt;
use sccache::util::BASE64_URL_SAFE_ENGINE;
use std::collections::HashMap;
use std::result::Result as StdResult;
Expand Down Expand Up @@ -150,13 +149,11 @@ impl MozillaCheck {
// https://github.com/mozilla-iam/auth0-deploy/blob/6889f1dde12b84af50bb4b2e2f00d5e80d5be33f/rules/CIS-Claims-fixups.js#L158-L168
let url = reqwest::Url::parse(MOZ_USERINFO_ENDPOINT)
.expect("Failed to parse MOZ_USERINFO_ENDPOINT");
let header = hyperx::header::Authorization(hyperx::header::Bearer {
token: token.to_owned(),
});

let res = self
.client
.get(url.clone())
.set_header(header)
.bearer_auth(token)
.send()
.context("Failed to make request to mozilla userinfo")?;
let status = res.status();
Expand Down Expand Up @@ -289,13 +286,10 @@ impl ProxyTokenCheck {
auth_cache.remove(token);
}
// Make a request to another API, which as a side effect should actually check the token
let header = hyperx::header::Authorization(hyperx::header::Bearer {
token: token.to_owned(),
});
let res = self
.client
.get(&self.url)
.set_header(header)
.bearer_auth(token)
.send()
.context("Failed to make request to proxying url")?;
if !res.status().is_success() {
Expand Down
10 changes: 6 additions & 4 deletions src/cache/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
use opendal::Operator;

use opendal::layers::LoggingLayer;
use opendal::services::azblob;
use opendal::services::Azblob;

use crate::errors::*;

pub struct AzureBlobCache;

impl AzureBlobCache {
pub fn build(connection_string: &str, container: &str, key_prefix: &str) -> Result<Operator> {
let mut builder = azblob::Builder::from_connection_string(connection_string)?;
let mut builder = Azblob::from_connection_string(connection_string)?;
builder.container(container);
builder.root(key_prefix);

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}
10 changes: 6 additions & 4 deletions src/cache/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::errors::*;
use opendal::Operator;
use opendal::{layers::LoggingLayer, services::gcs};
use opendal::{layers::LoggingLayer, services::Gcs};
use reqsign::{GoogleBuilder, GoogleToken, GoogleTokenLoad};
use url::Url;

Expand Down Expand Up @@ -47,7 +47,7 @@ impl GCSCache {
rw_mode: RWMode,
credential_url: Option<&str>,
) -> Result<Operator> {
let mut builder = gcs::Builder::default();
let mut builder = Gcs::default();
builder.bucket(bucket);
builder.root(key_prefix);

Expand All @@ -70,8 +70,10 @@ impl GCSCache {
}
builder.signer(signer_builder.build()?);

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/cache/gha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use opendal::layers::LoggingLayer;
use opendal::services::ghac;
use opendal::services::Ghac;
use opendal::Operator;

use crate::errors::*;
Expand All @@ -24,7 +24,7 @@ pub struct GHACache;

impl GHACache {
pub fn build(version: &str) -> Result<Operator> {
let mut builder = ghac::Builder::default();
let mut builder = Ghac::default();
// This is the prefix of gha cache.
// From user side, cache key will be like `sccache/f/c/b/fcbxxx`
//
Expand All @@ -38,7 +38,9 @@ impl GHACache {
builder.version(&format!("sccache-v{VERSION}-{version}"));
}

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}
10 changes: 6 additions & 4 deletions src/cache/memcached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::time::Duration;

use opendal::layers::LoggingLayer;
use opendal::services::memcached;
use opendal::services::Memcached;
use opendal::Operator;

use crate::errors::*;
Expand All @@ -26,11 +26,13 @@ pub struct MemcachedCache;

impl MemcachedCache {
pub fn build(url: &str, expiration: u32) -> Result<Operator> {
let mut builder = memcached::Builder::default();
let mut builder = Memcached::default();
builder.endpoint(url);
builder.default_ttl(Duration::from_secs(expiration as u64));

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}
10 changes: 6 additions & 4 deletions src/cache/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::errors::*;
use opendal::layers::LoggingLayer;
use opendal::services::redis;
use opendal::services::Redis;
use opendal::Operator;
use std::collections::HashMap;
use std::time::Duration;
Expand All @@ -29,7 +29,7 @@ impl RedisCache {
pub fn build(url: &str) -> Result<Operator> {
let parsed = Url::parse(url)?;

let mut builder = redis::Builder::default();
let mut builder = Redis::default();
builder.endpoint(parsed.as_str());
builder.username(parsed.username());
builder.password(parsed.password().unwrap_or_default());
Expand All @@ -45,7 +45,9 @@ impl RedisCache {
.map(|v| v.parse().unwrap_or_default())
.unwrap_or_default());

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}
12 changes: 7 additions & 5 deletions src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// limitations under the License.

use opendal::layers::LoggingLayer;
use opendal::services::s3;
use opendal::services::S3;
use opendal::Operator;

use std::convert::TryInto;
Expand All @@ -29,21 +29,23 @@ impl S3Cache {
endpoint: Option<&str>,
use_ssl: Option<bool>,
) -> Result<Operator> {
let mut builder = s3::Builder::default();
let mut builder = S3::default();
builder.bucket(bucket);
if let Some(region) = region {
builder.region(region);
}
builder.root(key_prefix);
if no_credentials {
builder.disable_credential_loader();
builder.disable_config_load();
}
if let Some(endpoint) = endpoint {
builder.endpoint(&endpoint_resolver(endpoint, use_ssl)?);
}

let op: Operator = builder.build()?.into();
Ok(op.layer(LoggingLayer::default()))
let op = Operator::create(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
}
}

Expand Down
Loading