Skip to content

Commit 44be62f

Browse files
committed
(MODULES-10950) Infer application name from run mode
Fix a regression introduced by MODULES-7397[1] which incorrectly assumed that the application name can be queried through `Puppet::Application.name`, causing lenses that are pluginsynced not to be loaded. Since we only need to find out whether or not we're running as part of `puppet agent`, it should be enough to use `Puppet.run_mode.name`, which returns `:agent` in this case, and `:user` otherwise. [1] #27
1 parent 209b03b commit 44be62f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/puppet/provider/augeas/augeas.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def get_load_path(resource)
367367
load_path.flatten!
368368
end
369369

370-
if Puppet::Application.name == :agent
370+
if Puppet.run_mode.name == :agent
371371
if Puppet::FileSystem.exist?("#{Puppet[:libdir]}/augeas/lenses")
372372
load_path << "#{Puppet[:libdir]}/augeas/lenses"
373373
end

spec/unit/provider/augeas/augeas_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ def make_tmpname((prefix, suffix), n)
11241124
context 'when running application is agent' do
11251125
before(:each) do
11261126
Puppet[:libdir] = my_fixture_dir
1127-
Puppet::Application.stubs(:name).returns(:agent)
1127+
Puppet.run_mode.stubs(:name).returns(:agent)
11281128
end
11291129

11301130
it 'offers pluginsync augeas/lenses subdir' do
@@ -1139,7 +1139,7 @@ def make_tmpname((prefix, suffix), n)
11391139

11401140
context 'when running application is not agent' do
11411141
before(:each) do
1142-
Puppet::Application.stubs(:name).returns(:apply)
1142+
Puppet.run_mode.stubs(:name).returns(:user)
11431143

11441144
env = Puppet::Node::Environment.create('root', ['/modules/foobar'])
11451145
Puppet.stubs(:lookup).returns(env)

0 commit comments

Comments
 (0)