rename new_context method

Summary:
This method is a footgun: it's easy to find for bootcampers working
on migration to new CLI and it's not a good choice for all usecases.

Let's rename it to stress out that it provided basic logging which won't suit
every usecase.

Reviewed By: clara-9

Differential Revision: D38469579

fbshipit-source-id: 5b08b0b1e5de4d2a54f2ed32f7a8585e19fd3c22
This commit is contained in:
Mateusz Kwapich 2022-08-08 04:06:51 -07:00 committed by Facebook GitHub Bot
parent 97d45dc989
commit 474614a431
20 changed files with 25 additions and 22 deletions

View File

@ -192,8 +192,11 @@ impl MononokeApp {
&self.env.readonly_storage
}
/// Create a basic CoreContext.
pub fn new_context(&self) -> CoreContext {
/// Create a basic CoreContext without scuba logging. Good choice for
/// simple CLI tools like admin.
///
/// Warning: returned context doesn't provide any scuba logging!
pub fn new_basic_context(&self) -> CoreContext {
CoreContext::new_with_logger(self.env.fb, self.logger().clone())
}
@ -406,7 +409,7 @@ impl MononokeApp {
let blobstore = if redaction == Redaction::Enabled {
let redacted_blobs = self
.repo_factory
.redacted_blobs(self.new_context(), &storage_config.metadata)
.redacted_blobs(self.new_basic_context(), &storage_config.metadata)
.await?;
RedactedBlobstore::new(
blobstore,

View File

@ -36,7 +36,7 @@ pub enum BlobstoreSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let blobstore = app
.open_blobstore(&args.repo_blobstore_args)

View File

@ -99,7 +99,7 @@ async fn get_blobstore(
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo_arg = args.repo_args.id_or_name()?;
let (_repo_name, repo_config) = app.repo_config(repo_arg)?;

View File

@ -97,7 +97,7 @@ pub enum BookmarksSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -77,7 +77,7 @@ pub enum ChangelogSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo_args)

View File

@ -120,7 +120,7 @@ pub enum CommitSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo_args)

View File

@ -60,7 +60,7 @@ pub struct Repo {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -202,7 +202,7 @@ impl FetchPublicArgs {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app.open_repo(&args.repo).await?;
let input_format = args.input_format;

View File

@ -53,7 +53,7 @@ pub enum EphemeralStoreSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app.open_repo(&args.repo).await?;
let subcommand_result = match args.subcommand {

View File

@ -81,7 +81,7 @@ pub enum ManifestKind {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo_args)

View File

@ -114,7 +114,7 @@ impl FilestoreItemIdArgs {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -89,7 +89,7 @@ pub enum HgSyncSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -79,7 +79,7 @@ pub enum MutableRenamesSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -69,7 +69,7 @@ pub enum RedactionSubcommand {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
match args.subcommand {
RedactionSubcommand::CreateKeyList(create_args) => {

View File

@ -33,7 +33,7 @@ pub struct Repo {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo)

View File

@ -78,7 +78,7 @@ fn get_blobstore_key(key_arg: Option<String>, config: RepoConfig) -> Result<Stri
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo_arg = args.repo.id_or_name()?;
let (_, repo_config) = app.repo_config(repo_arg)?;
let logger = &app.logger();

View File

@ -58,7 +58,7 @@ pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
.await
.context("Failed to open repo")?;
let ctx = app.new_context();
let ctx = app.new_basic_context();
stream::iter(entries)
.try_for_each_concurrent(args.concurrency, {

View File

@ -46,7 +46,7 @@ pub struct CommandArgs {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let mut content = String::new();
File::open(&args.bonsai_file)

View File

@ -303,7 +303,7 @@ fn print_name_hash_pairs(pairs: impl IntoIterator<Item = (String, impl Display)>
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: BlobRepo = app
.open_repo(&args.repo_args)

View File

@ -93,7 +93,7 @@ pub struct Repo {
}
pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
let ctx = app.new_context();
let ctx = app.new_basic_context();
let repo: Repo = app
.open_repo(&args.repo_args)