diff options
| -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 | ||||
| -rwxr-xr-x | spec/unit/ssl/certificate_authority_spec.rb | 2 | ||||
| -rwxr-xr-x | test/network/authorization.rb | 2 | ||||
| -rwxr-xr-x | test/network/server/webrick.rb | 2 |
6 files changed, 11 insertions, 5 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 diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb index db812b278..a39113d8f 100755 --- a/spec/unit/ssl/certificate_authority_spec.rb +++ b/spec/unit/ssl/certificate_authority_spec.rb @@ -27,7 +27,7 @@ describe Puppet::SSL::CertificateAuthority do describe "and the host is a CA host and the run_mode is master" do before do Puppet.settings.stubs(:value).with(:ca).returns true - Puppet::Util::RunMode.any_instance.stubs(:master?).returns true + Puppet.run_mode.stubs(:master?).returns true @ca = mock('ca') Puppet::SSL::CertificateAuthority.stubs(:new).returns @ca diff --git a/test/network/authorization.rb b/test/network/authorization.rb index 56c537773..3c1f71e49 100755 --- a/test/network/authorization.rb +++ b/test/network/authorization.rb @@ -83,7 +83,7 @@ class TestAuthConfig < Test::Unit::TestCase assert_logged(:notice, /Denying/, "did not log call") # Now set our run_mode to master, so calls are allowed - Puppet::Util::RunMode.any_instance.stubs(:master?).returns true + Puppet.run_mode.stubs(:master?).returns true assert(@obj.authorized?(@request), "Denied call with no config file and master") assert_logged(:debug, /Allowing/, "did not log call") diff --git a/test/network/server/webrick.rb b/test/network/server/webrick.rb index 99b04817c..e2493b424 100755 --- a/test/network/server/webrick.rb +++ b/test/network/server/webrick.rb @@ -93,7 +93,7 @@ class TestWebrickServer < Test::Unit::TestCase } pid = fork { - Puppet::Util::RunMode.any_instance.stubs(:master?).returns true + Puppet.run_mode.stubs(:master?).returns true assert_nothing_raised() { trap(:INT) { server.shutdown } server.start |
