Skip to content

Commit 75ca3f8

Browse files
committed
[WIP] Introduce StringSetting constructor that accepts 2 arguments
1 parent b8f24c5 commit 75ca3f8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

logstash-core/lib/logstash/environment.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module Environment
3535

3636
[
3737
Setting::Boolean.new("allow_superuser", false),
38-
Setting::String.new("node.name", Socket.gethostname),
38+
Setting::StringSetting.new("node.name", Socket.gethostname),
3939
Setting::NullableString.new("path.config", nil, false),
4040
Setting::WritableDirectory.new("path.data", ::File.join(LogStash::Environment::LOGSTASH_HOME, "data")),
4141
Setting::NullableString.new("config.string", nil, false),
@@ -52,7 +52,7 @@ module Environment
5252
Setting::Boolean.new("config.support_escapes", false),
5353
Setting::StringSetting.new("config.field_reference.escape_style", "none", true, %w(none percent ampersand)),
5454
Setting::Boolean.new("metric.collect", true),
55-
Setting::String.new("pipeline.id", "main"),
55+
Setting::StringSetting.new("pipeline.id", "main"),
5656
Setting::Boolean.new("pipeline.system", false),
5757
Setting::PositiveInteger.new("pipeline.workers", LogStash::Config::CpuCoreStrategy.maximum),
5858
Setting::PositiveInteger.new("pipeline.batch.size", 125),
@@ -73,9 +73,9 @@ module Environment
7373
Setting::StringSetting.new("log.format", "plain", true, ["json", "plain"]),
7474
Setting::Boolean.new("log.format.json.fix_duplicate_message_fields", true),
7575
Setting::Boolean.new("api.enabled", true),
76-
Setting::String.new("api.http.host", "127.0.0.1"),
76+
Setting::StringSetting.new("api.http.host", "127.0.0.1"),
7777
Setting::PortRange.new("api.http.port", 9600..9700),
78-
Setting::String.new("api.environment", "production"),
78+
Setting::StringSetting.new("api.environment", "production"),
7979
Setting::StringSetting.new("api.auth.type", "none", true, %w(none basic)),
8080
Setting::String.new("api.auth.basic.username", nil, false).nullable,
8181
Setting::Password.new("api.auth.basic.password", nil, false).nullable,
@@ -107,7 +107,7 @@ module Environment
107107
Setting::TimeValue.new("slowlog.threshold.info", "-1"),
108108
Setting::TimeValue.new("slowlog.threshold.debug", "-1"),
109109
Setting::TimeValue.new("slowlog.threshold.trace", "-1"),
110-
Setting::String.new("keystore.classname", "org.logstash.secret.store.backend.JavaKeyStore"),
110+
Setting::StringSetting.new("keystore.classname", "org.logstash.secret.store.backend.JavaKeyStore"),
111111
Setting::String.new("keystore.file", ::File.join(::File.join(LogStash::Environment::LOGSTASH_HOME, "config"), "logstash.keystore"), false), # will be populated on
112112
Setting::NullableString.new("monitoring.cluster_uuid"),
113113
Setting::StringSetting.new("pipeline.buffer.type", "direct", true, ["direct", "heap"])

logstash-core/src/main/java/org/logstash/settings/SettingWithDeprecatedAlias.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void format(List<String> output) {
9999
@Override
100100
public void validateValue() {
101101
if (deprecatedAlias.isSet() && getCanonicalSetting().isSet()) {
102-
throw new IllegalStateException(String.format("Both `%s` and its deprecated alias `%s` have been set.\n" +
102+
throw new IllegalStateException(String.format("Both `%s` and its deprecated alias `%s` have been set. " +
103103
"Please only set `%s`", getCanonicalSetting().getName(), deprecatedAlias.getName(), getCanonicalSetting().getName()));
104104
}
105105
super.validateValue();

logstash-core/src/main/java/org/logstash/settings/StringSetting.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public StringSetting(String name, String defaultValue, boolean strict, List<Stri
1717
}
1818
}
1919

20+
public StringSetting(String name, String defaultValue) {
21+
this(name, defaultValue, true, Collections.emptyList());
22+
}
23+
2024
@Override
2125
public void validate(String input) throws IllegalArgumentException {
2226
staticValidate(input, possibleStrings, this.getName());

0 commit comments

Comments
 (0)