diff options
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java | 6 | ||||
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java | 25 |
2 files changed, 25 insertions, 6 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java index b5822ff825e..fd3409dcfcb 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java @@ -21,7 +21,7 @@ public abstract class AbstractVespaMojo extends AbstractMojo { protected MavenProject project; @Parameter(property = "endpoint", defaultValue = "https://api.vespa.corp.yahoo.com:4443") // TODO jvenstad: Change default - protected String endpointUri; + protected String endpoint; @Parameter(property = "tenant") protected String tenant; @@ -58,8 +58,8 @@ public abstract class AbstractVespaMojo extends AbstractMojo { id = ApplicationId.from(tenant, application, instance); controller = certificateFile == null - ? ControllerHttpClient.withSignatureKey(URI.create(endpointUri), Paths.get(privateKeyFile), id) - : ControllerHttpClient.withKeyAndCertificate(URI.create(endpointUri), Paths.get(privateKeyFile), Paths.get(certificateFile)); + ? ControllerHttpClient.withSignatureKey(URI.create(endpoint), Paths.get(privateKeyFile), id) + : ControllerHttpClient.withKeyAndCertificate(URI.create(endpoint), Paths.get(privateKeyFile), Paths.get(certificateFile)); } protected String projectPathOf(String first, String... rest) { 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 15142a6c793..503dcdea629 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,12 +1,15 @@ package ai.vespa.hosted.plugin; import ai.vespa.hosted.api.Deployment; +import ai.vespa.hosted.api.DeploymentLog; 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; import java.nio.file.Paths; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; /** * Deploys a Vespa application package to the hosted Vespa API. @@ -43,19 +46,35 @@ public class DeployMojo extends AbstractVespaMojo { @Parameter(property = "build") private Long build; + @Parameter(property = "follow", defaultValue = "true") + private boolean follow; + @Override protected void doExecute() { Deployment deployment = build == null ? Deployment.ofPackage(Paths.get(firstNonBlank(applicationZip, projectPathOf("target", "application.zip")))) : Deployment.ofReference(repository, branch, commit, build); - if ("true".equalsIgnoreCase(ignoreValidationErrors)) deployment = deployment.ignoringValidationErrors(); + if ("true".equalsIgnoreCase(ignoreValidationErrors)) deployment = deployment.ignoringValidationErrors(); // TODO unused, GC or fix. if (vespaVersion != null) deployment = deployment.atVersion(vespaVersion); ZoneId zone = environment == null || region == null ? controller.devZone() : ZoneId.from(environment, region); DeploymentResult result = controller.deploy(deployment, id, zone); - System.out.println("Success: " + result.message()); - System.out.println("Follow the deployment at " + result.location()); + System.out.println(result.message()); + + if (follow) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC); + DeploymentLog log = controller.deploymentLog(id, zone, result.run()); + do { + for (DeploymentLog.Entry entry : log.entries()) + System.out.printf("[%10s%10s] %s\n", + entry.level().toUpperCase(), + formatter.format(entry.at()), + entry.message()); + log = controller.deploymentLog(id, zone, result.run(), log.last()); + } + while (log.isActive()); + } } } |