Skip to content

Commit

Permalink
eden-client refactoring: move getConfig
Browse files Browse the repository at this point in the history
Summary:
## Context
We should not directly make Thrift calls from EdenFS cli commands/subcommands. Instead, encapsulate the methods into the eden instance.
## This Diff
Wraps `getConfig` as the eden instance method.
## Note
There is already a method of eden instance called `get_config` which is a wrapper around `edenfs_config::load_config` so I named the  new method "get_config_default" since it's calling with the default arg.

Reviewed By: jdelliot

Differential Revision: D67367636

fbshipit-source-id: e844efe44a752f917a2bfeef05002cd64c4b767c
  • Loading branch information
lXXXw authored and facebook-github-bot committed Dec 18, 2024
1 parent fced4f8 commit a2f95fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions eden/fs/cli_rs/edenfs-client/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use thrift_streaming_thriftclients::build_StreamingEdenService_client;
#[cfg(fbcode_build)]
use thrift_types::edenfs::ChangesSinceV2Params;
use thrift_types::edenfs::DaemonInfo;
use thrift_types::edenfs::GetConfigParams;
use thrift_types::edenfs::GetCurrentSnapshotInfoRequest;
use thrift_types::edenfs::GetScmStatusParams;
use thrift_types::edenfs::MountId;
Expand Down Expand Up @@ -539,6 +540,19 @@ impl EdenFsInstance {

Ok(())
}

pub async fn get_config_default(&self) -> Result<thrift_types::edenfs_config::EdenConfigData> {
let client = self
.connect(None)
.await
.with_context(|| "Unable to connect to EdenFS daemon")?;

let params: GetConfigParams = Default::default();
client
.getConfig(&params)
.await
.map_err(|_| EdenFsError::Other(anyhow!("failed to get default eden config data")))
}
}

pub trait DaemonHealthy {
Expand Down
6 changes: 1 addition & 5 deletions eden/fs/cli_rs/edenfs-commands/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use edenfs_client::EdenFsInstance;
#[cfg(windows)]
use edenfs_utils::find_python;
use hg_util::path::expand_path;
use thrift_types::edenfs::GetConfigParams;
use thrift_types::edenfs_config::ConfigSourceType;

use crate::ExitCode;
Expand Down Expand Up @@ -204,10 +203,7 @@ pub struct FsConfigCmd {
impl crate::Subcommand for FsConfigCmd {
async fn run(&self) -> Result<ExitCode> {
let instance = EdenFsInstance::global();
let client = instance.connect(None).await?;

let params: GetConfigParams = Default::default();
let config_data = client.getConfig(&params).await?;
let config_data = instance.get_config_default().await?;

let mut current_section: Option<String> = None;

Expand Down

0 comments on commit a2f95fa

Please sign in to comment.