diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-07 21:43:28 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-09 11:18:39 +0200 |
commit | 35f588ddb5f70de25360d4a37cfa71d85d2408b6 (patch) | |
tree | ca21d0b1e18d0d9e8138fc53fa076b471859a486 /controller-api | |
parent | f3181bc95684341d3a9ea94edb025115c5af5ca3 (diff) |
Add dev deployments to JobType members
Diffstat (limited to 'controller-api')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java index c04527c0c4d..bf5f6ebb907 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobType.java @@ -13,6 +13,7 @@ import java.util.stream.Stream; import static com.yahoo.config.provision.SystemName.cd; import static com.yahoo.config.provision.SystemName.main; +import static com.yahoo.config.provision.SystemName.vaas; /** Job types that exist in the build system */ public enum JobType { @@ -58,6 +59,12 @@ public enum JobType { productionAwsUsEast1b ("production-aws-us-east-1b", Map.of(main, ZoneId.from("prod" , "aws-us-east-1b"))), + devUsEast1 ("dev-us-east-1", + Map.of(main, ZoneId.from("dev" , "us-east-1"))), + + devAwsUsEast2a ("dev-aws-us-east-2a", + Map.of(main, ZoneId.from("dev" , "us-east-1"))), + productionCdAwsUsEast1a("production-cd-aws-us-east-1a", Map.of(cd , ZoneId.from("prod" , "cd-aws-us-east-1a"))), @@ -69,12 +76,21 @@ public enum JobType { Map.of(cd , ZoneId.from("prod" , "cd-us-central-2"))), productionCdUsWest1 ("production-cd-us-west-1", - Map.of(cd , ZoneId.from("prod" , "cd-us-west-1"))); + Map.of(cd , ZoneId.from("prod" , "cd-us-west-1"))), + + devCdUsCentral1 ("dev-cd-us-central-1", + Map.of(cd , ZoneId.from("dev" , "cd-us-central-1"))), + + devAwsUsEast1b ("dev-aws-us-east-1b", + Map.of(vaas, ZoneId.from("dev" , "vaas-aws-us-east-1b"))); private final String jobName; private final Map<SystemName, ZoneId> zones; JobType(String jobName, Map<SystemName, ZoneId> zones) { + if (zones.values().stream().map(ZoneId::environment).distinct().count() > 1) + throw new IllegalArgumentException("All zones of a job must be in the same environment"); + this.jobName = jobName; this.zones = zones; } @@ -97,12 +113,8 @@ public enum JobType { /** Returns the environment of this job type, or null if it does not have an environment */ public Environment environment() { - switch (this) { - case component: return null; - case systemTest: return Environment.test; - case stagingTest: return Environment.staging; - default: return Environment.prod; - } + if (this == component) return null; + return zones.values().iterator().next().environment(); } public static Optional<JobType> fromOptionalJobName(String jobName) { @@ -118,10 +130,9 @@ public enum JobType { /** Returns the job type for the given zone */ public static Optional<JobType> from(SystemName system, ZoneId zone) { - for (JobType job : values()) - if (zone.equals(job.zones.get(system))) - return Optional.of(job); - return Optional.empty(); + return Stream.of(values()) + .filter(job -> zone.equals(job.zones.get(system))) + .findAny(); } /** Returns the job job type for the given environment and region or null if none */ |