diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2010-07-01 12:01:46 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-01 13:48:03 -0700 |
| commit | 174e02a2b71fd51ff27f9186526352d79253da26 (patch) | |
| tree | bd7d78e2eb18dd3394344c4f0b3112b0d52a49ba /lib | |
| parent | 62e3b611e65deab60c615eac553cac9aa7e76d9d (diff) | |
| download | puppet-174e02a2b71fd51ff27f9186526352d79253da26.tar.gz puppet-174e02a2b71fd51ff27f9186526352d79253da26.tar.xz puppet-174e02a2b71fd51ff27f9186526352d79253da26.zip | |
[#4090] Change how RunMode instances are created so that an object for each RunMode is only created once instead of every time it's called
Got lots of unpredictable test failures, presumably because a new
RunMode was being created every time we accessed the RunMode.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/application.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/util/run_mode.rb | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index af1bd8da9..2e0066ca1 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -93,7 +93,7 @@ module Puppet def self.run_mode require 'puppet/util/run_mode' - $puppet_application_mode || Puppet::Util::RunMode.new( :user ) + $puppet_application_mode || Puppet::Util::RunMode[:user] end def self.application_name diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index c49f42fd7..8aa3708aa 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -228,7 +228,7 @@ class Application return @run_mode if @run_mode and not mode_name require 'puppet/util/run_mode' - @run_mode = Puppet::Util::RunMode.new( mode_name || :user ) + @run_mode = Puppet::Util::RunMode[ mode_name || :user ] end end diff --git a/lib/puppet/util/run_mode.rb b/lib/puppet/util/run_mode.rb index 08f2c851f..029c1f921 100644 --- a/lib/puppet/util/run_mode.rb +++ b/lib/puppet/util/run_mode.rb @@ -5,8 +5,14 @@ module Puppet @name = name.to_sym end + @@run_modes = Hash.new {|h, k| h[k] = RunMode.new(k)} + attr :name + def self.[](name) + @@run_modes[name] + end + def master? name == :master end |
