Skip to content

Commit

Permalink
remove the deprecated settings: http.enabled, http.host, http.port, a…
Browse files Browse the repository at this point in the history
…nd http.environment
  • Loading branch information
kaisecheng committed Oct 14, 2024
1 parent c80c334 commit 9ce63d0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 117 deletions.
6 changes: 1 addition & 5 deletions docker/data/logstash/env2yaml/env2yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ package main

import (
"errors"
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
"os"
"strings"
"fmt"
)

var validSettings = []string{
Expand Down Expand Up @@ -65,10 +65,6 @@ var validSettings = []string{
"dead_letter_queue.storage_policy",
"dead_letter_queue.retain.age",
"path.dead_letter_queue",
"http.enabled", // DEPRECATED: prefer `api.enabled`
"http.environment", // DEPRECATED: prefer `api.environment`
"http.host", // DEPRECATED: prefer `api.http.host`
"http.port", // DEPRECATED: prefer `api.http.port`
"log.level",
"log.format",
"log.format.json.fix_duplicate_message_fields",
Expand Down
8 changes: 4 additions & 4 deletions logstash-core/lib/logstash/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ module Environment
Setting::Boolean.new("enable-local-plugin-development", false),
Setting::String.new("log.format", "plain", true, ["json", "plain"]),
Setting::Boolean.new("log.format.json.fix_duplicate_message_fields", false),
Setting::Boolean.new("api.enabled", true).with_deprecated_alias("http.enabled", "9"),
Setting::String.new("api.http.host", "127.0.0.1").with_deprecated_alias("http.host", "9"),
Setting::PortRange.new("api.http.port", 9600..9700).with_deprecated_alias("http.port", "9"),
Setting::String.new("api.environment", "production").with_deprecated_alias("http.environment", "9"),
Setting::Boolean.new("api.enabled", true),
Setting::String.new("api.http.host", "127.0.0.1"),
Setting::PortRange.new("api.http.port", 9600..9700),
Setting::String.new("api.environment", "production"),
Setting::String.new("api.auth.type", "none", true, %w(none basic)),
Setting::String.new("api.auth.basic.username", nil, false).nullable,
Setting::Password.new("api.auth.basic.password", nil, false).nullable,
Expand Down
15 changes: 0 additions & 15 deletions logstash-core/lib/logstash/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,6 @@ class LogStash::Runner < Clamp::StrictCommand
I18n.t("logstash.runner.flag.quiet"),
:new_flag => "log.level", :new_value => "error"

deprecated_option ["--http.enabled"], :flag,
I18n.t("logstash.runner.flag.http_enabled"),
:new_flag => "api.enabled", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

deprecated_option ["--http.host"], "HTTP_HOST",
I18n.t("logstash.runner.flag.http_host"),
:new_flag => "api.http.host", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

deprecated_option ["--http.port"], "HTTP_PORT",
I18n.t("logstash.runner.flag.http_port"),
:new_flag => "api.http.port", :passthrough => true, # use settings to disambiguate
:obsoleted_version => "9"

deprecated_option ["--event_api.tags.illegal"], "STRING",
I18n.t("logstash.runner.flag.event_api.tags.illegal"),
:default => LogStash::SETTINGS.get_default("event_api.tags.illegal"),
Expand Down
10 changes: 0 additions & 10 deletions logstash-core/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,6 @@ en:
e.g. 'username:<password>'
configtest: |+
Check configuration for valid syntax and then exit.
http_enabled: |+
Can be used to disable the Web API, which is
enabled by default.
DEPRECATED: use `--api.enabled=false`
http_host: |+
Web API binding host
DEPRECATED: use `--api.http.host=IP`
http_port: |+
Web API http port
DEPRECATED: use `--api.http.port=PORT`
api_enabled: |+
Can be used to disable the Web API, which is
enabled by default.
Expand Down
83 changes: 0 additions & 83 deletions logstash-core/spec/logstash/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,37 +255,6 @@
subject.run("bin/logstash", args)
end
end

context "using deprecated :http.host alias" do
let(:deprecation_logger_stub) { double("DeprecationLogger(Settings)").as_null_object }
before(:each) { allow(LogStash::Settings).to receive(:deprecation_logger).and_return(deprecation_logger_stub) }

let(:runner_deprecation_logger_stub) { double("DeprecationLogger(Runner)").as_null_object }
before(:each) { allow(runner).to receive(:deprecation_logger).and_return(runner_deprecation_logger_stub) }

context "when deprecated :http.host is defined by the user" do
let(:args) { ["--http.host", "localhost", "-e", pipeline_string]}
it "creates an Agent whose `api.http.host` uses the provided value and provides helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.host` is a deprecated alias for `api.http.host`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.host"] has been deprecated')
expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.host")).to be(true)
expect(settings.get("api.http.host")).to eq("localhost")
end

subject.run("bin/logstash", args)
end
end

context "when :api.http.host and deprecated alias :http.host are both defined by the user" do
it "errors helpfully" do
args = ["--api.http.host", "api.local", "--http.host", "http.local", "-e", pipeline_string]
expect do
expect(subject.run("bin/logstash", args)).to_not eq(0)
end.to output(a_string_including("Both `api.http.host` and its deprecated alias `http.host` have been set. Please only set `api.http.host`")).to_stderr
end
end
end
end

context ":api.http.port" do
Expand Down Expand Up @@ -326,58 +295,6 @@
end
end
end

context "using deprecated :http.port alias" do
let(:deprecation_logger_stub) { double("DeprecationLogger(Settings)").as_null_object }
before(:each) { allow(LogStash::Settings).to receive(:deprecation_logger).and_return(deprecation_logger_stub) }

let(:runner_deprecation_logger_stub) { double("DeprecationLogger(Runner)").as_null_object }
before(:each) { allow(runner).to receive(:deprecation_logger).and_return(runner_deprecation_logger_stub) }

context "when defined using deprecated :http.port alias" do
let(:args) { ["--http.port", port_argument, "-e", pipeline_string] }

context "as a single-value string" do
let(:port_argument) { "10000" }
it "creates an Agent whose `api.http.port` uses an appropriate single-element range and logs a helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.port` is a deprecated alias for `api.http.port`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.port"] has been deprecated')

expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.port")).to be(true)
expect(settings.get("api.http.port")).to eq(10000..10000)
end

subject.run("bin/logstash", args)
end
end

context "as a range" do
let(:port_argument) { "10000-20000" }
it "creates an Agent whose `api.http.port` uses the appropriate inclusive-end range and logs a helpful deprecation message" do
expect(deprecation_logger_stub).to receive(:deprecated).with(a_string_including "`http.port` is a deprecated alias for `api.http.port`")
expect(runner_deprecation_logger_stub).to receive(:deprecated).with(a_string_including 'The flag ["--http.port"] has been deprecated')

expect(LogStash::Agent).to receive(:new) do |settings|
expect(settings.set?("api.http.port")).to be(true)
expect(settings.get("api.http.port")).to eq(10000..20000)
end

subject.run("bin/logstash", args)
end
end
end

context "when defined by both canonical name and deprecated :http.port alias" do
let(:args) { ["--api.http.port", "9603", "--http.port", "9604", "-e", pipeline_string] }

it "errors helpfully" do
expect do
expect(subject.run("bin/logstash", args)).to_not eq(0)
end.to output(a_string_including("Both `api.http.port` and its deprecated alias `http.port` have been set. Please only set `api.http.port`")).to_stderr
end
end
end
end

context "event_api.tags.illegal" do
Expand Down

0 comments on commit 9ce63d0

Please sign in to comment.