Skip to content

Commit 3a24fe9

Browse files
authored
Move keystore-cli to its own tools project (#40787) (#54294)
This commit moves the keystore cli into its own project, so that the test dependencies can be isolated from the rest of server.
1 parent 0fa1060 commit 3a24fe9

27 files changed

+122
-71
lines changed

distribution/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
267267
from { project(':distribution:tools:plugin-cli').jar }
268268
from { project(':distribution:tools:plugin-cli').configurations.runtime }
269269
}
270+
into('tools/keystore-cli') {
271+
from { project(':distribution:tools:keystore-cli').jar }
272+
}
270273
if (oss == false) {
271274
into('tools/security-cli') {
272275
from { project(':x-pack:plugin:security:cli').jar }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

33
ES_MAIN_CLASS=org.elasticsearch.common.settings.KeyStoreCli \
4+
ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/keystore-cli \
45
"`dirname "$0"`"/elasticsearch-cli \
56
"$@"

distribution/src/bin/elasticsearch-keystore.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ setlocal enabledelayedexpansion
44
setlocal enableextensions
55

66
set ES_MAIN_CLASS=org.elasticsearch.common.settings.KeyStoreCli
7+
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/keystore-cli
78
call "%~dp0elasticsearch-cli.bat" ^
89
%%* ^
910
|| goto exit
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
apply plugin: 'elasticsearch.build'
21+
22+
dependencies {
23+
compileOnly project(":server")
24+
compileOnly project(":libs:elasticsearch-cli")
25+
testCompile project(":test:framework")
26+
testCompile 'com.google.jimfs:jimfs:1.1'
27+
testCompile 'com.google.guava:guava:18.0'
28+
}

server/src/main/java/org/elasticsearch/common/settings/AddFileKeyStoreCommand.java renamed to distribution/tools/keystore-cli/src/main/java/org/elasticsearch/common/settings/AddFileKeyStoreCommand.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ class AddFileKeyStoreCommand extends BaseKeyStoreCommand {
4242

4343
AddFileKeyStoreCommand() {
4444
super("Add a file setting to the keystore", false);
45-
this.forceOption = parser.acceptsAll(Arrays.asList("f", "force"),
46-
"Overwrite existing setting without prompting, creating keystore if necessary");
45+
this.forceOption = parser.acceptsAll(
46+
Arrays.asList("f", "force"),
47+
"Overwrite existing setting without prompting, creating keystore if necessary"
48+
);
4749
// jopt simple has issue with multiple non options, so we just get one set of them here
4850
// and convert to File when necessary
4951
// see https://github.com/jopt-simple/jopt-simple/issues/103

server/src/main/java/org/elasticsearch/common/settings/AddStringKeyStoreCommand.java renamed to distribution/tools/keystore-cli/src/main/java/org/elasticsearch/common/settings/AddStringKeyStoreCommand.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ class AddStringKeyStoreCommand extends BaseKeyStoreCommand {
4848
AddStringKeyStoreCommand() {
4949
super("Add a string settings to the keystore", false);
5050
this.stdinOption = parser.acceptsAll(Arrays.asList("x", "stdin"), "Read setting values from stdin");
51-
this.forceOption = parser.acceptsAll(Arrays.asList("f", "force"),
52-
"Overwrite existing setting without prompting, creating keystore if necessary");
51+
this.forceOption = parser.acceptsAll(
52+
Arrays.asList("f", "force"),
53+
"Overwrite existing setting without prompting, creating keystore if necessary"
54+
);
5355
this.arguments = parser.nonOptions("setting names");
5456
}
5557

server/src/main/java/org/elasticsearch/common/settings/CreateKeyStoreCommand.java renamed to distribution/tools/keystore-cli/src/main/java/org/elasticsearch/common/settings/CreateKeyStoreCommand.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class CreateKeyStoreCommand extends KeyStoreAwareCommand {
4545

4646
@Override
4747
protected void execute(Terminal terminal, OptionSet options, Environment env) throws Exception {
48-
try (SecureString password = options.has(passwordOption) ?
49-
readPassword(terminal, true) : new SecureString(new char[0])) {
48+
try (SecureString password = options.has(passwordOption) ? readPassword(terminal, true) : new SecureString(new char[0])) {
5049
Path keystoreFile = KeyStoreWrapper.keystorePath(env.configFile());
5150
if (Files.exists(keystoreFile)) {
5251
if (terminal.promptYesNo("An elasticsearch keystore already exists. Overwrite?", false) == false) {

server/src/main/java/org/elasticsearch/common/settings/ListKeyStoreCommand.java renamed to distribution/tools/keystore-cli/src/main/java/org/elasticsearch/common/settings/ListKeyStoreCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.common.settings;
2121

22-
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.List;

0 commit comments

Comments
 (0)