diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index bd3ad6b23d..8b94fd6a82 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -318,14 +318,6 @@ def self.initialize_default_settings!(settings) sense when specified on the command line as `--genmanifest`. Takes into account arguments specified on the CLI.", }, - :configprint => { - :default => "", - :deprecated => :completely, - :desc => "Prints the value of a specific configuration setting. If the name of a - setting is provided for this, then the value is printed and puppet - exits. Comma-separate multiple values. For a list of all values, - specify 'all'. This setting is deprecated, the 'puppet config' command replaces this functionality.", - }, :color => { :default => "ansi", :type => :string, diff --git a/lib/puppet/settings.rb b/lib/puppet/settings.rb index e1303ab606..cedb8dec5b 100644 --- a/lib/puppet/settings.rb +++ b/lib/puppet/settings.rb @@ -512,45 +512,6 @@ def include?(name) @config.include?(name) end - # Prints the contents of a config file with the available config settings, or it - # prints a single value of a config setting. - def print_config_options - if Puppet::Util::Log.sendlevel?(:info) - Puppet::Util::Log.newdestination(:console) - message = _("Using --configprint is deprecated. Use 'puppet config ' instead.") - Puppet.deprecation_warning(message) - end - - env = value(:environment) - val = value(:configprint) - if val == "all" - hash = {} - each do |name, _obj| - val = value(name, env) - val = val.inspect if val == "" - hash[name] = val - end - hash.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, v| - puts "#{name} = #{v}" - end - else - val.split(/\s*,\s*/).sort.each do |v| - if include?(v) - # if there is only one value, just print it for back compatibility - if v == val - puts value(val, env) - break - end - puts "#{v} = #{value(v, env)}" - else - puts "invalid setting: #{v}" - return false - end - end - end - true - end - def generate_config puts to_config true @@ -562,14 +523,13 @@ def generate_manifest end def print_configs - return print_config_options if value(:configprint) != "" return generate_config if value(:genconfig) generate_manifest if value(:genmanifest) end def print_configs? - (value(:configprint) != "" || value(:genconfig) || value(:genmanifest)) && true + (value(:genconfig) || value(:genmanifest)) && true end # The currently configured run mode that is preferred for constructing the application configuration. diff --git a/spec/integration/directory_environments_spec.rb b/spec/integration/directory_environments_spec.rb index 79815dd393..58f78cf27a 100644 --- a/spec/integration/directory_environments_spec.rb +++ b/spec/integration/directory_environments_spec.rb @@ -1,8 +1,9 @@ require 'spec_helper' +require 'puppet/application/config' describe "directory environments" do - let(:args) { ['--configprint', 'modulepath', '--environment', 'direnv'] } - let(:puppet) { Puppet::Application[:apply] } + let(:args) { ['print', 'modulepath', '--environment', 'direnv'] } + let(:puppet) { Puppet::Application[:config] } context "with a single directory environmentpath" do before(:each) do @@ -12,7 +13,8 @@ end it "config prints the environments modulepath" do - Puppet.settings.initialize_global_settings(args) + puppet.command_line.args = args + Puppet.initialize_settings(args) expect { puppet.run }.to exit_with(0) @@ -20,8 +22,9 @@ end it "config prints the cli --modulepath despite environment" do - args << '--modulepath' << '/completely/different' - Puppet.settings.initialize_global_settings(args) + args.push('--modulepath', '/completely/different') + puppet.command_line.args = args + Puppet.initialize_settings(args) expect { puppet.run }.to exit_with(0) @@ -38,7 +41,8 @@ Puppet[:environmentpath] = shortened expect(Puppet[:environmentpath]).to match(/~/) - Puppet.settings.initialize_global_settings(args) + puppet.command_line.args = args + Puppet.initialize_settings(args) expect { puppet.run }.to exit_with(0) @@ -47,7 +51,7 @@ end context "with an environmentpath having multiple directories" do - let(:args) { ['--configprint', 'modulepath', '--environment', 'otherdirenv'] } + let(:args) { ['print', 'modulepath', '--environment', 'otherdirenv'] } before(:each) do envdir1 = File.join(Puppet[:confdir], 'env1') @@ -57,7 +61,8 @@ end it "config prints a directory environment modulepath" do - Puppet.settings.initialize_global_settings(args) + puppet.command_line.args = args + Puppet.initialize_settings(args) expect { puppet.run }.to exit_with(0) diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb index 381c3e9e0a..eefcb5f940 100644 --- a/spec/unit/application/agent_spec.rb +++ b/spec/unit/application/agent_spec.rb @@ -286,19 +286,6 @@ def run(options = {}); end end end - it "should print puppet config if asked to in Puppet config" do - Puppet[:configprint] = "plugindest" - expect(Puppet.settings).to receive(:print_configs).and_return(true) - expect { execute_agent }.to exit_with 0 - end - - it "should exit after printing puppet config if asked to in Puppet config" do - path = make_absolute('/my/path') - Puppet[:modulepath] = path - Puppet[:configprint] = "modulepath" - expect_any_instance_of(Puppet::Settings).to receive(:puts).with(path) - expect { execute_agent }.to exit_with 0 - end it "should use :main, :puppetd, and :ssl" do expect(Puppet.settings).to receive(:use).with(:main, :agent, :ssl) diff --git a/spec/unit/settings_spec.rb b/spec/unit/settings_spec.rb index d8d213e8ea..56e3d7910f 100644 --- a/spec/unit/settings_spec.rb +++ b/spec/unit/settings_spec.rb @@ -2044,11 +2044,6 @@ def assert_accessing_setting_is_deprecated(settings, setting) expect(@settings.print_configs?).to be_falsey end - it "should return true when :configprint has a value" do - allow(@settings).to receive(:value).with(:configprint).and_return("something") - expect(@settings.print_configs?).to be_truthy - end - it "should return true when :genconfig has a value" do allow(@settings).to receive(:value).with(:genconfig).and_return(true) expect(@settings.print_configs?).to be_truthy @@ -2061,57 +2056,6 @@ def assert_accessing_setting_is_deprecated(settings, setting) end describe "when printing configs" do - describe "when :configprint has a value" do - it "should call print_config_options" do - allow(@settings).to receive(:value).with(:configprint).and_return("something") - expect(@settings).to receive(:print_config_options) - @settings.print_configs - end - - it "should get the value of the option using the environment" do - allow(@settings).to receive(:value).with(:configprint).and_return("something") - allow(@settings).to receive(:include?).with("something").and_return(true) - expect(@settings).to receive(:value).with(:environment).and_return("env") - expect(@settings).to receive(:value).with("something", "env").and_return("foo") - allow(@settings).to receive(:puts).with("foo") - @settings.print_configs - end - - it "should print the value of the option" do - allow(@settings).to receive(:value).with(:configprint).and_return("something") - allow(@settings).to receive(:include?).with("something").and_return(true) - allow(@settings).to receive(:value).with("something", nil).and_return("foo") - expect(@settings).to receive(:puts).with("foo") - @settings.print_configs - end - - it "should print the value pairs if there are multiple options" do - allow(@settings).to receive(:value).with(:configprint).and_return("bar,baz") - allow(@settings).to receive(:include?).with("bar").and_return(true) - allow(@settings).to receive(:include?).with("baz").and_return(true) - allow(@settings).to receive(:value).with("bar", nil).and_return("foo") - allow(@settings).to receive(:value).with("baz", nil).and_return("fud") - expect(@settings).to receive(:puts).with("bar = foo") - expect(@settings).to receive(:puts).with("baz = fud") - @settings.print_configs - end - - it "should return true after printing" do - allow(@settings).to receive(:value).with(:configprint).and_return("something") - allow(@settings).to receive(:include?).with("something").and_return(true) - allow(@settings).to receive(:value).with("something", nil).and_return("foo") - allow(@settings).to receive(:puts).with("foo") - expect(@settings.print_configs).to be_truthy - end - - it "should return false if a config param is not found" do - allow(@settings).to receive(:puts) - allow(@settings).to receive(:value).with(:configprint).and_return("something") - allow(@settings).to receive(:include?).with("something").and_return(false) - expect(@settings.print_configs).to be_falsey - end - end - describe "when genconfig is true" do before do allow(@settings).to receive(:puts)