blob: ba60e42e7d64c8458878a48b46a2327e0bf2eb9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
import com.yahoo.component.Version;
/**
* A Docker image.
*
* @author mpolden
*/
public class DockerImage {
private final String name;
public DockerImage(String name) {
this.name = name;
}
/** Get Docker image tag as version */
public Version tagAsVersion() {
String[] parts = asString().split(":");
if (parts.length < 2) {
throw new IllegalArgumentException("Could not parse tag from Docker image '" + asString() + "'");
}
return Version.fromString(parts[parts.length - 1]);
}
/** Returns the Docker image tagged with the given version */
public DockerImage withTag(Version version) {
return new DockerImage(name + ":" + version.toFullString());
}
public String asString() {
return name;
}
}
|