#reference #parser #tags #domain #buildkit #docker #path

buildkit-rs-reference

A parser for image references, based on the reference go package

1 unstable release

0.1.0 Apr 10, 2023

#891 in Unix APIs

21 downloads per month
Used in buildkit-rs

Apache-2.0 OR MIT

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.4–4MB
~71K SLoC