Opt-in logstash plugin to formatting (#53413)

This change opts-in the logstash plugin for enforced formatting.

Backport of #53370
This commit is contained in:
Jay Modi 2020-03-11 09:58:37 -06:00 committed by GitHub
parent 1fd56698fa
commit 9a21a8abf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 17 deletions

View File

@ -115,7 +115,8 @@ subprojects {
':distribution:tools:plugin-cli',
':qa:os',
':x-pack:plugin:autoscaling',
':x-pack:plugin:enrich'
':x-pack:plugin:enrich',
':x-pack:plugin:logstash'
]
if (projectPathsToFormat.contains(project.path)) {

View File

@ -45,27 +45,31 @@ public class Logstash extends Plugin implements SystemIndexPlugin {
}
boolean isEnabled() {
return enabled;
return enabled;
}
boolean isTransportClient() {
return transportClientMode;
return transportClientMode;
}
public Collection<Module> createGuiceModules() {
List<Module> modules = new ArrayList<>();
modules.add(b -> {
XPackPlugin.bindFeatureSet(b, LogstashFeatureSet.class);
});
modules.add(b -> { XPackPlugin.bindFeatureSet(b, LogstashFeatureSet.class); });
return modules;
}
public UnaryOperator<Map<String, IndexTemplateMetaData>> getIndexTemplateMetaDataUpgrader() {
return templates -> {
templates.keySet().removeIf(OLD_LOGSTASH_INDEX_NAME::equals);
TemplateUtils.loadTemplateIntoMap("/" + LOGSTASH_TEMPLATE_FILE_NAME + ".json", templates, LOGSTASH_INDEX_TEMPLATE_NAME,
Version.CURRENT.toString(), TEMPLATE_VERSION_VARIABLE, LogManager.getLogger(Logstash.class));
//internal representation of typeless templates requires the default "_doc" type, which is also required for internal templates
TemplateUtils.loadTemplateIntoMap(
"/" + LOGSTASH_TEMPLATE_FILE_NAME + ".json",
templates,
LOGSTASH_INDEX_TEMPLATE_NAME,
Version.CURRENT.toString(),
TEMPLATE_VERSION_VARIABLE,
LogManager.getLogger(Logstash.class)
);
// internal representation of typeless templates requires the default "_doc" type, which is also required for internal templates
assert templates.get(LOGSTASH_INDEX_TEMPLATE_NAME).mappings().get(MapperService.SINGLE_MAPPING_NAME) != null;
return templates;
};
@ -73,7 +77,8 @@ public class Logstash extends Plugin implements SystemIndexPlugin {
@Override
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
return Collections.singletonList(new SystemIndexDescriptor(LOGSTASH_CONCRETE_INDEX_NAME,
"Contains data for Logstash Central Management"));
return Collections.singletonList(
new SystemIndexDescriptor(LOGSTASH_CONCRETE_INDEX_NAME, "Contains data for Logstash Central Management")
);
}
}

View File

@ -15,7 +15,6 @@ import org.elasticsearch.xpack.core.XPackField;
import org.elasticsearch.xpack.core.XPackSettings;
import org.elasticsearch.xpack.core.logstash.LogstashFeatureSetUsage;
import java.util.Map;
public class LogstashFeatureSet implements XPackFeatureSet {
@ -46,7 +45,7 @@ public class LogstashFeatureSet implements XPackFeatureSet {
@Override
public Map<String, Object> nativeCodeInfo() {
return null;
return null;
}
@Override

View File

@ -21,10 +21,7 @@ public class LogstashFeatureSetTests extends ESTestCase {
public void testEnabledSetting() throws Exception {
boolean enabled = randomBoolean();
Settings settings = Settings.builder()
.put("path.home", createTempDir())
.put("xpack.logstash.enabled", enabled)
.build();
Settings settings = Settings.builder().put("path.home", createTempDir()).put("xpack.logstash.enabled", enabled).build();
LogstashFeatureSet featureSet = new LogstashFeatureSet(settings, null);
assertThat(featureSet.enabled(), is(enabled));