diff options
3 files changed, 26 insertions, 16 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java index ca812f92c49..17cf38a9118 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java @@ -76,7 +76,7 @@ public abstract class ControllerHttpClient { /** Sends the given deployment to the given application in the given zone, or throws if this fails. */ public DeploymentResult deploy(Deployment deployment, ApplicationId id, ZoneId zone) { - return toDeploymentResult(send(request(HttpRequest.newBuilder(deploymentPath(id, zone)) + return toDeploymentResult(send(request(HttpRequest.newBuilder(deploymentJobPath(id, zone)) .timeout(Duration.ofMinutes(60)), POST, toDataStream(deployment)))); @@ -144,6 +144,11 @@ public abstract class ControllerHttpClient { "instance", id.instance().value()); } + private URI deploymentJobPath(ApplicationId id, ZoneId zone) { + return concatenated(instancePath(id), + "job", zone.environment().value() + "-" + zone.region().value()); + } + private URI defaultRegionPath() { return concatenated(endpoint, "zone", "v1", "environment", Environment.dev.value(), "default"); } @@ -228,15 +233,9 @@ public abstract class ControllerHttpClient { } private static DeploymentResult toDeploymentResult(HttpResponse<byte[]> response) { - try { - Inspector responseObject = toInspector(response); - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - new JsonFormat(false).encode(buffer, responseObject); // Pretty-print until done properly. - return new DeploymentResult(buffer.toString(UTF_8)); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } + Inspector rootObject = toInspector(response); + return new DeploymentResult(rootObject.field("message").asString(), + URI.create(rootObject.field("location").asString())); } private static Slime toSlime(byte[] data) { diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java index 63142ffbbf1..f13453b7416 100644 --- a/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java +++ b/hosted-api/src/main/java/ai/vespa/hosted/api/DeploymentResult.java @@ -1,6 +1,8 @@ package ai.vespa.hosted.api; +import java.net.URI; + /** * Contains information about the result of a {@link Deployment} against a {@link ControllerHttpClient}. * @@ -8,14 +10,20 @@ package ai.vespa.hosted.api; */ public class DeploymentResult { - private final String json; // TODO probably do this properly. + private final String message; + private final URI location; + + public DeploymentResult(String message, URI location) { + this.message = message; + this.location = location; + } - public DeploymentResult(String json) { - this.json = json; + public String message() { + return message; } - public String json() { - return json; + public URI location() { + return location; } } diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java index 9a2c65ef86e..15142a6c793 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java @@ -1,6 +1,7 @@ package ai.vespa.hosted.plugin; import ai.vespa.hosted.api.Deployment; +import ai.vespa.hosted.api.DeploymentResult; import com.yahoo.config.provision.zone.ZoneId; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -52,7 +53,9 @@ public class DeployMojo extends AbstractVespaMojo { ZoneId zone = environment == null || region == null ? controller.devZone() : ZoneId.from(environment, region); - System.out.println(controller.deploy(deployment, id, zone).json()); + DeploymentResult result = controller.deploy(deployment, id, zone); + System.out.println("Success: " + result.message()); + System.out.println("Follow the deployment at " + result.location()); } } |