Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/puppet/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 1 addition & 41 deletions lib/puppet/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <subcommand>' 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
Expand All @@ -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.
Expand Down
21 changes: 13 additions & 8 deletions spec/integration/directory_environments_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,16 +13,18 @@
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)
.and output(%r{/direnv/modules}).to_stdout
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)
Expand All @@ -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)
Expand All @@ -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')
Expand All @@ -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)
Expand Down
13 changes: 0 additions & 13 deletions spec/unit/application/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
56 changes: 0 additions & 56 deletions spec/unit/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down