Skip to content

Commit 6284232

Browse files
gustavoavenameta-codesync[bot]
authored andcommitted
code_tenting: Add new flags to scsc and integration test
Summary: ## This stack Implements functionality requested by the Code Search team: efficiently get all the tents that the client has access to. ## This diff Adds the flags to scsc and an integration test Reviewed By: lmvasquezg Differential Revision: D102157528 fbshipit-source-id: 262c438583494125f8e2fe43a204239cc9e9376f
1 parent 4b74a89 commit 6284232

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

  • eden/mononoke/clients/scsc/src/commands/restricted_paths

eden/mononoke/clients/scsc/src/commands/restricted_paths/find.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ pub(super) struct FindArgs {
3030
repo_args: RepoArgs,
3131
#[clap(flatten)]
3232
commit_id_args: CommitIdArgs,
33+
#[clap(long)]
34+
/// Check access permissions (populates `has_access` in the streamed output)
35+
check_permissions: bool,
36+
#[clap(long)]
37+
/// Return only restriction roots the caller can access
38+
return_only_accessible: bool,
3339
#[clap(long, short)]
3440
/// Root paths to search under (empty for entire repository)
3541
root: Option<Vec<String>>,
@@ -39,13 +45,25 @@ pub(super) struct FindArgs {
3945
struct FindOutput {
4046
path: String,
4147
acls: Vec<String>,
48+
has_access: Option<bool>,
4249
}
4350

4451
impl Render for FindOutput {
4552
type Args = ();
4653

4754
fn render(&self, _args: &Self::Args, w: &mut dyn Write) -> Result<()> {
48-
writeln!(w, "{} (ACLs: {})", self.path, self.acls.join(", "))?;
55+
let access = match self.has_access {
56+
Some(true) => ", access: allowed",
57+
Some(false) => ", access: denied",
58+
None => "",
59+
};
60+
writeln!(
61+
w,
62+
"{} (ACLs: {}{})",
63+
self.path,
64+
self.acls.join(", "),
65+
access
66+
)?;
4967
Ok(())
5068
}
5169

@@ -69,6 +87,8 @@ pub(super) async fn run(app: ScscApp, args: FindArgs) -> Result<()> {
6987
let roots = args.root.unwrap_or_default().into_iter().collect();
7088
let params = thrift::CommitFindRestrictedPathsParams {
7189
roots,
90+
check_permissions: Some(args.check_permissions),
91+
return_only_accessible: Some(args.return_only_accessible),
7292
..Default::default()
7393
};
7494

@@ -81,6 +101,7 @@ pub(super) async fn run(app: ScscApp, args: FindArgs) -> Result<()> {
81101
.map_ok(|item| FindOutput {
82102
path: item.path,
83103
acls: item.acls,
104+
has_access: item.has_access,
84105
})
85106
.map_err(Into::into);
86107

0 commit comments

Comments
 (0)