From 50f65bbbeb483bc1c85d06219373b4755f7aa4d3 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Tue, 24 Mar 2020 12:50:30 -0400 Subject: [PATCH] Adding `solr_wrapper --debug` option Prior to this commit, it was somewhat opaque what was used in the Solr Wrapper work. This change will provide a way to gain insight into the configuration options that would run. --- exe/solr_wrapper | 9 +++++++++ lib/solr_wrapper/configuration.rb | 5 ++++- lib/solr_wrapper/instance.rb | 9 +++++++++ lib/solr_wrapper/settings.rb | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/exe/solr_wrapper b/exe/solr_wrapper index ebf9abd..47d2948 100755 --- a/exe/solr_wrapper +++ b/exe/solr_wrapper @@ -67,6 +67,10 @@ args = OptionParser.new do |opts| options[:ignore_checksum] = true end + opts.on("--debug", "Output configuration parameters and exit") do |d| + options[:debug] = true + end + opts.separator "" opts.separator subtext end @@ -98,6 +102,11 @@ end instance = SolrWrapper.instance(options) +if instance.debug? + puts instance.as_json + exit(0) +end + case command when 'clean' if instance.started? diff --git a/lib/solr_wrapper/configuration.rb b/lib/solr_wrapper/configuration.rb index 91bcaf0..18c791f 100644 --- a/lib/solr_wrapper/configuration.rb +++ b/lib/solr_wrapper/configuration.rb @@ -7,10 +7,13 @@ class Configuration def initialize(options = {}) @config = options[:config] @verbose = options[:verbose] - @options = load_configs(Array(options[:config])).merge(options) end + def debug? + @debug + end + def solr_xml options[:solr_xml] end diff --git a/lib/solr_wrapper/instance.rb b/lib/solr_wrapper/instance.rb index e33d01a..d020cb0 100644 --- a/lib/solr_wrapper/instance.rb +++ b/lib/solr_wrapper/instance.rb @@ -35,9 +35,18 @@ class Instance # @option options [Hash] :env # @option options [String] :config def initialize(options = {}) + @debug = options.fetch(:debug, false) @config = Settings.new(Configuration.new(options)) end + def debug? + @debug + end + + def as_json + config.as_json + end + def host config.host end diff --git a/lib/solr_wrapper/settings.rb b/lib/solr_wrapper/settings.rb index 80dc565..a5ece8e 100644 --- a/lib/solr_wrapper/settings.rb +++ b/lib/solr_wrapper/settings.rb @@ -20,6 +20,25 @@ def initialize(static_config) @static_config = static_config end + def as_json + { + host: host, + zookeeper_host: zookeeper_host, + port: port, + zookeeper_port: zookeeper_port, + url: url, + instance_dir: instance_dir, + managed: managed?, + download_url: download_url, + download_dir: download_dir, + solr_zip_path: solr_zip_path, + version_file: version_file, + solr_binary: solr_binary, + tmp_save_dir: tmp_save_dir, + default_download_url: default_download_url + } + end + ## # Get the host this Solr instance is bound to def host