use of com.yahoo.config.application.api.DeploymentSpec.Step in project vespa by vespa-engine.
the class DeploymentSpecXmlReader method read.
/**
* Reads a deployment spec from XML
*/
public DeploymentSpec read(String xmlForm) {
List<Step> steps = new ArrayList<>();
Optional<String> globalServiceId = Optional.empty();
Element root = XML.getDocument(xmlForm).getDocumentElement();
if (validate)
validateTagOrder(root);
for (Element environmentTag : XML.getChildren(root)) {
if (!isEnvironmentName(environmentTag.getTagName()))
continue;
Environment environment = Environment.from(environmentTag.getTagName());
if (environment == Environment.prod) {
for (Element stepTag : XML.getChildren(environmentTag)) {
Optional<AthenzService> athenzService = stringAttribute("athenz-service", environmentTag).map(AthenzService::from);
if (stepTag.getTagName().equals("delay")) {
steps.add(new Delay(Duration.ofSeconds(longAttribute("hours", stepTag) * 60 * 60 + longAttribute("minutes", stepTag) * 60 + longAttribute("seconds", stepTag))));
} else if (stepTag.getTagName().equals("parallel")) {
List<DeclaredZone> zones = new ArrayList<>();
for (Element regionTag : XML.getChildren(stepTag)) {
zones.add(readDeclaredZone(environment, athenzService, regionTag));
}
steps.add(new ParallelZones(zones));
} else {
// a region: deploy step
steps.add(readDeclaredZone(environment, athenzService, stepTag));
}
}
} else {
steps.add(new DeclaredZone(environment));
}
if (environment == Environment.prod)
globalServiceId = readGlobalServiceId(environmentTag);
else if (readGlobalServiceId(environmentTag).isPresent())
throw new IllegalArgumentException("Attribute 'global-service-id' is only valid on 'prod' tag.");
}
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);
}
Aggregations