@Test public void test() { Object[][] srcs = new Object[][] { {"", new ImageName("", "", "", null)}, {"img", new ImageName("", "img", "", null)}, {"img:latest", new ImageName("", "img", "latest", null)}, {"hubrepo/img:latest", new ImageName("", "hubrepo/img", "latest", null)}, {"repo.org/img:latest", new ImageName("repo.org", "img", "latest", null)}, {"repo.org:80/img:latest", new ImageName("repo.org:80", "img", "latest", null)}, {"repo.org:80/ns/img:1.0", new ImageName("repo.org:80", "ns/img", "1.0", null)}, {"repo.org:80/img", new ImageName("repo.org:80", "img", "", null)}, {"debian@sha256:913c8c1da94e7d9d7fe21a45b4677770ecbb59087556e98fae5c45959f008351", new ImageName("", "debian", "", "sha256:913c8c1da94e7d9d7fe21a45b4677770ecbb59087556e98fae5c45959f008351")}, {"sha256:913c8c1da94e7d9d7fe21a45b4677770ecbb59087556e98fae5c45959f008351", new ImageName("", "", "", "sha256:913c8c1da94e7d9d7fe21a45b4677770ecbb59087556e98fae5c45959f008351")}, }; for(Object[] src: srcs) { String str = (String) src[0]; ImageName res = ImageName.parse(str); Assert.assertEquals("On parse: " + str, src[1], res); } }
public static ImageName parse(String src) { if(src == null) { return null; } int at = src.indexOf('@'); if(at < 0) { if(isId(src)) { return new ImageName("", src); } return new ImageName(src, null); } return new ImageName(src.substring(0, at), src.substring(at + 1)); }
ImageName { public static ImageName parse(String src) { if(src == null) { return null; } int at = src.indexOf('@'); if(at < 0) { if(isId(src)) { return new ImageName("", src); } return new ImageName(src, null); } return new ImageName(src.substring(0, at), src.substring(at + 1)); } }
ImageName { public static ImageName parse(String src) { if(src == null) { return null; } int at = src.indexOf('@'); if(at < 0) { if(isId(src)) { return new ImageName("", src); } return new ImageName(src, null); } return new ImageName(src.substring(0, at), src.substring(at + 1)); } ImageName(String registry, String name, String tag, String id); private  ImageName(String src, String id); }
ImageName { public static ImageName parse(String src) { if(src == null) { return null; } int at = src.indexOf('@'); if(at < 0) { if(isId(src)) { return new ImageName("", src); } return new ImageName(src, null); } return new ImageName(src.substring(0, at), src.substring(at + 1)); } ImageName(String registry, String name, String tag, String id); private  ImageName(String src, String id); String getId(); String getFullName(); String getTag(); String getRegistry(); String getName(); static ImageName parse(String src); static boolean isRegistry(String registry); static String getName(String name, String imageId); static String nameFromId(String imageId); static String nameWithId(String name, String id); static boolean isId(String image); static void assertName(String image); static String withoutTag(String name); static String withoutTagOrNull(String name); static String setTag(String image, String tag); }
ImageName { public static ImageName parse(String src) { if(src == null) { return null; } int at = src.indexOf('@'); if(at < 0) { if(isId(src)) { return new ImageName("", src); } return new ImageName(src, null); } return new ImageName(src.substring(0, at), src.substring(at + 1)); } ImageName(String registry, String name, String tag, String id); private  ImageName(String src, String id); String getId(); String getFullName(); String getTag(); String getRegistry(); String getName(); static ImageName parse(String src); static boolean isRegistry(String registry); static String getName(String name, String imageId); static String nameFromId(String imageId); static String nameWithId(String name, String id); static boolean isId(String image); static void assertName(String image); static String withoutTag(String name); static String withoutTagOrNull(String name); static String setTag(String image, String tag); static final String TAG_LATEST; static final String NONE; static final String NONE_NAME; static final int NAME_ID_LEN; }