Skip to content

Commit

Permalink
'buck2_re_configuration': remove anyhow usage
Browse files Browse the repository at this point in the history
Summary: ^

Reviewed By: iguridi

Differential Revision: D65311904

fbshipit-source-id: f0595ebb03426d2ee1884747f80ae7e730397c0b
  • Loading branch information
Will-MingLun-Li authored and facebook-github-bot committed Nov 2, 2024
1 parent 583ba2f commit a4df9cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/buck2_re_configuration/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ rust_library(
name = "buck2_re_configuration",
srcs = glob(["src/**/*.rs"]),
deps = [
"fbsource//third-party/rust:anyhow",
"//buck2/allocative/allocative:allocative",
"//buck2/app/buck2_common:buck2_common",
"//buck2/app/buck2_core:buck2_core",
"//buck2/app/buck2_error:buck2_error",
],
)
2 changes: 1 addition & 1 deletion app/buck2_re_configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ version = "0.1.0"

[dependencies]
allocative = { workspace = true }
anyhow = { workspace = true }
buck2_common = { workspace = true }
buck2_core = { workspace = true }
buck2_error = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fbcode_build)"] }
13 changes: 7 additions & 6 deletions app/buck2_re_configuration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static BUCK2_RE_CLIENT_CFG_SECTION: &str = "buck2_re_client";
/// We put functions here that both things need to implement for code that isn't gated behind a
/// fbcode_build or not(fbcode_build)
pub trait RemoteExecutionStaticMetadataImpl: Sized {
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self>;
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self>;
fn cas_semaphore_size(&self) -> usize;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ mod fbcode {
}

impl RemoteExecutionStaticMetadataImpl for RemoteExecutionStaticMetadata {
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
Ok(Self {
cas_address: legacy_config.parse(BuckconfigKeyRef {
section: BUCK2_RE_CLIENT_CFG_SECTION,
Expand Down Expand Up @@ -249,7 +249,7 @@ mod not_fbcode {
pub struct RemoteExecutionStaticMetadata(pub Buck2OssReConfiguration);

impl RemoteExecutionStaticMetadataImpl for RemoteExecutionStaticMetadata {
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
Ok(Self(Buck2OssReConfiguration::from_legacy_config(
legacy_config,
)?))
Expand Down Expand Up @@ -313,7 +313,7 @@ pub struct HttpHeader {
}

impl FromStr for HttpHeader {
type Err = anyhow::Error;
type Err = buck2_error::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut iter = s.split(':');
Expand All @@ -322,7 +322,8 @@ impl FromStr for HttpHeader {
key: key.trim().to_owned(),
value: value.trim().to_owned(),
}),
_ => Err(anyhow::anyhow!(
_ => Err(buck2_error::buck2_error!(
[],
"Invalid header (expect exactly one `:`): `{}`",
s
)),
Expand All @@ -331,7 +332,7 @@ impl FromStr for HttpHeader {
}

impl Buck2OssReConfiguration {
pub fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> anyhow::Result<Self> {
pub fn from_legacy_config(legacy_config: &LegacyBuckConfig) -> buck2_error::Result<Self> {
// this is used for all three services by default, if given; if one of
// them has an explicit address given as well though, use that instead
let default_address: Option<String> = legacy_config.parse(BuckconfigKeyRef {
Expand Down

0 comments on commit a4df9cc

Please sign in to comment.