Skip to content

Commit

Permalink
added key_permissions method to package LogState (#251)
Browse files Browse the repository at this point in the history
Added method to determine what permissions a given `KeyID` has for a
package.
  • Loading branch information
calvinrp authored Feb 27, 2024
1 parent 55877dc commit 7794fa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl<R: RegistryStorage, C: ContentStorage, N: NamespaceMapStorage> Client<R, C,
if let Ok(Some(nm)) = namespace_state {
if let warg_protocol::operator::NamespaceState::Imported { registry } = nm {
self.api
.set_warg_registry(Some(RegistryDomain::from_str(&registry)?));
.set_warg_registry(Some(RegistryDomain::from_str(registry)?));
}
true
} else {
Expand Down
7 changes: 7 additions & 0 deletions crates/protocol/src/package/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ impl LogState {
self.keys.get(key_id)
}

/// Gets the key permissions.
///
/// Returns `None` if the key id is not recognized.
pub fn key_permissions(&self, key_id: &signing::KeyID) -> Option<&IndexSet<model::Permission>> {
self.permissions.get(key_id)
}

fn initialized(&self) -> bool {
// The package log is initialized if the hash algorithm is set
self.algorithm.is_some()
Expand Down

0 comments on commit 7794fa0

Please sign in to comment.