diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-10-18 12:45:33 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-10-18 12:45:33 +0200 |
commit | ff5425a5ced4134efcf8682c04d546e89bbe770e (patch) | |
tree | 493b20ea1082cd23f74195bb5b0aa4c2866ec72a /config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java | |
parent | 0a5aeca4ccd596256bb1ee9265857499440de0a4 (diff) |
Don't upgrade if major version i pinned
Add major-version to deployment as that makes it
available to deployment orchestration.
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java')
-rw-r--r-- | config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java index 8bc4e0026a6..1900e2139cd 100644 --- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java +++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; */ public class DeploymentSpecXmlReader { + private static final String majorVersionTag = "major-version"; private static final String testTag = "test"; private static final String stagingTag = "staging"; private static final String blockChangeTag = "block-change"; @@ -101,7 +102,14 @@ public class DeploymentSpecXmlReader { } Optional<AthenzDomain> athenzDomain = stringAttribute("athenz-domain", root).map(AthenzDomain::from); Optional<AthenzService> athenzService = stringAttribute("athenz-service", root).map(AthenzService::from); - return new DeploymentSpec(globalServiceId, readUpgradePolicy(root), readChangeBlockers(root), steps, xmlForm, athenzDomain, athenzService); + return new DeploymentSpec(globalServiceId, + readUpgradePolicy(root), + optionalIntegerAttribute(majorVersionTag, root), + readChangeBlockers(root), + steps, + xmlForm, + athenzDomain, + athenzService); } /** Imposes some constraints on tag order which are not expressible in the schema */ @@ -138,6 +146,19 @@ public class DeploymentSpecXmlReader { } } + /** Returns the given attribute as an integer, or 0 if it is not present */ + private Optional<Integer> optionalIntegerAttribute(String attributeName, Element tag) { + String value = tag.getAttribute(attributeName); + if (value == null || value.isEmpty()) return Optional.empty(); + try { + return Optional.of(Integer.parseInt(value)); + } + catch (NumberFormatException e) { + throw new IllegalArgumentException("Expected an integer for attribute '" + attributeName + + "' but got '" + value + "'"); + } + } + /** Returns the given attribute as a string, or Optional.empty if it is not present or empty */ private Optional<String> stringAttribute(String attributeName, Element tag) { String value = tag.getAttribute(attributeName); |