Allow keystore add to handle multiple settings (#54229)

Today the keystore add command can only handle adding a single
setting/value pair in a single invocation. This incurs the startup costs
of the JVM many times, which in some environments can be expensive. This
commit teaches the add keystore command to accept adding multiple
settings in a single invocation.
This commit is contained in:
Jason Tedor 2020-03-25 22:19:45 -04:00 committed by GitHub
parent f9431001eb
commit e8e8b163cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 110 additions and 54 deletions

View file

@ -11,7 +11,7 @@ in the {es} keystore.
[source,shell]
--------------------------------------------------
bin/elasticsearch-keystore
([add <setting>] [-f] [--stdin] |
([add <settings>] [-f] [--stdin] |
[add-file <setting> <path>] | [create] [-p] |
[list] | [passwd] | [remove <setting>] | [upgrade])
[-h, --help] ([-s, --silent] | [-v, --verbose])
@ -40,12 +40,13 @@ keystore, see the setting reference.
[[elasticsearch-keystore-parameters]]
=== Parameters
`add <setting>`:: Adds settings to the keystore. By default, you are prompted
for the value of the setting. If the keystore is password protected, you are
also prompted to enter the password. If the setting already exists in the
keystore, you must confirm that you want to overwrite the current value. If the
keystore does not exist, you must confirm that you want to create a keystore. To
avoid these two confirmation prompts, use the `-f` parameter.
`add <settings>`:: Adds settings to the keystore. Multiple setting names can be
specified as arguments to the `add` command. By default, you are prompted for
the values of the settings. If the keystore is password protected, you are also
prompted to enter the password. If a setting already exists in the keystore, you
must confirm that you want to overwrite the current value. If the keystore does
not exist, you must confirm that you want to create a keystore. To avoid these
two confirmation prompts, use the `-f` parameter.
`add-file <setting> <path>`:: Adds a file to the keystore.
@ -70,12 +71,14 @@ protected, you are prompted to enter the current password and the new one. You
can optionally use an empty string to remove the password. If the keystore is
not password protected, you can use this command to set a password.
`remove <setting>`:: Removes a setting from the keystore.
`remove <settings>`:: Removes settings from the keystore. Multiple setting
names can be specified as arguments to the `add` command.
`-s, --silent`:: Shows minimal output.
`--stdin`:: When used with the `add` parameter, you can pass the setting value
through standard input (stdin). See <<add-string-to-keystore>>.
`--stdin`:: When used with the `add` parameter, you can pass the settings values
through standard input (stdin). Separate multiple values with carriage returns
or newlines. See <<add-string-to-keystore>>.
`upgrade`:: Upgrades the internal format of the keystore.
@ -143,13 +146,28 @@ bin/elasticsearch-keystore add the.setting.name.to.set
You are prompted to enter the value of the setting. If the {es} keystore is
password protected, you are also prompted to enter the password.
To pass the setting value through standard input (stdin), use the `--stdin` flag:
You can also add multiple settings with the `add` command:
[source,sh]
----------------------------------------------------------------
bin/elasticsearch-keystore add \
the.setting.name.to.set \
the.other.setting.name.to.set
----------------------------------------------------------------
You are prompted to enter the values of the settings. If the {es} keystore is
password protected, you are also prompted to enter the password.
To pass the settings values through standard input (stdin), use the `--stdin`
flag:
[source,sh]
----------------------------------------------------------------
cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin the.setting.name.to.set
----------------------------------------------------------------
Values for multiple settings must be separated by carriage returns or newlines.
[discrete]
[[add-file-to-keystore]]
==== Add files to the keystore