Permalink
Browse files

Fix docker image parsing

  • Loading branch information...
schrieveslaach committed Feb 1, 2019
1 parent fd920e5 commit e857f56602f175a7da6cdc3345f34c580811ddd9
Showing with 10 additions and 1 deletion.
  1. +10 −1 api/src/models/service.rs
@@ -366,7 +366,7 @@ impl std::str::FromStr for Image {
}

regex = Regex::new(
r"^(((?P<registry>.+)/)?(?P<user>[\w-]+)/)?(?P<repo>[\w-]+)(:(?P<tag>[\w-]+))?$",
r"^(((?P<registry>.+)/)?(?P<user>[\w-]+)/)?(?P<repo>[\w-]+)(:(?P<tag>[\w\.-]+))?$",
)
.unwrap();
let captures = match regex.captures(s) {
@@ -465,6 +465,15 @@ mod tests {

#[test]
fn should_parse_image_with_version() {
let image = Image::from_str("mariadb:10.3").unwrap();

assert_eq!(&image.get_name().unwrap(), "library/mariadb");
assert_eq!(&image.get_tag().unwrap(), "10.3");
assert_eq!(&image.to_string(), "docker.io/library/mariadb:10.3");
}

#[test]
fn should_parse_image_with_latest_version() {
let image = Image::from_str("nginx:latest").unwrap();

assert_eq!(&image.get_name().unwrap(), "library/nginx");

0 comments on commit e857f56

Please sign in to comment.