Support creating from an XML string
@@ -80,7 +80,19 @@ public class DeploymentSpec {
*/
public static DeploymentSpec fromXml(Reader reader) {
try {
- String xmlForm = IOUtils.readAll(reader);
+ return fromXml(IOUtils.readAll(reader));
+ }
+ catch (IOException e) {
+ throw new IllegalArgumentException("Could not read deployment spec", e);
+ }
+ }
+
+ /**
+ * Creates a deployment spec from XML.
+ *
+ * @throws IllegalArgumentException if the XML is invalid
+ */
+ public static DeploymentSpec fromXml(String xmlForm) {
List<DeclaredZone> zones = new ArrayList<>();
Optional<String> globalServiceId = Optional.empty();
Element root = XML.getDocument(xmlForm).getDocumentElement();
@@ -106,10 +118,6 @@ public class DeploymentSpec {
}
return new DeploymentSpec(globalServiceId, readUpgradePolicy(root), zones, xmlForm);
}
- catch (IOException e) {
- throw new IllegalArgumentException("Could not read deployment spec", e);
- }
- }
private static boolean isEnvironmentName(String tagName) {
return tagName.equals("test") || tagName.equals("staging") || tagName.equals("prod");
