From e0281141684789473e8f905ffd9a27fdbd6e9d1c Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Tue, 7 Sep 2021 11:49:29 +0200 Subject: Add deployedDirectly to ApplicationVersion --- .../integration/deployment/ApplicationVersion.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'controller-api/src') diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java index 30fd8fad1bd..a9a3e080109 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/ApplicationVersion.java @@ -23,7 +23,7 @@ public class ApplicationVersion implements Comparable { */ public static final ApplicationVersion unknown = new ApplicationVersion(Optional.empty(), OptionalLong.empty(), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty(), Optional.empty()); + Optional.empty(), Optional.empty(), false); // 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"; @@ -35,11 +35,12 @@ public class ApplicationVersion implements Comparable { private final Optional buildTime; private final Optional sourceUrl; private final Optional commit; + private final boolean deployedDirectly; /** Public for serialisation only. */ public ApplicationVersion(Optional source, OptionalLong buildNumber, Optional authorEmail, - Optional compileVersion, Optional buildTime, Optional sourceUrl, - Optional commit) { + Optional compileVersion, Optional buildTime, Optional sourceUrl, + Optional commit, boolean deployedDirectly) { if (buildNumber.isEmpty() && ( source.isPresent() || authorEmail.isPresent() || compileVersion.isPresent() || buildTime.isPresent() || sourceUrl.isPresent() || commit.isPresent())) throw new IllegalArgumentException("Build number must be present if any other attribute is"); @@ -63,32 +64,27 @@ public class ApplicationVersion implements Comparable { this.buildTime = buildTime; this.sourceUrl = Objects.requireNonNull(sourceUrl, "sourceUrl cannot be null"); this.commit = Objects.requireNonNull(commit, "commit cannot be null"); + this.deployedDirectly = deployedDirectly; } /** Create an application package version from a completed build, without an author email */ public static ApplicationVersion from(SourceRevision source, long buildNumber) { return new ApplicationVersion(Optional.of(source), OptionalLong.of(buildNumber), Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); - } - - /** Creates an version from a completed build and an author email. */ - public static ApplicationVersion from(SourceRevision source, long buildNumber, String authorEmail) { - return new ApplicationVersion(Optional.of(source), OptionalLong.of(buildNumber), Optional.of(authorEmail), - Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), false); } /** Creates an version from a completed build, an author email, and build meta data. */ public static ApplicationVersion from(SourceRevision source, long buildNumber, String authorEmail, Version compileVersion, Instant buildTime) { return new ApplicationVersion(Optional.of(source), OptionalLong.of(buildNumber), Optional.of(authorEmail), - Optional.of(compileVersion), Optional.of(buildTime), Optional.empty(), Optional.empty()); + Optional.of(compileVersion), Optional.of(buildTime), Optional.empty(), Optional.empty(), false); } /** Creates an version from a completed build, an author email, and build meta data. */ public static ApplicationVersion from(Optional source, long buildNumber, Optional authorEmail, Optional compileVersion, Optional buildTime, - Optional sourceUrl, Optional commit) { - return new ApplicationVersion(source, OptionalLong.of(buildNumber), authorEmail, compileVersion, buildTime, sourceUrl, commit); + Optional sourceUrl, Optional commit, boolean deployedDirectly) { + return new ApplicationVersion(source, OptionalLong.of(buildNumber), authorEmail, compileVersion, buildTime, sourceUrl, commit, deployedDirectly); } /** Returns an unique identifier for this version or "unknown" if version is not known */ @@ -142,18 +138,24 @@ public class ApplicationVersion implements Comparable { return this.equals(unknown); } + /** Returns whether the application package for this version was deployed directly to zone */ + public boolean isDeployedDirectly() { + return deployedDirectly; + } + @Override public boolean equals(Object o) { if (this == o) return true; if ( ! (o instanceof ApplicationVersion)) return false; ApplicationVersion that = (ApplicationVersion) o; return Objects.equals(buildNumber, that.buildNumber) - && Objects.equals(commit(), that.commit()); + && Objects.equals(commit(), that.commit()) + && deployedDirectly == that.deployedDirectly; } @Override public int hashCode() { - return Objects.hash(buildNumber, commit()); + return Objects.hash(buildNumber, commit(), deployedDirectly); } @Override -- cgit v1.2.3