def configure_keystore()

in plugins/v1/repository_s3/plugin.py [0:0]


def configure_keystore(config_names, variables, **kwargs):
    logger = logging.getLogger(LOGGER_NAME)
    # s3_session_token is optional
    keystore_params = ["s3_access_key", "s3_secret_key", "s3_session_token"]
    client_name = variables.get("s3_client_name")

    # skip keystore configuration entirely if any of the mandatory params is missing
    if not (client_name and variables.get(keystore_params[0]) and variables.get(keystore_params[1])):
        logger.warning("Skipping keystore configuration for repository-s3 as mandatory plugin-params [%s,%s,%s] were not supplied",
                       "s3_client_name",
                       keystore_params[0],
                       keystore_params[1])
        return False

    keystore_binary_filename = "elasticsearch-keystore"
    install_root = variables["install_root_path"]
    keystore_binary = resolve_binary(install_root, keystore_binary_filename)
    env = kwargs.get("env")

    if not os.path.isfile(resolve_keystore_config(install_root)):
        create_keystore(install_root, keystore_binary, env)

    for property_name in keystore_params:
        # the actual Elasticsearch secure settings for the s3 plugin don't contain the s3_ prefix
        es_property_name = property_name.replace("s3_", "")
        property_value = variables.get(property_name)
        # skip optional properties like session_token
        if not property_value:
            continue

        add_property_to_keystore(keystore_binary, client_name, es_property_name, property_value, env)

    # Success
    return True