Add filtering support within Setting class
Now we have a nice Setting infra, we can define in Setting class if a setting should be filtered or not. So when we register a setting, setting filtering would be automatically done. Instead of writing: ```java Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER); settingsModule.registerSetting(AwsEc2Service.KEY_SETTING, false); settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.KEY_SETTING.getKey()); ``` We could simply write: ```java Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER, true); settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.KEY_SETTING.getKey()); ``` It also removes `settingsModule.registerSettingsFilterIfMissing` method. The plan would be to remove as well `settingsModule.registerSettingsFilter` method but it still used with wildcards. For example in Azure Repository plugin: ```java module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.account"); module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.key"); ``` Closes #16598.
This commit is contained in:
parent
b5aee2075f
commit
aabb124209
|
@ -71,22 +71,50 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
private final Function<String, T> parser;
|
||||
private final boolean dynamic;
|
||||
private final Scope scope;
|
||||
private final boolean filtered;
|
||||
|
||||
/**
|
||||
* Creates a new Setting instance, unfiltered
|
||||
* @param key the settings key for this setting.
|
||||
* @param defaultValue a default value function that returns the default values string representation.
|
||||
* @param parser a parser that parses the string rep into a complex datatype.
|
||||
* @param dynamic true if this setting can be dynamically updateable
|
||||
* @param scope the scope of this setting
|
||||
*/
|
||||
public Setting(String key, Function<Settings, String> defaultValue, Function<String, T> parser, boolean dynamic, Scope scope) {
|
||||
this(key, defaultValue, parser, dynamic, scope, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Setting instance
|
||||
* @param key the settings key for this setting.
|
||||
* @param defaultValue a default value function that returns the default values string representation.
|
||||
* @param parser a parser that parses the string rep into a complex datatype.
|
||||
* @param dynamic true iff this setting can be dynamically updateable
|
||||
* @param dynamic true if this setting can be dynamically updateable
|
||||
* @param scope the scope of this setting
|
||||
* @param filtered true if this setting should be filtered
|
||||
*/
|
||||
public Setting(String key, Function<Settings, String> defaultValue, Function<String, T> parser, boolean dynamic, Scope scope) {
|
||||
public Setting(String key, Function<Settings, String> defaultValue, Function<String, T> parser, boolean dynamic, Scope scope,
|
||||
boolean filtered) {
|
||||
assert parser.apply(defaultValue.apply(Settings.EMPTY)) != null || this.isGroupSetting(): "parser returned null";
|
||||
this.key = key;
|
||||
this.defaultValue = defaultValue;
|
||||
this.parser = parser;
|
||||
this.dynamic = dynamic;
|
||||
this.scope = scope;
|
||||
this.filtered = filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Setting instance, unfiltered
|
||||
* @param key the settings key for this setting.
|
||||
* @param fallBackSetting a setting to fall back to if the current setting is not set.
|
||||
* @param parser a parser that parses the string rep into a complex datatype.
|
||||
* @param dynamic true iff this setting can be dynamically updateable
|
||||
* @param scope the scope of this setting
|
||||
*/
|
||||
public Setting(String key, Setting<T> fallBackSetting, Function<String, T> parser, boolean dynamic, Scope scope) {
|
||||
this(key, fallBackSetting, parser, dynamic, scope, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,9 +124,10 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
* @param parser a parser that parses the string rep into a complex datatype.
|
||||
* @param dynamic true iff this setting can be dynamically updateable
|
||||
* @param scope the scope of this setting
|
||||
* @param filtered true if this setting should be filtered
|
||||
*/
|
||||
public Setting(String key, Setting<T> fallBackSetting, Function<String, T> parser, boolean dynamic, Scope scope) {
|
||||
this(key, fallBackSetting::getRaw, parser, dynamic, scope);
|
||||
public Setting(String key, Setting<T> fallBackSetting, Function<String, T> parser, boolean dynamic, Scope scope, boolean filtered) {
|
||||
this(key, fallBackSetting::getRaw, parser, dynamic, scope, filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +142,7 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> iff this setting is dynamically updateable, otherwise <code>false</code>
|
||||
* Returns <code>true</code> if this setting is dynamically updateable, otherwise <code>false</code>
|
||||
*/
|
||||
public final boolean isDynamic() {
|
||||
return dynamic;
|
||||
|
@ -126,6 +155,13 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this setting must be filtered, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean isFiltered() {
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> iff this setting is a group setting. Group settings represent a set of settings
|
||||
* rather than a single value. The key, see {@link #getKey()}, in contrast to non-group settings is a prefix like <tt>cluster.store.</tt>
|
||||
|
@ -331,7 +367,11 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
|
||||
|
||||
public Setting(String key, String defaultValue, Function<String, T> parser, boolean dynamic, Scope scope) {
|
||||
this(key, (s) -> defaultValue, parser, dynamic, scope);
|
||||
this(key, defaultValue, parser, dynamic, scope, false);
|
||||
}
|
||||
|
||||
public Setting(String key, String defaultValue, Function<String, T> parser, boolean dynamic, Scope scope, boolean filtered) {
|
||||
this(key, (s) -> defaultValue, parser, dynamic, scope, filtered);
|
||||
}
|
||||
|
||||
public static Setting<Float> floatSetting(String key, float defaultValue, boolean dynamic, Scope scope) {
|
||||
|
@ -357,11 +397,19 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
public static Setting<Long> longSetting(String key, long defaultValue, long minValue, boolean dynamic, Scope scope) {
|
||||
return new Setting<>(key, (s) -> Long.toString(defaultValue), (s) -> parseLong(s, minValue, key), dynamic, scope);
|
||||
return longSetting(key, defaultValue, minValue, dynamic, scope, false);
|
||||
}
|
||||
|
||||
public static Setting<Long> longSetting(String key, long defaultValue, long minValue, boolean dynamic, Scope scope, boolean filtered) {
|
||||
return new Setting<>(key, (s) -> Long.toString(defaultValue), (s) -> parseLong(s, minValue, key), dynamic, scope, filtered);
|
||||
}
|
||||
|
||||
public static Setting<String> simpleString(String key, boolean dynamic, Scope scope) {
|
||||
return new Setting<>(key, "", Function.identity(), dynamic, scope);
|
||||
return simpleString(key, dynamic, scope, false);
|
||||
}
|
||||
|
||||
public static Setting<String> simpleString(String key, boolean dynamic, Scope scope, boolean filtered) {
|
||||
return new Setting<>(key, s -> "", Function.identity(), dynamic, scope, filtered);
|
||||
}
|
||||
|
||||
public static int parseInt(String s, int minValue, String key) {
|
||||
|
@ -392,7 +440,11 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
public static Setting<Boolean> boolSetting(String key, boolean defaultValue, boolean dynamic, Scope scope) {
|
||||
return new Setting<>(key, (s) -> Boolean.toString(defaultValue), Booleans::parseBooleanExact, dynamic, scope);
|
||||
return boolSetting(key, defaultValue, dynamic, scope, false);
|
||||
}
|
||||
|
||||
public static Setting<Boolean> boolSetting(String key, boolean defaultValue, boolean dynamic, Scope scope, boolean filtered) {
|
||||
return new Setting<>(key, (s) -> Boolean.toString(defaultValue), Booleans::parseBooleanExact, dynamic, scope, filtered);
|
||||
}
|
||||
|
||||
public static Setting<Boolean> boolSetting(String key, Setting<Boolean> fallbackSetting, boolean dynamic, Scope scope) {
|
||||
|
|
|
@ -71,6 +71,11 @@ public class SettingsModule extends AbstractModule {
|
|||
* the setting during startup.
|
||||
*/
|
||||
public void registerSetting(Setting<?> setting) {
|
||||
if (setting.isFiltered()) {
|
||||
if (settingsFilterPattern.contains(setting.getKey()) == false) {
|
||||
registerSettingsFilter(setting.getKey());
|
||||
}
|
||||
}
|
||||
switch (setting.getScope()) {
|
||||
case CLUSTER:
|
||||
if (clusterSettings.containsKey(setting.getKey())) {
|
||||
|
@ -101,12 +106,6 @@ public class SettingsModule extends AbstractModule {
|
|||
settingsFilterPattern.add(filter);
|
||||
}
|
||||
|
||||
public void registerSettingsFilterIfMissing(String filter) {
|
||||
if (settingsFilterPattern.contains(filter) == false) {
|
||||
registerSettingsFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a setting has already been registered
|
||||
*/
|
||||
|
|
|
@ -50,6 +50,11 @@ public class SettingsFilteringIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public static class SettingsFilteringPlugin extends Plugin {
|
||||
public static final Setting<Boolean> SOME_NODE_SETTING =
|
||||
Setting.boolSetting("some.node.setting", false, false, Setting.Scope.CLUSTER, true);
|
||||
public static final Setting<Boolean> SOME_OTHER_NODE_SETTING =
|
||||
Setting.boolSetting("some.other.node.setting", false, false, Setting.Scope.CLUSTER);
|
||||
|
||||
/**
|
||||
* The name of the plugin.
|
||||
*/
|
||||
|
@ -72,10 +77,9 @@ public class SettingsFilteringIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSetting(SOME_NODE_SETTING);
|
||||
module.registerSetting(SOME_OTHER_NODE_SETTING);
|
||||
module.registerSetting(Setting.groupSetting("index.filter_test.", false, Setting.Scope.INDEX));
|
||||
module.registerSetting(Setting.boolSetting("some.node.setting", false, false, Setting.Scope.CLUSTER));
|
||||
module.registerSetting(Setting.boolSetting("some.other.node.setting", false, false, Setting.Scope.CLUSTER));
|
||||
module.registerSettingsFilter("some.node.setting");
|
||||
module.registerSettingsFilter("index.filter_test.foo");
|
||||
module.registerSettingsFilter("index.filter_test.bar*");
|
||||
}
|
||||
|
@ -104,8 +108,8 @@ public class SettingsFilteringIT extends ESIntegTestCase {
|
|||
for(NodeInfo info : nodeInfos.getNodes()) {
|
||||
Settings settings = info.getSettings();
|
||||
assertNotNull(settings);
|
||||
assertNull(settings.get("some.node.setting"));
|
||||
assertTrue(settings.getAsBoolean("some.other.node.setting", false));
|
||||
assertNull(settings.get(SettingsFilteringPlugin.SOME_NODE_SETTING.getKey()));
|
||||
assertTrue(settings.getAsBoolean(SettingsFilteringPlugin.SOME_OTHER_NODE_SETTING.getKey(), false));
|
||||
assertEquals(settings.get("node.name"), info.getNode().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,11 +132,10 @@ public class SettingsModuleTests extends ModuleTestCase {
|
|||
Settings settings = Settings.builder().put("foo.bar", "false").put("bar.foo", false).put("bar.baz", false).build();
|
||||
SettingsModule module = new SettingsModule(settings);
|
||||
module.registerSetting(Setting.boolSetting("foo.bar", true, false, Setting.Scope.CLUSTER));
|
||||
module.registerSetting(Setting.boolSetting("bar.foo", true, false, Setting.Scope.CLUSTER));
|
||||
module.registerSetting(Setting.boolSetting("bar.foo", true, false, Setting.Scope.CLUSTER, true));
|
||||
module.registerSetting(Setting.boolSetting("bar.baz", true, false, Setting.Scope.CLUSTER));
|
||||
|
||||
module.registerSettingsFilter("foo.*");
|
||||
module.registerSettingsFilterIfMissing("bar.foo");
|
||||
try {
|
||||
module.registerSettingsFilter("bar.foo");
|
||||
fail();
|
||||
|
|
|
@ -632,8 +632,8 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
|||
client().admin().cluster().preparePutRepository("test-repo")
|
||||
.setType("mock").setSettings(Settings.settingsBuilder()
|
||||
.put("location", randomRepoPath())
|
||||
.put("secret.mock.username", "notsecretusername")
|
||||
.put("secret.mock.password", "verysecretpassword")
|
||||
.put(MockRepository.Plugin.USERNAME_SETTING.getKey(), "notsecretusername")
|
||||
.put(MockRepository.Plugin.PASSWORD_SETTING.getKey(), "verysecretpassword")
|
||||
).get();
|
||||
|
||||
RestGetRepositoriesAction getRepoAction = internalCluster().getInstance(RestGetRepositoriesAction.class);
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.common.inject.AbstractModule;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.common.settings.SettingsModule;
|
||||
|
@ -63,6 +64,11 @@ public class MockRepository extends FsRepository {
|
|||
|
||||
public static class Plugin extends org.elasticsearch.plugins.Plugin {
|
||||
|
||||
public static final Setting<String> USERNAME_SETTING =
|
||||
Setting.simpleString("secret.mock.username", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> PASSWORD_SETTING =
|
||||
Setting.simpleString("secret.mock.password", false, Setting.Scope.CLUSTER, true);
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "mock-repository";
|
||||
|
@ -78,8 +84,8 @@ public class MockRepository extends FsRepository {
|
|||
}
|
||||
|
||||
public void onModule(SettingsModule module) {
|
||||
module.registerSettingsFilter("secret.mock.password");
|
||||
|
||||
module.registerSetting(USERNAME_SETTING);
|
||||
module.registerSetting(PASSWORD_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,26 +22,35 @@ package org.elasticsearch.cloud.azure.management;
|
|||
import com.microsoft.windowsazure.core.utils.KeyStoreType;
|
||||
import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDetailedResponse;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Scope;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.discovery.azure.AzureUnicastHostsProvider;
|
||||
|
||||
public interface AzureComputeService {
|
||||
|
||||
final class Management {
|
||||
public static final Setting<String> SUBSCRIPTION_ID_SETTING = Setting.simpleString("cloud.azure.management.subscription.id", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> SERVICE_NAME_SETTING = Setting.simpleString("cloud.azure.management.cloud.service.name", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> SUBSCRIPTION_ID_SETTING =
|
||||
Setting.simpleString("cloud.azure.management.subscription.id", false, Scope.CLUSTER, true);
|
||||
public static final Setting<String> SERVICE_NAME_SETTING =
|
||||
Setting.simpleString("cloud.azure.management.cloud.service.name", false, Scope.CLUSTER);
|
||||
|
||||
// Keystore settings
|
||||
public static final Setting<String> KEYSTORE_PATH_SETTING = Setting.simpleString("cloud.azure.management.keystore.path", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> KEYSTORE_PASSWORD_SETTING = Setting.simpleString("cloud.azure.management.keystore.password", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<KeyStoreType> KEYSTORE_TYPE_SETTING = new Setting<>("cloud.azure.management.keystore.type", KeyStoreType.pkcs12.name(), KeyStoreType::fromString, false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> KEYSTORE_PATH_SETTING =
|
||||
Setting.simpleString("cloud.azure.management.keystore.path", false, Scope.CLUSTER, true);
|
||||
public static final Setting<String> KEYSTORE_PASSWORD_SETTING =
|
||||
Setting.simpleString("cloud.azure.management.keystore.password", false, Scope.CLUSTER, true);
|
||||
public static final Setting<KeyStoreType> KEYSTORE_TYPE_SETTING =
|
||||
new Setting<>("cloud.azure.management.keystore.type", KeyStoreType.pkcs12.name(), KeyStoreType::fromString, false,
|
||||
Scope.CLUSTER, false);
|
||||
}
|
||||
|
||||
final class Discovery {
|
||||
public static final Setting<TimeValue> REFRESH_SETTING = Setting.positiveTimeSetting("discovery.azure.refresh_interval", TimeValue.timeValueSeconds(0), false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<TimeValue> REFRESH_SETTING =
|
||||
Setting.positiveTimeSetting("discovery.azure.refresh_interval", TimeValue.timeValueSeconds(0), false, Scope.CLUSTER);
|
||||
|
||||
public static final Setting<AzureUnicastHostsProvider.HostType> HOST_TYPE_SETTING = new Setting<>("discovery.azure.host.type",
|
||||
AzureUnicastHostsProvider.HostType.PRIVATE_IP.name(), AzureUnicastHostsProvider.HostType::fromString, false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<AzureUnicastHostsProvider.HostType> HOST_TYPE_SETTING =
|
||||
new Setting<>("discovery.azure.host.type", AzureUnicastHostsProvider.HostType.PRIVATE_IP.name(),
|
||||
AzureUnicastHostsProvider.HostType::fromString, false, Scope.CLUSTER);
|
||||
|
||||
public static final String ENDPOINT_NAME = "discovery.azure.endpoint.name";
|
||||
public static final String DEPLOYMENT_NAME = "discovery.azure.deployment.name";
|
||||
|
|
|
@ -74,10 +74,5 @@ public class AzureDiscoveryPlugin extends Plugin {
|
|||
settingsModule.registerSetting(AzureComputeService.Management.SUBSCRIPTION_ID_SETTING);
|
||||
settingsModule.registerSetting(AzureComputeService.Management.SERVICE_NAME_SETTING);
|
||||
settingsModule.registerSetting(AzureComputeService.Discovery.HOST_TYPE_SETTING);
|
||||
// Cloud management API settings we need to hide
|
||||
settingsModule.registerSettingsFilter(AzureComputeService.Management.KEYSTORE_PATH_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilter(AzureComputeService.Management.KEYSTORE_PASSWORD_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilter(AzureComputeService.Management.KEYSTORE_TYPE_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilter(AzureComputeService.Management.SUBSCRIPTION_ID_SETTING.getKey());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,11 +40,11 @@ public interface AwsEc2Service {
|
|||
/**
|
||||
* cloud.aws.access_key: AWS Access key. Shared with repository-s3 plugin
|
||||
*/
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.secret_key: AWS Secret key. Shared with repository-s3 plugin
|
||||
*/
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("cloud.aws.secret_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("cloud.aws.secret_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.protocol: Protocol for AWS API: http or https. Defaults to https. Shared with repository-s3 plugin
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ public interface AwsEc2Service {
|
|||
/**
|
||||
* cloud.aws.proxy.password: In case of proxy with auth, define the password. Shared with repository-s3 plugin
|
||||
*/
|
||||
Setting<String> PROXY_PASSWORD_SETTING = Setting.simpleString("cloud.aws.proxy.password", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> PROXY_PASSWORD_SETTING = Setting.simpleString("cloud.aws.proxy.password", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.signer: If you are using an old AWS API version, you can define a Signer. Shared with repository-s3 plugin
|
||||
*/
|
||||
|
@ -84,13 +84,13 @@ public interface AwsEc2Service {
|
|||
* @see AwsEc2Service#KEY_SETTING
|
||||
*/
|
||||
Setting<String> KEY_SETTING = new Setting<>("cloud.aws.ec2.access_key", AwsEc2Service.KEY_SETTING, Function.identity(), false,
|
||||
Setting.Scope.CLUSTER);
|
||||
Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.ec2.secret_key: AWS Secret key specific for EC2 API calls. Defaults to cloud.aws.secret_key.
|
||||
* @see AwsEc2Service#SECRET_SETTING
|
||||
*/
|
||||
Setting<String> SECRET_SETTING = new Setting<>("cloud.aws.ec2.secret_key", AwsEc2Service.SECRET_SETTING, Function.identity(), false,
|
||||
Setting.Scope.CLUSTER);
|
||||
Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.ec2.protocol: Protocol for AWS API specific for EC2 API calls: http or https. Defaults to cloud.aws.protocol.
|
||||
* @see AwsEc2Service#PROTOCOL_SETTING
|
||||
|
@ -122,7 +122,7 @@ public interface AwsEc2Service {
|
|||
* @see AwsEc2Service#PROXY_PASSWORD_SETTING
|
||||
*/
|
||||
Setting<String> PROXY_PASSWORD_SETTING = new Setting<>("cloud.aws.ec2.proxy.password", AwsEc2Service.PROXY_PASSWORD_SETTING,
|
||||
Function.identity(), false, Setting.Scope.CLUSTER);
|
||||
Function.identity(), false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.ec2.signer: If you are using an old AWS API version, you can define a Signer. Specific for EC2 API calls.
|
||||
* Defaults to cloud.aws.signer.
|
||||
|
|
|
@ -134,14 +134,6 @@ public class Ec2DiscoveryPlugin extends Plugin {
|
|||
settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.GROUPS_SETTING);
|
||||
settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.AVAILABILITY_ZONES_SETTING);
|
||||
settingsModule.registerSetting(AwsEc2Service.DISCOVERY_EC2.NODE_CACHE_TIME_SETTING);
|
||||
|
||||
// Filter global settings
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.KEY_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.SECRET_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.PROXY_PASSWORD_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.CLOUD_EC2.KEY_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.CLOUD_EC2.SECRET_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,13 +41,20 @@ public interface AzureStorageService {
|
|||
|
||||
final class Storage {
|
||||
public static final String PREFIX = "cloud.azure.storage.";
|
||||
public static final Setting<TimeValue> TIMEOUT_SETTING = Setting.timeSetting("cloud.azure.storage.timeout", TimeValue.timeValueMinutes(5), false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> ACCOUNT_SETTING = Setting.simpleString("repositories.azure.account", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> CONTAINER_SETTING = Setting.simpleString("repositories.azure.container", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> BASE_PATH_SETTING = Setting.simpleString("repositories.azure.base_path", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> LOCATION_MODE_SETTING = Setting.simpleString("repositories.azure.location_mode", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<ByteSizeValue> CHUNK_SIZE_SETTING = Setting.byteSizeSetting("repositories.azure.chunk_size", new ByteSizeValue(-1), false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<Boolean> COMPRESS_SETTING = Setting.boolSetting("repositories.azure.compress", false, false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<TimeValue> TIMEOUT_SETTING =
|
||||
Setting.timeSetting("cloud.azure.storage.timeout", TimeValue.timeValueMinutes(5), false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> ACCOUNT_SETTING =
|
||||
Setting.simpleString("repositories.azure.account", false, Setting.Scope.CLUSTER, true);
|
||||
public static final Setting<String> CONTAINER_SETTING =
|
||||
Setting.simpleString("repositories.azure.container", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> BASE_PATH_SETTING =
|
||||
Setting.simpleString("repositories.azure.base_path", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<String> LOCATION_MODE_SETTING =
|
||||
Setting.simpleString("repositories.azure.location_mode", false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<ByteSizeValue> CHUNK_SIZE_SETTING =
|
||||
Setting.byteSizeSetting("repositories.azure.chunk_size", new ByteSizeValue(-1), false, Setting.Scope.CLUSTER);
|
||||
public static final Setting<Boolean> COMPRESS_SETTING =
|
||||
Setting.boolSetting("repositories.azure.compress", false, false, Setting.Scope.CLUSTER);
|
||||
}
|
||||
|
||||
boolean doesContainerExist(String account, LocationMode mode, String container);
|
||||
|
@ -62,13 +69,17 @@ public interface AzureStorageService {
|
|||
|
||||
void deleteBlob(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException;
|
||||
|
||||
InputStream getInputStream(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException;
|
||||
InputStream getInputStream(String account, LocationMode mode, String container, String blob)
|
||||
throws URISyntaxException, StorageException;
|
||||
|
||||
OutputStream getOutputStream(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException;
|
||||
OutputStream getOutputStream(String account, LocationMode mode, String container, String blob)
|
||||
throws URISyntaxException, StorageException;
|
||||
|
||||
Map<String,BlobMetaData> listBlobsByPrefix(String account, LocationMode mode, String container, String keyPath, String prefix) throws URISyntaxException, StorageException;
|
||||
Map<String,BlobMetaData> listBlobsByPrefix(String account, LocationMode mode, String container, String keyPath, String prefix)
|
||||
throws URISyntaxException, StorageException;
|
||||
|
||||
void moveBlob(String account, LocationMode mode, String container, String sourceBlob, String targetBlob) throws URISyntaxException, StorageException;
|
||||
void moveBlob(String account, LocationMode mode, String container, String sourceBlob, String targetBlob)
|
||||
throws URISyntaxException, StorageException;
|
||||
|
||||
AzureStorageService start();
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public class AzureRepositoryPlugin extends Plugin {
|
|||
module.registerSetting(AzureStorageService.Storage.BASE_PATH_SETTING);
|
||||
module.registerSetting(AzureStorageService.Storage.CHUNK_SIZE_SETTING);
|
||||
module.registerSetting(AzureStorageService.Storage.LOCATION_MODE_SETTING);
|
||||
// Cloud storage API settings needed to be hidden
|
||||
|
||||
// Cloud storage API settings using a pattern needed to be hidden
|
||||
module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.account");
|
||||
module.registerSettingsFilter(AzureStorageService.Storage.PREFIX + "*.key");
|
||||
module.registerSettingsFilter(AzureStorageService.Storage.ACCOUNT_SETTING.getKey());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,11 +38,11 @@ public interface AwsS3Service extends LifecycleComponent<AwsS3Service> {
|
|||
/**
|
||||
* cloud.aws.access_key: AWS Access key. Shared with discovery-ec2 plugin
|
||||
*/
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("cloud.aws.access_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.secret_key: AWS Secret key. Shared with discovery-ec2 plugin
|
||||
*/
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("cloud.aws.secret_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("cloud.aws.secret_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.protocol: Protocol for AWS API: http or https. Defaults to https. Shared with discovery-ec2 plugin
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ public interface AwsS3Service extends LifecycleComponent<AwsS3Service> {
|
|||
/**
|
||||
* cloud.aws.proxy.password: In case of proxy with auth, define the password. Shared with discovery-ec2 plugin
|
||||
*/
|
||||
Setting<String> PROXY_PASSWORD_SETTING = Setting.simpleString("cloud.aws.proxy.password", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> PROXY_PASSWORD_SETTING = Setting.simpleString("cloud.aws.proxy.password", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.signer: If you are using an old AWS API version, you can define a Signer. Shared with discovery-ec2 plugin
|
||||
*/
|
||||
|
@ -82,13 +82,13 @@ public interface AwsS3Service extends LifecycleComponent<AwsS3Service> {
|
|||
* @see AwsS3Service#KEY_SETTING
|
||||
*/
|
||||
Setting<String> KEY_SETTING =
|
||||
new Setting<>("cloud.aws.s3.access_key", AwsS3Service.KEY_SETTING, Function.identity(), false, Setting.Scope.CLUSTER);
|
||||
new Setting<>("cloud.aws.s3.access_key", AwsS3Service.KEY_SETTING, Function.identity(), false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.s3.secret_key: AWS Secret key specific for S3 API calls. Defaults to cloud.aws.secret_key.
|
||||
* @see AwsS3Service#SECRET_SETTING
|
||||
*/
|
||||
Setting<String> SECRET_SETTING =
|
||||
new Setting<>("cloud.aws.s3.secret_key", AwsS3Service.SECRET_SETTING, Function.identity(), false, Setting.Scope.CLUSTER);
|
||||
new Setting<>("cloud.aws.s3.secret_key", AwsS3Service.SECRET_SETTING, Function.identity(), false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.s3.protocol: Protocol for AWS API specific for S3 API calls: http or https. Defaults to cloud.aws.protocol.
|
||||
* @see AwsS3Service#PROTOCOL_SETTING
|
||||
|
@ -124,7 +124,7 @@ public interface AwsS3Service extends LifecycleComponent<AwsS3Service> {
|
|||
*/
|
||||
Setting<String> PROXY_PASSWORD_SETTING =
|
||||
new Setting<>("cloud.aws.s3.proxy.password", AwsS3Service.PROXY_PASSWORD_SETTING, Function.identity(), false,
|
||||
Setting.Scope.CLUSTER);
|
||||
Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* cloud.aws.s3.signer: If you are using an old AWS API version, you can define a Signer. Specific for S3 API calls.
|
||||
* Defaults to cloud.aws.signer.
|
||||
|
|
|
@ -144,16 +144,6 @@ public class S3RepositoryPlugin extends Plugin {
|
|||
settingsModule.registerSetting(S3Repository.Repository.STORAGE_CLASS_SETTING);
|
||||
settingsModule.registerSetting(S3Repository.Repository.CANNED_ACL_SETTING);
|
||||
settingsModule.registerSetting(S3Repository.Repository.BASE_PATH_SETTING);
|
||||
|
||||
// Filter global settings
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.KEY_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.SECRET_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.PROXY_PASSWORD_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.CLOUD_S3.KEY_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.CLOUD_S3.SECRET_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilterIfMissing(AwsS3Service.CLOUD_S3.PROXY_PASSWORD_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilter(S3Repository.Repository.KEY_SETTING.getKey());
|
||||
settingsModule.registerSettingsFilter(S3Repository.Repository.SECRET_SETTING.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,12 +140,12 @@ public class S3Repository extends BlobStoreRepository {
|
|||
* access_key
|
||||
* @see Repositories#KEY_SETTING
|
||||
*/
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("access_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> KEY_SETTING = Setting.simpleString("access_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* secret_key
|
||||
* @see Repositories#SECRET_SETTING
|
||||
*/
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("secret_key", false, Setting.Scope.CLUSTER);
|
||||
Setting<String> SECRET_SETTING = Setting.simpleString("secret_key", false, Setting.Scope.CLUSTER, true);
|
||||
/**
|
||||
* bucket
|
||||
* @see Repositories#BUCKET_SETTING
|
||||
|
|
Loading…
Reference in New Issue