Skip to content

Commit

Permalink
[Signature] Add top level API.
Browse files Browse the repository at this point in the history
Expose the image structure and policy structure in the crate root `lib.rs`.
The caller can use the signature library as follows:

```rust
use signature::{Image, Policy};
use oci_distribution::Reference;

let reference = Reference::try_from("docker.io/library/example:tag").unwrap();
let image_digest = "sha256:sha256:69704ef328d05a9f806b6b8502915e6a0a4faa4d72018dc42343f511490daf8a";

let policy = Policy::from_file("path/to/policy/file").unwrap();

let mut image = Image::default_with_reference(reference);
image.set_manifest_digest(image_digest)?;

policy.is_image_allowed(image).except("Validate image failed");
```

Signed-off-by: Jiale Zhang <[email protected]>
  • Loading branch information
jialez0 authored and sameo committed Apr 1, 2022
1 parent 4cb6901 commit e1ab4ae
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions signature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ extern crate strum;
mod image;
mod policy;
mod signatures;

pub use image::Image;
pub use policy::Policy;

0 comments on commit e1ab4ae

Please sign in to comment.