plugin: implement fs host api
This commit is contained in:
@@ -190,6 +190,11 @@ fn render_item_human(item: &PluginInspectionItem) -> Result<String> {
|
||||
" configured_https_grants: {}",
|
||||
join_or_none(&item.configured_https_grants)
|
||||
)?;
|
||||
writeln!(
|
||||
out,
|
||||
" configured_fs_grants: {}",
|
||||
join_or_none(&item.configured_fs_grants)
|
||||
)?;
|
||||
|
||||
if let Some(runtime) = &item.static_runtime {
|
||||
writeln!(
|
||||
@@ -360,6 +365,7 @@ fn snapshot_from_resolution(
|
||||
builder.enabled_surfaces = surface_strings(enablement.surfaces.iter().copied());
|
||||
builder.configured_grants = permission_strings(&enablement.grants.permissions);
|
||||
builder.configured_https_grants = https_grant_strings(&enablement.grants.https);
|
||||
builder.configured_fs_grants = fs_grant_strings(&enablement.grants.fs);
|
||||
if let Ok(identity) = SourceQualifiedPluginId::parse(&enablement.id) {
|
||||
builder
|
||||
.source
|
||||
@@ -452,6 +458,7 @@ fn fill_resolved(builder: &mut ItemBuilder, resolved: &ResolvedPlugin) {
|
||||
builder.requested_permissions = permission_strings(&resolved.manifest.permissions);
|
||||
builder.configured_grants = permission_strings(&resolved.grants.permissions);
|
||||
builder.configured_https_grants = https_grant_strings(&resolved.grants.https);
|
||||
builder.configured_fs_grants = fs_grant_strings(&resolved.grants.fs);
|
||||
|
||||
let record = ResolvedPluginRecord::from_resolved(resolved);
|
||||
let static_runtime = inspect_resolved_plugin_static(&record);
|
||||
@@ -554,6 +561,13 @@ fn https_grant_strings(grants: &[manifest::plugin::PluginHttpsGrant]) -> Vec<Str
|
||||
values
|
||||
}
|
||||
|
||||
fn fs_grant_strings(grants: &[manifest::plugin::PluginFsGrant]) -> Vec<String> {
|
||||
let mut values: Vec<_> = grants.iter().map(|grant| grant.label()).collect();
|
||||
values.sort();
|
||||
values.dedup();
|
||||
values
|
||||
}
|
||||
|
||||
fn permission_requested(manifest: &PluginPackageManifest, permission: &PluginPermission) -> bool {
|
||||
manifest
|
||||
.permissions
|
||||
@@ -625,6 +639,7 @@ struct PluginInspectionItem {
|
||||
requested_permissions: Vec<String>,
|
||||
configured_grants: Vec<String>,
|
||||
configured_https_grants: Vec<String>,
|
||||
configured_fs_grants: Vec<String>,
|
||||
tools: Vec<ToolSummary>,
|
||||
static_runtime: Option<PluginStaticInspection>,
|
||||
diagnostics: Vec<DiagnosticSummary>,
|
||||
@@ -693,6 +708,7 @@ struct ItemBuilder {
|
||||
requested_permissions: Vec<String>,
|
||||
configured_grants: Vec<String>,
|
||||
configured_https_grants: Vec<String>,
|
||||
configured_fs_grants: Vec<String>,
|
||||
tools: Vec<ToolSummary>,
|
||||
static_runtime: Option<PluginStaticInspection>,
|
||||
diagnostics: Vec<DiagnosticSummary>,
|
||||
@@ -719,6 +735,7 @@ impl ItemBuilder {
|
||||
requested_permissions: Vec::new(),
|
||||
configured_grants: Vec::new(),
|
||||
configured_https_grants: Vec::new(),
|
||||
configured_fs_grants: Vec::new(),
|
||||
tools: Vec::new(),
|
||||
static_runtime: None,
|
||||
diagnostics: Vec::new(),
|
||||
@@ -790,6 +807,7 @@ impl ItemBuilder {
|
||||
requested_permissions: self.requested_permissions,
|
||||
configured_grants: self.configured_grants,
|
||||
configured_https_grants: self.configured_https_grants,
|
||||
configured_fs_grants: self.configured_fs_grants,
|
||||
tools: self.tools,
|
||||
static_runtime: self.static_runtime,
|
||||
diagnostics: self.diagnostics,
|
||||
@@ -883,6 +901,7 @@ mod tests {
|
||||
PluginPermission::tool("Echo"),
|
||||
],
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
});
|
||||
@@ -900,6 +919,7 @@ mod tests {
|
||||
PluginPermission::tool("Echo"),
|
||||
],
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
});
|
||||
@@ -1017,6 +1037,7 @@ mod tests {
|
||||
PluginPermission::tool("Echo"),
|
||||
],
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
});
|
||||
@@ -1280,6 +1301,7 @@ mod tests {
|
||||
PluginPermission::tool("Echo"),
|
||||
],
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
}],
|
||||
@@ -1310,6 +1332,7 @@ mod tests {
|
||||
digest: Some(digest),
|
||||
permissions,
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
}
|
||||
@@ -1337,6 +1360,7 @@ mod tests {
|
||||
digest: None,
|
||||
permissions,
|
||||
https: Vec::new(),
|
||||
fs: Vec::new(),
|
||||
},
|
||||
config: None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user