Skip to content

Commit

Permalink
Fix docker image parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
schrieveslaach committed Feb 1, 2019
1 parent fd920e5 commit e857f56
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/src/models/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit e857f56

Please sign in to comment.