diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-06 13:59:24 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2019-05-06 16:37:07 +0200 |
commit | 1b7c363a7eb452214ec76bbdac1f9f25889f14e3 (patch) | |
tree | e7e50d2048539a57ad7491640dbae246b38a09f2 /vespa-maven-plugin | |
parent | cf9751079b459f463ddacfd895ec778e27cc5b68 (diff) |
Support key/certificate based authentication in ControllerHttpClient
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r-- | vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java index 88302c8cec6..f3360d975c6 100644 --- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java +++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/SubmitMojo.java @@ -64,20 +64,16 @@ public class SubmitMojo extends AbstractMojo { @Override public void execute() { - try { - setup(); - ControllerHttpClient controller = new ControllerHttpClient(URI.create(endpointUri), - Files.readString(Paths.get(privateKeyFile), UTF_8), - ApplicationId.from(tenant, application, instance)); - - Submission submission = new Submission(repository, branch, commit, authorEmail, - Paths.get(applicationZip), Paths.get(applicationTestZip)); - - System.out.println(controller.submit(submission)); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } + setup(); + ApplicationId id = ApplicationId.from(tenant, application, instance); + ControllerHttpClient controller = ControllerHttpClient.withSignatureKey(URI.create(endpointUri), + Paths.get(privateKeyFile), + id); + + Submission submission = new Submission(repository, branch, commit, authorEmail, + Paths.get(applicationZip), Paths.get(applicationTestZip)); + + System.out.println(controller.submit(submission, id.tenant(), id.application())); } private void setup() { @@ -92,11 +88,12 @@ public class SubmitMojo extends AbstractMojo { return project.getBasedir().toPath().resolve(Path.of(first, rest)).toString(); } - /** Returns the first of the given strings which is non-null and non-blank. */ + /** Returns the first of the given strings which is non-null and non-blank, or throws IllegalArgumentException. */ private static String firstNonBlank(String... values) { for (String value : values) if (value != null && ! value.isBlank()) return value; + throw new IllegalArgumentException("No valid value given"); } |