1 unstable release
0.1.0 | Apr 10, 2023 |
---|
#862 in Unix APIs
Used in buildkit-rs
38KB
671 lines
A parser for image references.
Based on the canonical Docker image reference parser
Example
use buildkit_rs_reference::Reference;
// Parse a reference with no domain, an incomplete path, and a tag
let image = "alpine:latest";
let reference = Reference::parse_normalized_named(image).unwrap();
assert_eq!(reference.domain(), "docker.io");
assert_eq!(reference.path().as_deref(), Some("library/alpine"));
assert_eq!(reference.tag(), Some("latest"));
// Parse a reference with a domain and digest
let image = "b.gcr.io/alpine@sha256:86e0e091d0da6bde2456dbb48306f3956bbeb2eae1b5b9a43045843f69fe4aaa";
let reference = Reference::parse_normalized_named(image).unwrap();
assert_eq!(reference.domain(), "b.gcr.io");
assert_eq!(reference.path().as_deref(), Some("alpine"));
assert_eq!(reference.digest(), Some("sha256:86e0e091d0da6bde2456dbb48306f3956bbeb2eae1b5b9a43045843f69fe4aaa"));
Dependencies
~2.3–4MB
~71K SLoC