diff options
author | Andreas Eriksen <andreer@yahooinc.com> | 2024-01-11 14:54:24 +0100 |
---|---|---|
committer | Andreas Eriksen <andreer@yahooinc.com> | 2024-01-11 15:29:36 +0100 |
commit | d19c9d7be588a9a989cc9e38af10177dfdfdf7fc (patch) | |
tree | ea6fa206169a37fc81f1112565cd6792a87d5ece /vespa-maven-plugin/src | |
parent | 649a5ba83bf0ab9f05674e12eca2da51da473847 (diff) |
specify cloud for effectiveServices mojo
Diffstat (limited to 'vespa-maven-plugin/src')
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/EffectiveServicesMojo.java | 11 | ||||
-rw-r--r-- | vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java | 7 |
2 files changed, 12 insertions, 6 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/EffectiveServicesMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/EffectiveServicesMojo.java index f3c7a23d8bc..9e06faf9180 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/EffectiveServicesMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/EffectiveServicesMojo.java @@ -2,6 +2,7 @@ package ai.vespa.hosted.plugin; import com.yahoo.config.application.XmlPreProcessor; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.Tags; import com.yahoo.config.provision.zone.ZoneId; @@ -37,6 +38,9 @@ public class EffectiveServicesMojo extends AbstractVespaDeploymentMojo { @Parameter(property = "outputDirectory", defaultValue = "target") private String outputDirectory; + @Parameter(property = "cloud", defaultValue = "default") + private String cloud; + @Override protected void doExecute() throws Exception { File services = new File(servicesFile); @@ -46,20 +50,21 @@ public class EffectiveServicesMojo extends AbstractVespaDeploymentMojo { ZoneId zone = zoneOf(environment, region); Path output = Paths.get(outputDirectory).resolve("services-" + zone.environment().value() + "-" + zone.region().value() + ".xml"); Tags tagz = Tags.fromString(tags); - Files.write(output, effectiveServices(services, zone, InstanceName.from(instance), tagz).getBytes(StandardCharsets.UTF_8)); + Files.write(output, effectiveServices(services, zone, CloudName.from(cloud), InstanceName.from(instance), tagz).getBytes(StandardCharsets.UTF_8)); getLog().info("Effective services for " + zone + ", instance " + instance + ( tags == null ? "" : ", tags '" + tagz + "'") + " written to " + output); } - static String effectiveServices(File servicesFile, ZoneId zone, InstanceName instance, Tags tags) throws Exception { + static String effectiveServices(File servicesFile, ZoneId zone, CloudName cloud, InstanceName instance, Tags tags) throws Exception { Document processedServicesXml = new XmlPreProcessor(servicesFile.getParentFile(), servicesFile, instance, zone.environment(), zone.region(), - zone.cloud(), tags) + cloud, + tags) .run(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); diff --git a/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java b/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java index 89c6ab83801..b19910e50b8 100644 --- a/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java +++ b/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java @@ -1,6 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package ai.vespa.hosted.plugin; +import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.Tags; import com.yahoo.config.provision.zone.ZoneId; @@ -27,21 +28,21 @@ class EffectiveServicesMojoTest { @DisplayName("when zone matches environment-only directive") void devServices() throws Exception { assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/dev.xml")), - effectiveServices(servicesFile, ZoneId.from("dev", "us-east-3"), InstanceName.defaultName(), Tags.empty())); + effectiveServices(servicesFile, ZoneId.from("dev", "us-east-3"), CloudName.DEFAULT, InstanceName.defaultName(), Tags.empty())); } @Test @DisplayName("when zone matches region-and-environment directive") void prodUsEast3() throws Exception { assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-east-3.xml")), - effectiveServices(servicesFile, ZoneId.from("prod", "us-east-3"), InstanceName.defaultName(), Tags.empty())); + effectiveServices(servicesFile, ZoneId.from("prod", "us-east-3"), CloudName.DEFAULT, InstanceName.defaultName(), Tags.empty())); } @Test @DisplayName("when zone doesn't match any directives") void prodUsWest1Services() throws Exception { assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-west-1.xml")), - effectiveServices(servicesFile, ZoneId.from("prod", "us-west-1"), InstanceName.defaultName(), Tags.empty())); + effectiveServices(servicesFile, ZoneId.from("prod", "us-west-1"), CloudName.DEFAULT, InstanceName.defaultName(), Tags.empty())); } } |