From 9ce63d06da28bcc18ea2a3e6c08f3ab4c84c6d8c Mon Sep 17 00:00:00 2001 From: Kaise Cheng Date: Mon, 14 Oct 2024 13:45:31 +0100 Subject: [PATCH] remove the deprecated settings: http.enabled, http.host, http.port, and http.environment --- docker/data/logstash/env2yaml/env2yaml.go | 6 +- logstash-core/lib/logstash/environment.rb | 8 +-- logstash-core/lib/logstash/runner.rb | 15 ---- logstash-core/locales/en.yml | 10 --- logstash-core/spec/logstash/runner_spec.rb | 83 ---------------------- 5 files changed, 5 insertions(+), 117 deletions(-) diff --git a/docker/data/logstash/env2yaml/env2yaml.go b/docker/data/logstash/env2yaml/env2yaml.go index 7bcaa33d17f..28ee2d22692 100644 --- a/docker/data/logstash/env2yaml/env2yaml.go +++ b/docker/data/logstash/env2yaml/env2yaml.go @@ -16,12 +16,12 @@ package main import ( "errors" + "fmt" "gopkg.in/yaml.v2" "io/ioutil" "log" "os" "strings" - "fmt" ) var validSettings = []string{ @@ -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", diff --git a/logstash-core/lib/logstash/environment.rb b/logstash-core/lib/logstash/environment.rb index fb971364eb2..b975f2c6f2c 100644 --- a/logstash-core/lib/logstash/environment.rb +++ b/logstash-core/lib/logstash/environment.rb @@ -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, diff --git a/logstash-core/lib/logstash/runner.rb b/logstash-core/lib/logstash/runner.rb index 148a758e441..2d51c4c35d4 100644 --- a/logstash-core/lib/logstash/runner.rb +++ b/logstash-core/lib/logstash/runner.rb @@ -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"), diff --git a/logstash-core/locales/en.yml b/logstash-core/locales/en.yml index e5e8211bce4..1af921dabf3 100644 --- a/logstash-core/locales/en.yml +++ b/logstash-core/locales/en.yml @@ -300,16 +300,6 @@ en: e.g. 'username:' 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. diff --git a/logstash-core/spec/logstash/runner_spec.rb b/logstash-core/spec/logstash/runner_spec.rb index 0408e9de173..78c2572d4b6 100644 --- a/logstash-core/spec/logstash/runner_spec.rb +++ b/logstash-core/spec/logstash/runner_spec.rb @@ -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 @@ -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