[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Markus Roberts
Markus at reality.com
Wed Jul 14 10:35:58 UTC 2010
The following commit has been merged in the upstream branch:
commit 75e0662168936da8255507a10bccad8889326947
Author: Matt Robinson <matt at puppetlabs.com>
Date: Wed Jun 30 12:19:29 2010 -0700
[#4090] Rename mode (:master, :agent, :user) to run_mode
Mode is a terribly overused word. Files use it, puppetdoc uses it, and
certs use it, and those are just the places that I happened to
stumble upon. It makes reading code very confusing and finding things
in code difficult. I know namespacing allows us to reuse words for
method and variable names, but that doesn't mean we should.
diff --git a/lib/puppet.rb b/lib/puppet.rb
index a039d25..4e496e7 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -91,9 +91,9 @@ module Puppet
@@settings
end
- def self.mode
- require 'puppet/util/mode'
- $puppet_application_mode ||= Puppet::Util::Mode.new( :user )
+ def self.run_mode
+ require 'puppet/util/run_mode'
+ $puppet_application_mode ||= Puppet::Util::RunMode.new( :user )
end
def self.application_name
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 97d2c95..f74b375 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -155,7 +155,7 @@ class Application
[:restart_requested, :stop_requested].include? run_status
end
- # Indicates that Puppet::Application believes that it's in usual running mode (no stop/restart request
+ # Indicates that Puppet::Application believes that it's in usual running run_mode (no stop/restart request
# currently active).
def clear?
run_status.nil?
@@ -221,10 +221,10 @@ class Application
find(name).new
end
- def mode( mode_name = nil)
- @mode ||= mode_name || @mode || :user
- require 'puppet/util/mode'
- Puppet::Util::Mode.new( @mode )
+ def run_mode( mode_name = nil)
+ @run_mode ||= mode_name || @run_mode || :user
+ require 'puppet/util/run_mode'
+ Puppet::Util::RunMode.new( @run_mode )
end
end
@@ -266,10 +266,10 @@ class Application
def initialize(command_line = nil)
require 'puppet/util/command_line'
@command_line = command_line || Puppet::Util::CommandLine.new
- @mode = self.class.mode
+ @run_mode = self.class.run_mode
@options = {}
- $puppet_application_mode = @mode
+ $puppet_application_mode = @run_mode
$puppet_application_name = name
require 'puppet'
end
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index f0693f9..a754ed3 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -3,7 +3,7 @@ require 'puppet/application'
class Puppet::Application::Agent < Puppet::Application
should_parse_config
- mode :agent
+ run_mode :agent
attr_accessor :explicit_waitforcert, :args, :agent, :daemon, :host
diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb
index acbafb2..b368728 100644
--- a/lib/puppet/application/cert.rb
+++ b/lib/puppet/application/cert.rb
@@ -3,7 +3,7 @@ require 'puppet/application'
class Puppet::Application::Cert < Puppet::Application
should_parse_config
- mode :server
+ run_mode :server
attr_accessor :cert_mode, :all, :ca, :digest, :signed
diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index ba01002..a28cac2 100644
--- a/lib/puppet/application/doc.rb
+++ b/lib/puppet/application/doc.rb
@@ -3,7 +3,7 @@ require 'puppet/application'
class Puppet::Application::Doc < Puppet::Application
should_not_parse_config
- mode :master
+ run_mode :master
attr_accessor :unknown_args, :manifest
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index 5d597a6..fdcd7d3 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -3,7 +3,7 @@ require 'puppet/application'
class Puppet::Application::Master < Puppet::Application
should_parse_config
- mode :master
+ run_mode :master
option("--debug", "-d")
option("--verbose", "-v")
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 94e4466..bfc18d8 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -1,17 +1,17 @@
# The majority of the system configuration parameters are set in this file.
module Puppet
setdefaults(:main,
- :confdir => [Puppet.mode.conf_dir, "The main Puppet configuration directory. The default for this parameter is calculated based on the user. If the process
+ :confdir => [Puppet.run_mode.conf_dir, "The main Puppet configuration directory. The default for this parameter is calculated based on the user. If the process
is running as root or the user that ``puppet master`` is supposed to run as, it defaults to a system directory, but if it's running as any other user,
it defaults to being in ``~``."],
- :vardir => [Puppet.mode.var_dir, "Where Puppet stores dynamic and growing data. The default for this parameter is calculated specially, like `confdir`_."],
+ :vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic and growing data. The default for this parameter is calculated specially, like `confdir`_."],
:name => [Puppet.application_name.to_s, "The name of the application, if we are running as one. The
default is essentially $0 without the path or ``.rb``."],
- :mode => [Puppet.mode.name.to_s, "The name of the application, if we are running as one. The
+ :run_mode => [Puppet.run_mode.name.to_s, "The name of the application, if we are running as one. The
default is essentially $0 without the path or ``.rb``."]
)
- setdefaults(:main, :logdir => Puppet.mode.logopts)
+ setdefaults(:main, :logdir => Puppet.run_mode.logopts)
setdefaults(:main,
:trace => [false, "Whether to print stack traces on some errors"],
@@ -26,7 +26,7 @@ module Puppet
might result in spurious service restarts)."
},
:rundir => {
- :default => Puppet.mode.run_dir,
+ :default => Puppet.run_mode.run_dir,
:mode => 01777,
:desc => "Where Puppet PID files are kept."
},
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 0dccf36..b1c9df7 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -53,7 +53,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Is our compiler part of a network, or are we just local?
def networked?
- Puppet.mode.master?
+ Puppet.run_mode.master?
end
private
diff --git a/lib/puppet/indirector/file.rb b/lib/puppet/indirector/file.rb
index 0aedccf..a035f0d 100644
--- a/lib/puppet/indirector/file.rb
+++ b/lib/puppet/indirector/file.rb
@@ -4,7 +4,7 @@ require 'puppet/indirector/terminus'
class Puppet::Indirector::File < Puppet::Indirector::Terminus
# Where do we store our data?
def data_directory
- name = Puppet.mode.master? ? :server_datadir : :client_datadir
+ name = Puppet.run_mode.master? ? :server_datadir : :client_datadir
File.join(Puppet.settings[name], self.class.indirection_name.to_s)
end
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 7102466..39d4751 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -45,7 +45,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
# Get the yaml directory
def base
- Puppet.mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir]
+ Puppet.run_mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir]
end
# Return the path to a given node's file.
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index a97add0..c0b736d 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -70,7 +70,7 @@ class Puppet::Network::HTTP::WEBrick
# Make sure the settings are all ready for us.
Puppet.settings.use(:main, :ssl, Puppet[:name])
- if Puppet.mode.master?
+ if Puppet.run_mode.master?
file = Puppet[:masterhttplog]
else
file = Puppet[:httplog]
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index bd081c9..aa1ccf9 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -33,7 +33,7 @@ class Puppet::SSL::CertificateAuthority
def self.ca?
return false unless Puppet[:ca]
- return false unless Puppet.mode.master?
+ return false unless Puppet.run_mode.master?
return true
end
diff --git a/lib/puppet/util/mode.rb b/lib/puppet/util/run_mode.rb
similarity index 98%
rename from lib/puppet/util/mode.rb
rename to lib/puppet/util/run_mode.rb
index 16ea44e..08f2c85 100644
--- a/lib/puppet/util/mode.rb
+++ b/lib/puppet/util/run_mode.rb
@@ -1,6 +1,6 @@
module Puppet
module Util
- class Mode
+ class RunMode
def initialize(name)
@name = name.to_sym
end
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 780461d..398fa48 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -17,7 +17,7 @@ class Puppet::Util::Settings
attr_accessor :file
attr_reader :timer
- ReadOnly = [:mode, :name]
+ ReadOnly = [:run_mode, :name]
# Retrieve a config value
def [](param)
@@ -285,8 +285,8 @@ class Puppet::Util::Settings
end
# Figure out the section name for the mode.
- def mode
- convert(@config[:mode].default).intern if @config[:mode]
+ def run_mode
+ convert(@config[:run_mode].default).intern if @config[:run_mode]
end
# Return all of the parameters associated with a given section.
@@ -443,9 +443,9 @@ class Puppet::Util::Settings
# The order in which to search for values.
def searchpath(environment = nil)
if environment
- [:cli, :memory, environment, :mode, :main]
+ [:cli, :memory, environment, :run_mode, :main]
else
- [:cli, :memory, :mode, :main]
+ [:cli, :memory, :run_mode, :main]
end
end
@@ -499,7 +499,7 @@ class Puppet::Util::Settings
legacy_to_mode = Puppet::Util::CommandLine::LegacyName.inject({}) do |hash, pair|
app, legacy = pair
command_line.require_application app
- hash[legacy.to_sym] = Puppet::Application.find(app).mode.name
+ hash[legacy.to_sym] = Puppet::Application.find(app).run_mode.name
hash
end
if new_type = legacy_to_mode[type]
@@ -602,8 +602,8 @@ Generated on #{Time.now}.
}.gsub(/^/, "# ")
# Add a section heading that matches our name.
- if @config.include?(:mode)
- str += "[%s]\n" % self[:mode]
+ if @config.include?(:run_mode)
+ str += "[%s]\n" % self[:run_mode]
end
eachsection do |section|
persection(section) do |obj|
@@ -827,7 +827,7 @@ Generated on #{Time.now}.
def each_source(environment)
searchpath(environment).each do |source|
# Modify the source as necessary.
- source = self.mode if source == :mode
+ source = self.run_mode if source == :run_mode
yield source
end
end
diff --git a/spec/unit/application/doc_spec.rb b/spec/unit/application/doc_spec.rb
index db805fe..0c2e7b4 100755
--- a/spec/unit/application/doc_spec.rb
+++ b/spec/unit/application/doc_spec.rb
@@ -223,8 +223,8 @@ describe Puppet::Application::Doc do
end
end
- it "should operate in master mode" do
- @doc.class.mode.name.should == :master
+ it "should operate in master run_mode" do
+ @doc.class.run_mode.name.should == :master
@doc.setup_rdoc
end
diff --git a/spec/unit/indirector/file_spec.rb b/spec/unit/indirector/file_spec.rb
index 207d897..2505a0c 100755
--- a/spec/unit/indirector/file_spec.rb
+++ b/spec/unit/indirector/file_spec.rb
@@ -30,15 +30,15 @@ describe Puppet::Indirector::File do
@searcher.should respond_to(:find)
end
- it "should use the server data directory plus the indirection name if the process mode is master" do
- Puppet.mode.expects(:master?).returns true
+ it "should use the server data directory plus the indirection name if the run_mode is master" do
+ Puppet.run_mode.expects(:master?).returns true
Puppet.settings.expects(:value).with(:server_datadir).returns "/my/dir"
@searcher.data_directory.should == File.join("/my/dir", "mystuff")
end
- it "should use the client data directory plus the indirection name if the process mode is not master" do
- Puppet.mode.expects(:master?).returns false
+ it "should use the client data directory plus the indirection name if the run_mode is not master" do
+ Puppet.run_mode.expects(:master?).returns false
Puppet.settings.expects(:value).with(:client_datadir).returns "/my/dir"
@searcher.data_directory.should == File.join("/my/dir", "mystuff")
diff --git a/spec/unit/indirector/yaml_spec.rb b/spec/unit/indirector/yaml_spec.rb
index 37c33f0..44ecf96 100755
--- a/spec/unit/indirector/yaml_spec.rb
+++ b/spec/unit/indirector/yaml_spec.rb
@@ -22,20 +22,20 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
@dir = "/what/ever"
Puppet.settings.stubs(:value).returns("fakesettingdata")
Puppet.settings.stubs(:value).with(:clientyamldir).returns(@dir)
- Puppet.mode.stubs(:master?).returns false
+ Puppet.run_mode.stubs(:master?).returns false
@request = stub 'request', :key => :me, :instance => @subject
end
describe Puppet::Indirector::Yaml, " when choosing file location" do
- it "should use the server_datadir if the mode is master" do
- Puppet.mode.expects(:master?).returns true
+ it "should use the server_datadir if the run_mode is master" do
+ Puppet.run_mode.expects(:master?).returns true
Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
@store.path(:me).should =~ %r{^/server/yaml/dir}
end
- it "should use the client yamldir if the mode is not master" do
- Puppet.mode.expects(:master?).returns false
+ it "should use the client yamldir if the run_mode is not master" do
+ Puppet.run_mode.expects(:master?).returns false
Puppet.settings.expects(:value).with(:clientyamldir).returns "/client/yaml/dir"
@store.path(:me).should =~ %r{^/client/yaml/dir}
end
diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb
index aaab53b..34abc69 100755
--- a/spec/unit/network/http/webrick_spec.rb
+++ b/spec/unit/network/http/webrick_spec.rb
@@ -211,8 +211,8 @@ describe Puppet::Network::HTTP::WEBrick do
@server.setup_logger
end
- it "should use the masterlog if the process mode is master" do
- Puppet.mode.stubs(:master?).returns(true)
+ it "should use the masterlog if the run_mode is master" do
+ Puppet.run_mode.stubs(:master?).returns(true)
Puppet.settings.expects(:value).with(:masterhttplog).returns "/master/log"
File.expects(:open).with("/master/log", "a+").returns @filehandle
@@ -220,8 +220,8 @@ describe Puppet::Network::HTTP::WEBrick do
@server.setup_logger
end
- it "should use the httplog if the process mode is not master" do
- Puppet.mode.stubs(:master?).returns(false)
+ it "should use the httplog if the run_mode is not master" do
+ Puppet.run_mode.stubs(:master?).returns(false)
Puppet.settings.expects(:value).with(:httplog).returns "/other/log"
File.expects(:open).with("/other/log", "a+").returns @filehandle
diff --git a/spec/unit/ssl/certificate_authority_spec.rb b/spec/unit/ssl/certificate_authority_spec.rb
index 3b1b948..db812b2 100755
--- a/spec/unit/ssl/certificate_authority_spec.rb
+++ b/spec/unit/ssl/certificate_authority_spec.rb
@@ -24,10 +24,10 @@ describe Puppet::SSL::CertificateAuthority do
end
describe "when finding an existing instance" do
- describe "and the host is a CA host and the mode is master" 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.mode.stubs(:master?).returns true
+ Puppet::Util::RunMode.any_instance.stubs(:master?).returns true
@ca = mock('ca')
Puppet::SSL::CertificateAuthority.stubs(:new).returns @ca
@@ -45,7 +45,7 @@ describe Puppet::SSL::CertificateAuthority do
describe "and the host is not a CA host" do
it "should return nil" do
Puppet.settings.stubs(:value).with(:ca).returns false
- Puppet.mode.stubs(:master?).returns true
+ Puppet.run_mode.stubs(:master?).returns true
ca = mock('ca')
Puppet::SSL::CertificateAuthority.expects(:new).never
@@ -53,10 +53,10 @@ describe Puppet::SSL::CertificateAuthority do
end
end
- describe "and the mode is not master" do
+ describe "and the run_mode is not master" do
it "should return nil" do
Puppet.settings.stubs(:value).with(:ca).returns true
- Puppet.mode.stubs(:master?).returns false
+ Puppet.run_mode.stubs(:master?).returns false
ca = mock('ca')
Puppet::SSL::CertificateAuthority.expects(:new).never
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 3e70cb5..1e694a4 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -199,15 +199,15 @@ describe Puppet::Util::Settings do
lambda{ @settings[:name] = "foo" }.should raise_error(ArgumentError)
end
- it "should raise an error if we try to set 'mode'" do
- lambda{ @settings[:mode] = "foo" }.should raise_error(ArgumentError)
+ it "should raise an error if we try to set 'run_mode'" do
+ lambda{ @settings[:run_mode] = "foo" }.should raise_error(ArgumentError)
end
it "should warn and use [master] if we ask for [puppetmasterd]" do
Puppet.expects(:warning)
@settings.set_value(:myval, "foo", :puppetmasterd)
- @settings.stubs(:mode).returns(:master)
+ @settings.stubs(:run_mode).returns(:master)
@settings.value(:myval).should == "foo"
end
@@ -215,7 +215,7 @@ describe Puppet::Util::Settings do
Puppet.expects(:warning)
@settings.set_value(:myval, "foo", :puppetd)
- @settings.stubs(:mode).returns(:agent)
+ @settings.stubs(:run_mode).returns(:agent)
@settings.value(:myval).should == "foo"
end
end
@@ -274,11 +274,11 @@ describe Puppet::Util::Settings do
@settings.value(:one, "env2").should == "twoval"
end
- it "should have a mode determined by the 'mode' parameter that cannot be edited" do
- @settings.setdefaults(:whatever, :mode => ["something", "yayness"])
- @settings.mode.should == :something
+ it "should have a run_mode determined by the 'run_mode' parameter that cannot be edited" do
+ @settings.setdefaults(:whatever, :run_mode => ["something", "yayness"])
+ @settings.run_mode.should == :something
- lambda{ @settings[:mode] = :other }.should raise_error
+ lambda{ @settings[:run_mode] = :other }.should raise_error
end
end
@@ -286,9 +286,9 @@ describe Puppet::Util::Settings do
before do
@settings = Puppet::Util::Settings.new
@settings.setdefaults :section,
- :config => ["/my/file", "a"],
- :one => ["ONE", "a"],
- :mode => ["mymode", "w"]
+ :config => ["/my/file", "a"],
+ :one => ["ONE", "a" ],
+ :run_mode => ["mymode", "w" ]
FileTest.stubs(:exist?).returns true
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list