diff options
author | Martin Polden <mpolden@mpolden.no> | 2018-02-07 12:33:07 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2018-02-20 13:27:01 +0100 |
commit | 2c96d6fa6b8e03481d1c11bc8f2da661560989b9 (patch) | |
tree | ae8089c2b2475dcf8063efc8f85ef089ac988c57 /controller-server/src/main | |
parent | 5df193d95df61ad3db8917f39371fbadab7a9ef6 (diff) |
Remove applicationPackageHash
Diffstat (limited to 'controller-server/src/main')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java index 31ee5fa6d44..e8d0001d451 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java @@ -5,8 +5,7 @@ import java.util.Objects; import java.util.Optional; /** - * An application package version. This represents an build artifact, identified by a source revision and a build - * number. + * An application package version, identified by a source revision and a build number. * * @author bratseth * @author mpolden @@ -17,66 +16,40 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> { * Used in cases where application version cannot be determined, such as manual deployments (e.g. in dev * environment) */ - public static final ApplicationVersion unknown = new ApplicationVersion(); + public static final ApplicationVersion unknown = new ApplicationVersion(Optional.empty(), Optional.empty()); // This never changes and is only used to create a valid semantic version number, as required by application bundles private static final String majorVersion = "1.0"; - // TODO: Remove after 2018-03-01 - private final Optional<String> applicationPackageHash; private final Optional<SourceRevision> source; private final Optional<Long> buildNumber; - private ApplicationVersion() { - this.applicationPackageHash = Optional.empty(); - this.source = Optional.empty(); - this.buildNumber = Optional.empty(); - } - - private ApplicationVersion(Optional<String> applicationPackageHash, Optional<SourceRevision> source, - Optional<Long> buildNumber) { - Objects.requireNonNull(applicationPackageHash, "applicationPackageHash cannot be null"); + private ApplicationVersion(Optional<SourceRevision> source, Optional<Long> buildNumber) { Objects.requireNonNull(source, "source cannot be null"); Objects.requireNonNull(buildNumber, "buildNumber cannot be null"); - if (!applicationPackageHash.isPresent() && source.isPresent() != buildNumber.isPresent()) { + if (source.isPresent() != buildNumber.isPresent()) { throw new IllegalArgumentException("both buildNumber and source must be set together"); } if (buildNumber.isPresent() && buildNumber.get() <= 0) { throw new IllegalArgumentException("buildNumber must be > 0"); } - this.applicationPackageHash = applicationPackageHash; this.source = source; this.buildNumber = buildNumber; } - /** Create an application package revision where there is no information about its source */ - public static ApplicationVersion from(String applicationPackageHash) { - return new ApplicationVersion(Optional.of(applicationPackageHash), Optional.empty(), Optional.empty()); - } - - /** Create an application package revision with a source */ - public static ApplicationVersion from(String applicationPackageHash, SourceRevision source) { - return new ApplicationVersion(Optional.of(applicationPackageHash), Optional.of(source), Optional.empty()); - } - /** Create an application package version from a completed build */ public static ApplicationVersion from(SourceRevision source, long buildNumber) { - return new ApplicationVersion(Optional.empty(), Optional.of(source), Optional.of(buildNumber)); + return new ApplicationVersion(Optional.of(source), Optional.of(buildNumber)); } - /** Returns an unique identifier for this version */ + /** Returns an unique identifier for this version or "unknown" if version is not known */ public String id() { - if (applicationPackageHash.isPresent()) { - return applicationPackageHash.get(); + if (isUnknown()) { + return "unknown"; } - return source.map(sourceRevision -> String.format("%s.%d-%s", majorVersion, buildNumber.get(), - abbreviateCommit(source.get().commit()))) - .orElse("unknown"); + return String.format("%s.%d-%s", majorVersion, buildNumber.get(), abbreviateCommit(source.get().commit())); } - /** Returns the application package hash, if known */ - public Optional<String> applicationPackageHash() { return applicationPackageHash; } - /** * Returns information about the source of this revision, or empty if the source is not know/defined * (which is the case for command-line deployment from developers, but never for deployment jobs) @@ -96,14 +69,13 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ApplicationVersion that = (ApplicationVersion) o; - return Objects.equals(applicationPackageHash, that.applicationPackageHash) && - Objects.equals(source, that.source) && + return Objects.equals(source, that.source) && Objects.equals(buildNumber, that.buildNumber); } @Override public int hashCode() { - return Objects.hash(applicationPackageHash, source, buildNumber); + return Objects.hash(source, buildNumber); } @Override |