From 8fb369df028d841dd07cbeea8b155b44db583701 Mon Sep 17 00:00:00 2001 From: Øyvind Grønnesby Date: Fri, 4 Oct 2019 16:42:34 +0200 Subject: Let plugin get the key as parameter --- .../java/ai/vespa/hosted/plugin/AbstractVespaMojo.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'vespa-maven-plugin/src') 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 bf8f6f83f53..080ac0b8173 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 @@ -34,7 +34,10 @@ public abstract class AbstractVespaMojo extends AbstractMojo { @Parameter(property = "instance") protected String instance; - @Parameter(property = "privateKeyFile", required = true) + @Parameter(property = "privateKey") + protected String privateKey; + + @Parameter(property = "privateKeyFile") protected String privateKeyFile; @Parameter(property = "certificateFile") @@ -67,8 +70,15 @@ public abstract class AbstractVespaMojo extends AbstractMojo { instance = firstNonBlank(instance, project.getProperties().getProperty("instance", "default")); id = ApplicationId.from(tenant, application, instance); + if (privateKey == null) { + if (privateKeyFile == null || privateKeyFile.isEmpty()) { + throw new IllegalArgumentException("Missing 'privateKey' or 'privateKeyFile' properties."); + } + privateKey = Paths.get(privateKeyFile); + } + controller = certificateFile == null - ? ControllerHttpClient.withSignatureKey(URI.create(endpoint), Paths.get(privateKeyFile), id) + ? ControllerHttpClient.withSignatureKey(URI.create(endpoint), privateKey, id) : ControllerHttpClient.withKeyAndCertificate(URI.create(endpoint), Paths.get(privateKeyFile), Paths.get(certificateFile)); } -- cgit v1.2.3