diff options
53 files changed, 297 insertions, 298 deletions
diff --git a/bin/filebucket b/bin/filebucket index 2001eaf63..22580cbe3 100755 --- a/bin/filebucket +++ b/bin/filebucket @@ -109,7 +109,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -139,7 +139,7 @@ begin when "--remote" options[:remote] = true else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail diff --git a/bin/puppet b/bin/puppet index 9520492a2..deeb65c42 100755 --- a/bin/puppet +++ b/bin/puppet @@ -76,7 +76,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -124,7 +124,7 @@ begin $stderr.puts detail.to_s end else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail @@ -156,7 +156,7 @@ end # Now parse the config if Puppet[:config] and File.exists? Puppet[:config] - Puppet.config.parse(Puppet[:config]) + Puppet.settings.parse(Puppet[:config]) end Puppet.genconfig diff --git a/bin/puppetca b/bin/puppetca index 3dbd87b89..72b2640a3 100755 --- a/bin/puppetca +++ b/bin/puppetca @@ -104,7 +104,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -143,7 +143,7 @@ begin when "--verbose" Puppet::Util::Log.level = :info else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail diff --git a/bin/puppetd b/bin/puppetd index a03ed8f10..8d112ca3a 100755 --- a/bin/puppetd +++ b/bin/puppetd @@ -178,7 +178,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -216,10 +216,10 @@ begin options[:enable] = true when "--test" # Enable all of the most common test options. - Puppet.config.handlearg("--ignorecache") - Puppet.config.handlearg("--no-usecacheonfailure") - Puppet.config.handlearg("--no-splay") - Puppet.config.handlearg("--show_diff") + Puppet.settings.handlearg("--ignorecache") + Puppet.settings.handlearg("--no-usecacheonfailure") + Puppet.settings.handlearg("--no-splay") + Puppet.settings.handlearg("--show_diff") options[:onetime] = true options[:waitforcert] = 0 unless Puppet::Util::Log.level == :debug @@ -264,7 +264,7 @@ begin options[:waitforcert] = arg.to_i explicit_waitforcert = true else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail diff --git a/bin/puppetmasterd b/bin/puppetmasterd index 4552fd0b8..51c714b15 100755 --- a/bin/puppetmasterd +++ b/bin/puppetmasterd @@ -95,7 +95,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -152,7 +152,7 @@ begin when "--verbose" options[:verbose] = true else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail diff --git a/bin/puppetrun b/bin/puppetrun index cd6b493b9..1aa0b295b 100755 --- a/bin/puppetrun +++ b/bin/puppetrun @@ -199,7 +199,7 @@ flags = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(flags) +Puppet.settings.addargs(flags) result = GetoptLong.new(*flags) @@ -259,7 +259,7 @@ begin when "--debug" options[:debug] = true else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail @@ -278,7 +278,7 @@ config = File.join(Puppet[:confdir], "puppetmasterd.conf") Puppet.parse_config(config) if File.exists? config - Puppet.config.parse(config) + Puppet.settings.parse(config) end if Puppet[:ldapnodes] @@ -99,7 +99,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -139,7 +139,7 @@ result.each { |opt,arg| debug = true else # Anything else is handled by the config stuff - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } diff --git a/ext/module_puppet b/ext/module_puppet index 194f3fa09..52f65b094 100755 --- a/ext/module_puppet +++ b/ext/module_puppet @@ -61,7 +61,7 @@ options = [ ] # Add all of the config parameters as valid options. -Puppet.config.addargs(options) +Puppet.settings.addargs(options) result = GetoptLong.new(*options) @@ -108,7 +108,7 @@ begin $stderr.puts detail.to_s end else - Puppet.config.handlearg(opt, arg) + Puppet.settings.handlearg(opt, arg) end } rescue GetoptLong::InvalidOption => detail @@ -121,7 +121,7 @@ end # Now parse the config if Puppet[:config] and File.exists? Puppet[:config] - Puppet.config.parse(Puppet[:config]) + Puppet.settings.parse(Puppet[:config]) end client = nil diff --git a/lib/puppet.rb b/lib/puppet.rb index b9a09bb49..949922459 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -12,7 +12,7 @@ require 'puppet/external/event-loop' require 'puppet/util' require 'puppet/util/log' require 'puppet/util/autoload' -require 'puppet/util/config' +require 'puppet/util/settings' require 'puppet/util/feature' require 'puppet/util/suidmanager' @@ -45,7 +45,7 @@ module Puppet end # the hash that determines how our system behaves - @@config = Puppet::Util::Config.new + @@settings = Puppet::Util::Settings.new # The services running in this process. @services ||= [] @@ -76,7 +76,7 @@ module Puppet # Store a new default value. def self.setdefaults(section, hash) - @@config.setdefaults(section, hash) + @@settings.setdefaults(section, hash) end # configuration parameter access and stuff @@ -89,17 +89,17 @@ module Puppet return false end else - return @@config[param] + return @@settings[param] end end # configuration parameter access and stuff def self.[]=(param,value) - @@config[param] = value + @@settings[param] = value end def self.clear - @@config.clear + @@settings.clear end def self.debug=(value) @@ -110,8 +110,8 @@ module Puppet end end - def self.config - @@config + def self.settings + @@settings end # Load all of the configuration parameters. @@ -122,7 +122,7 @@ module Puppet val = Puppet[:configprint] if val == "all" hash = {} - Puppet.config.each do |name, obj| + Puppet.settings.each do |name, obj| val = obj.value case val when true, false, "": val = val.inspect @@ -134,7 +134,7 @@ module Puppet end elsif val =~ /,/ val.split(/\s*,\s*/).sort.each do |v| - if Puppet.config.include?(v) + if Puppet.settings.include?(v) puts "%s = %s" % [v, Puppet[v]] else puts "invalid parameter: %s" % v @@ -143,7 +143,7 @@ module Puppet end else val.split(/\s*,\s*/).sort.each do |v| - if Puppet.config.include?(v) + if Puppet.settings.include?(v) puts Puppet[val] else puts "invalid parameter: %s" % v @@ -154,14 +154,14 @@ module Puppet exit(0) end if Puppet[:genconfig] - puts Puppet.config.to_config + puts Puppet.settings.to_config exit(0) end end def self.genmanifest if Puppet[:genmanifest] - puts Puppet.config.to_manifest + puts Puppet.settings.to_manifest exit(0) end end @@ -208,14 +208,14 @@ module Puppet oldconfig ||= File.join(Puppet[:confdir], Puppet[:name].to_s + ".conf") if FileTest.exists?(oldconfig) and Puppet[:name] != "puppet" Puppet.warning "Individual config files are deprecated; remove %s and use puppet.conf" % oldconfig - Puppet.config.old_parse(oldconfig) + Puppet.settings.old_parse(oldconfig) return end # Now check for the normal config. if Puppet[:config] and File.exists? Puppet[:config] Puppet.debug "Parsing %s" % Puppet[:config] - Puppet.config.parse(Puppet[:config]) + Puppet.settings.parse(Puppet[:config]) end end diff --git a/lib/puppet/config_stores/rest.rb b/lib/puppet/config_stores/rest.rb index 980968bd8..bb3d937ac 100644 --- a/lib/puppet/config_stores/rest.rb +++ b/lib/puppet/config_stores/rest.rb @@ -1,4 +1,4 @@ -Puppet::Util::ConfigStore.newstore(:rest) do +Puppet::Util::SettingsStore.newstore(:rest) do desc "Store client configurations via a REST web service." require 'net/http' diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 64f370bec..dbbe5e29d 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -267,7 +267,7 @@ module Puppet ) # Define the config default. - self.setdefaults(self.config[:name], + self.setdefaults(self.settings[:name], :config => ["$confdir/puppet.conf", "The configuration file for #{Puppet[:name]}."], :pidfile => ["", "The pid file"], diff --git a/lib/puppet/fact_stores/yaml.rb b/lib/puppet/fact_stores/yaml.rb index a4b12a2e5..b33e162ba 100644 --- a/lib/puppet/fact_stores/yaml.rb +++ b/lib/puppet/fact_stores/yaml.rb @@ -16,7 +16,7 @@ Puppet::Util::FactStore.newstore(:yaml) do end def initialize - Puppet.config.use(:yamlfacts) + Puppet.settings.use(:yamlfacts) end # Store the facts to disk. diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index aacad6c45..8afe0012d 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -47,8 +47,8 @@ class Puppet::Indirector::Indirection # Get the name of the terminus. unless terminus_name param_name = "%s_terminus" % self.name - if Puppet.config.valid?(param_name) - terminus_name = Puppet.config[param_name] + if Puppet.settings.valid?(param_name) + terminus_name = Puppet.settings[param_name] else terminus_name = Puppet[:default_terminus] end diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 42f1bb703..b9ea54f39 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -4,7 +4,7 @@ require 'puppet/indirector/terminus' class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus def initialize # Make sure our base directory exists. - Puppet.config.use(:yaml) + Puppet.settings.use(:yaml) end # Read a given name's file in and convert it from YAML. diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 924958bbe..dc30d8167 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -9,7 +9,7 @@ class Puppet::Module # parameter. Only consider paths that are absolute and existing # directories def self.modulepath(environment = nil) - dirs = Puppet.config.value(:modulepath, environment).split(":") + dirs = Puppet.settings.value(:modulepath, environment).split(":") if ENV["PUPPETLIB"] dirs = ENV["PUPPETLIB"].split(":") + dirs else @@ -61,7 +61,7 @@ class Puppet::Module if mod return mod.template(file) else - return File.join(Puppet.config.value(:templatedir, environment), template) + return File.join(Puppet.settings.value(:templatedir, environment), template) end end diff --git a/lib/puppet/network/client/ca.rb b/lib/puppet/network/client/ca.rb index 412c9c59f..46fb9f51f 100644 --- a/lib/puppet/network/client/ca.rb +++ b/lib/puppet/network/client/ca.rb @@ -14,9 +14,9 @@ class Puppet::Network::Client::CA < Puppet::Network::Client end # This client is really only able to request certificates for the - # current host. It uses the Puppet.config settings to figure everything out. + # current host. It uses the Puppet.settings settings to figure everything out. def request_cert - Puppet.config.use(:main, :ssl) + Puppet.settings.use(:main, :ssl) if cert = read_cert return cert @@ -49,8 +49,8 @@ class Puppet::Network::Client::CA < Puppet::Network::Client end # Only write the cert out if it passes validating. - Puppet.config.write(:hostcert) do |f| f.print cert end - Puppet.config.write(:localcacert) do |f| f.print cacert end + Puppet.settings.write(:hostcert) do |f| f.print cert end + Puppet.settings.write(:localcacert) do |f| f.print cacert end return @cert end diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index cc66d9076..f950a6059 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -46,7 +46,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # Return the list of dynamic facts as an array of symbols def self.dynamic_facts - Puppet.config[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase } + Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase } end # Cache the config @@ -205,7 +205,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # Just so we can specify that we are "the" instance. def initialize(*args) - Puppet.config.use(:main, :ssl, :puppetd) + Puppet.settings.use(:main, :ssl, :puppetd) super self.class.instance = self diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb index 422b21ae1..052eb5c19 100644 --- a/lib/puppet/network/handler/ca.rb +++ b/lib/puppet/network/handler/ca.rb @@ -60,7 +60,7 @@ class Puppet::Network::Handler end def initialize(hash = {}) - Puppet.config.use(:main, :ssl, :ca) + Puppet.settings.use(:main, :ssl, :ca) if hash.include? :autosign @autosign = hash[:autosign] end diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb index bb6a0e6d3..1bf8da854 100755 --- a/lib/puppet/network/handler/filebucket.rb +++ b/lib/puppet/network/handler/filebucket.rb @@ -64,7 +64,7 @@ class Puppet::Network::Handler # :nodoc: end end - Puppet.config.use(:filebucket) + Puppet.settings.use(:filebucket) @name = "Filebucket[#{@path}]" end diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb index 81aee6a3c..62e9cfdec 100755 --- a/lib/puppet/network/handler/report.rb +++ b/lib/puppet/network/handler/report.rb @@ -71,8 +71,8 @@ class Puppet::Network::Handler def initialize(*args) super - Puppet.config.use(:reporting) - Puppet.config.use(:metrics) + Puppet.settings.use(:reporting) + Puppet.settings.use(:metrics) end # Accept a report from a client. diff --git a/lib/puppet/network/server/webrick.rb b/lib/puppet/network/server/webrick.rb index 3af0cfd3f..f24411ab3 100644 --- a/lib/puppet/network/server/webrick.rb +++ b/lib/puppet/network/server/webrick.rb @@ -48,7 +48,7 @@ module Puppet # yuck; separate http logs file = nil - Puppet.config.use(:main, :ssl, Puppet[:name]) + Puppet.settings.use(:main, :ssl, Puppet[:name]) if Puppet[:name] == "puppetmasterd" file = Puppet[:masterhttplog] else diff --git a/lib/puppet/node/configuration.rb b/lib/puppet/node/configuration.rb index 360c25fc8..0ae03a651 100644 --- a/lib/puppet/node/configuration.rb +++ b/lib/puppet/node/configuration.rb @@ -357,7 +357,7 @@ class Puppet::Node::Configuration < Puppet::PGraph return unless Puppet[:graph] - Puppet.config.use(:graphing) + Puppet.settings.use(:graphing) file = File.join(Puppet[:graphdir], "%s.dot" % name.to_s) File.open(file, "w") { |f| diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index a4ea26572..81867c84b 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -68,7 +68,7 @@ class Puppet::Parser::Interpreter elsif self.file parser.file = self.file else - file = Puppet.config.value(:manifest, environment) + file = Puppet.settings.value(:manifest, environment) parser.file = file end parser.parse diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index 670c622eb..53dafce79 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -9,7 +9,7 @@ module Puppet::Rails # This global init does not work for testing, because we remove # the state dir on every test. unless ActiveRecord::Base.connected? - Puppet.config.use(:main, :rails, :puppetmasterd) + Puppet.settings.use(:main, :rails, :puppetmasterd) ActiveRecord::Base.logger = Logger.new(Puppet[:railslog]) begin @@ -103,7 +103,7 @@ module Puppet::Rails raise Puppet::DevError, "No activerecord, cannot init Puppet::Rails" end - Puppet.config.use(:puppetmasterd, :rails) + Puppet.settings.use(:puppetmasterd, :rails) begin ActiveRecord::Base.establish_connection(database_arguments()) diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index 65fdbeb7d..4b09002b8 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -1,6 +1,6 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc => "A reference for all configuration parameters") do docs = {} - Puppet.config.each do |name, object| + Puppet.settings.each do |name, object| docs[name] = object end diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb index 7209a8401..1516d331a 100644 --- a/lib/puppet/reports/rrdgraph.rb +++ b/lib/puppet/reports/rrdgraph.rb @@ -102,7 +102,7 @@ Puppet::Network::Handler.report.newreport(:rrdgraph) do unless File.directory?(hostdir) and FileTest.writable?(hostdir) # Some hackishness to create the dir with all of the right modes and ownership - config = Puppet::Util::Config.new + config = Puppet::Util::Settings.new config.setdefaults(:reports, :hostdir => {:default => hostdir, :owner => Puppet[:user], :mode => 0755, :group => Puppet[:group], :desc => "eh"}) # This creates the dir. diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index d51f50372..389de4e6e 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -1,7 +1,7 @@ require 'puppet' Puppet::Network::Handler.report.newreport(:store, :useyaml => true) do - Puppet.config.use(:reporting) + Puppet.settings.use(:reporting) desc "Store the yaml report on disk. Each host sends its report as a YAML dump and this just stores the file on disk, in the ``reportdir`` directory. @@ -11,7 +11,7 @@ Puppet::Network::Handler.report.newreport(:store, :useyaml => true) do default report)." def mkclientdir(client, dir) - config = Puppet::Util::Config.new + config = Puppet::Util::Settings.new config.setdefaults("reportclient-#{client}", "client-#{client}-dir" => { :default => dir, :mode => 0750, diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index b62a6d2d3..8c65524ee 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -31,7 +31,7 @@ Puppet::Network::Handler.report.newreport(:tagmail) do " - Puppet.config.use(:tagmail) + Puppet.settings.use(:tagmail) # Find all matching messages. def match(taglists) diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb index 5e355f7fe..fd416dd5e 100644 --- a/lib/puppet/sslcertificates/ca.rb +++ b/lib/puppet/sslcertificates/ca.rb @@ -53,7 +53,7 @@ class Puppet::SSLCertificates::CA end def initialize(hash = {}) - Puppet.config.use(:main, :ca, :ssl) + Puppet.settings.use(:main, :ca, :ssl) self.setconfig(hash) if Puppet[:capass] @@ -73,7 +73,7 @@ class Puppet::SSLCertificates::CA self.getcert init_crl unless FileTest.exists?(@config[:serial]) - Puppet.config.write(:serial) do |f| + Puppet.settings.write(:serial) do |f| f << "%04X" % 1 end end @@ -85,7 +85,7 @@ class Puppet::SSLCertificates::CA 20.times { pass += (rand(74) + 48).chr } begin - Puppet.config.write(:capass) { |f| f.print pass } + Puppet.settings.write(:capass) { |f| f.print pass } rescue Errno::EACCES => detail raise Puppet::Error, detail.to_s end @@ -163,10 +163,10 @@ class Puppet::SSLCertificates::CA Puppet::Util::SUIDManager.asuser(Puppet[:user], Puppet[:group]) do @cert = cert.mkselfsigned end - Puppet.config.write(:cacert) do |f| + Puppet.settings.write(:cacert) do |f| f.puts @cert.to_pem end - Puppet.config.write(:capub) do |f| + Puppet.settings.write(:capub) do |f| f.puts @cert.public_key end return cert @@ -201,7 +201,7 @@ class Puppet::SSLCertificates::CA # Take the Puppet config and store it locally. def setconfig(hash) @config = {} - Puppet.config.params("ca").each { |param| + Puppet.settings.params("ca").each { |param| param = param.intern if param.is_a? String if hash.include?(param) @config[param] = hash[param] @@ -303,7 +303,7 @@ class Puppet::SSLCertificates::CA raise Puppet::Error, "Certificate request for %s already exists" % host end - Puppet.config.writesub(:csrdir, csrfile) do |f| + Puppet.settings.writesub(:csrdir, csrfile) do |f| f.print csr.to_pem end end @@ -319,7 +319,7 @@ class Puppet::SSLCertificates::CA end Puppet::SSLCertificates::Inventory::add(cert) - Puppet.config.writesub(:signeddir, certfile) do |f| + Puppet.settings.writesub(:signeddir, certfile) do |f| f.print cert.to_pem end end @@ -389,7 +389,7 @@ class Puppet::SSLCertificates::CA @crl.next_update = now + 5 * 365*24*60*60 sign_with_key(@crl) - Puppet.config.write(:cacrl) do |f| + Puppet.settings.write(:cacrl) do |f| f.puts @crl.to_pem end end diff --git a/lib/puppet/sslcertificates/inventory.rb b/lib/puppet/sslcertificates/inventory.rb index d475c1c86..14d2155a8 100644 --- a/lib/puppet/sslcertificates/inventory.rb +++ b/lib/puppet/sslcertificates/inventory.rb @@ -11,7 +11,7 @@ module Puppet::SSLCertificates inited = false end - Puppet.config.write(:cert_inventory, "a") do |f| + Puppet.settings.write(:cert_inventory, "a") do |f| f.puts((inited ? nil : self.init).to_s + format(cert)) end end diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index e37a52038..c8d2e846b 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -44,7 +44,7 @@ module Puppet::SSLCertificates::Support unless instance_variable_get(var) unless cert = send(reader) cert = send(maker) - Puppet.config.write(param) { |f| f.puts cert.to_pem } + Puppet.settings.write(param) { |f| f.puts cert.to_pem } end instance_variable_set(var, cert) end @@ -59,7 +59,7 @@ module Puppet::SSLCertificates::Support # Our key meta programming can only handle one file, so we have # to separately write out the public key. - Puppet.config.write(:hostpubkey) do |f| + Puppet.settings.write(:hostpubkey) do |f| f.print key.public_key.to_pem end return key @@ -104,8 +104,8 @@ module Puppet::SSLCertificates::Support if cert.nil? or cert == "" return nil end - Puppet.config.write(:hostcert) do |f| f.print cert end - Puppet.config.write(:localcacert) do |f| f.print cacert end + Puppet.settings.write(:hostcert) do |f| f.print cert end + Puppet.settings.write(:localcacert) do |f| f.print cacert end #File.open(@certfile, "w", 0644) { |f| f.print cert } #File.open(@cacertfile, "w", 0644) { |f| f.print cacert } begin diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index 13bbc2af1..133aa9c2a 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -21,7 +21,7 @@ class Puppet::Util::Metric end def create(start = nil) - Puppet.config.use(:metrics) + Puppet.settings.use(:metrics) start ||= Time.now.to_i - 5 diff --git a/lib/puppet/util/config.rb b/lib/puppet/util/settings.rb index 4b6ae9e5b..f2af13dc2 100644 --- a/lib/puppet/util/config.rb +++ b/lib/puppet/util/settings.rb @@ -5,7 +5,7 @@ require 'getoptlong' # The class for handling configuration files. -class Puppet::Util::Config +class Puppet::Util::Settings include Enumerable include Puppet::Util @@ -502,7 +502,7 @@ class Puppet::Util::Config end bucket = Puppet::TransBucket.new - bucket.type = "Configuration" + bucket.type = "Settings" bucket.name = section bucket.push(*objects) bucket.keyword = "class" @@ -604,7 +604,7 @@ Generated on #{Time.now}. else topbucket.name = "top" end - topbucket.type = "Configuration" + topbucket.type = "Settings" topbucket.top = true # Now iterate over each section @@ -1190,7 +1190,7 @@ Generated on #{Time.now}. name = $1 unless @parent.include?(name) raise ArgumentError, - "Configuration parameter '%s' is undefined" % + "Settings parameter '%s' is undefined" % name end } diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb index cd41aa572..9e99057d9 100644 --- a/lib/puppet/util/storage.rb +++ b/lib/puppet/util/storage.rb @@ -46,7 +46,7 @@ class Puppet::Util::Storage self.init def self.load - Puppet.config.use(:main) + Puppet.settings.use(:main) unless File.exists?(Puppet[:statefile]) unless defined? @@state and ! @@state.nil? diff --git a/spec/unit/indirector/exec/node.rb b/spec/unit/indirector/exec/node.rb index 2eaf3c12e..47f4ce7a5 100755 --- a/spec/unit/indirector/exec/node.rb +++ b/spec/unit/indirector/exec/node.rb @@ -7,7 +7,7 @@ require 'puppet/indirector/exec/node' describe Puppet::Indirector::Exec::Node, " when constructing the command to run" do before do @indirection = mock 'indirection' - Puppet.config.stubs(:value).with(:external_nodes).returns("/echo") + Puppet.settings.stubs(:value).with(:external_nodes).returns("/echo") @searcher = Puppet::Indirector::Exec::Node.new end @@ -25,7 +25,7 @@ end describe Puppet::Indirector::Exec::Node, " when handling the results of the command" do before do @indirection = mock 'indirection' - Puppet.config.stubs(:value).with(:external_nodes).returns("/echo") + Puppet.settings.stubs(:value).with(:external_nodes).returns("/echo") @searcher = Puppet::Indirector::Exec::Node.new @node = stub 'node', :fact_merge => nil @name = "yay" diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb index b2320e0da..326b6b470 100755 --- a/spec/unit/indirector/indirection.rb +++ b/spec/unit/indirector/indirection.rb @@ -49,16 +49,16 @@ describe Puppet::Indirector::Indirection, " when choosing terminus types" do end it "should follow a convention on using per-model configuration parameters to determine the terminus class" do - Puppet.config.expects(:valid?).with('test_terminus').returns(true) - Puppet.config.expects(:value).with('test_terminus').returns(:foo) + Puppet.settings.expects(:valid?).with('test_terminus').returns(true) + Puppet.settings.expects(:value).with('test_terminus').returns(:foo) Puppet::Indirector::Terminus.expects(:terminus_class).with(:foo, :test).returns(@terminus_class) @indirection.terminus.should equal(@terminus) end it "should use a default system-wide configuration parameter parameter to determine the terminus class when no per-model configuration parameter is available" do - Puppet.config.expects(:valid?).with('test_terminus').returns(false) - Puppet.config.expects(:value).with(:default_terminus).returns(:foo) + Puppet.settings.expects(:valid?).with('test_terminus').returns(false) + Puppet.settings.expects(:value).with(:default_terminus).returns(:foo) Puppet::Indirector::Terminus.expects(:terminus_class).with(:foo, :test).returns(@terminus_class) @indirection.terminus.should equal(@terminus) end diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb index 339a2acfb..9e1d65e49 100755 --- a/spec/unit/indirector/yaml.rb +++ b/spec/unit/indirector/yaml.rb @@ -20,8 +20,8 @@ module YamlTesting @subject.name = :me @dir = "/what/ever" - Puppet.config.stubs(:use) - Puppet.config.stubs(:value).with(:yamldir).returns(@dir) + Puppet.settings.stubs(:use) + Puppet.settings.stubs(:value).with(:yamldir).returns(@dir) end end diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb index b37cc754d..8ba55f50c 100755 --- a/spec/unit/node/configuration.rb +++ b/spec/unit/node/configuration.rb @@ -305,7 +305,7 @@ describe Puppet::Node::Configuration, " when applying host configurations" do @config.apply end - after { Puppet.config.clear } + after { Puppet.settings.clear } end describe Puppet::Node::Configuration, " when applying non-host configurations" do @@ -328,7 +328,7 @@ describe Puppet::Node::Configuration, " when applying non-host configurations" d @config.apply end - after { Puppet.config.clear } + after { Puppet.settings.clear } end describe Puppet::Node::Configuration, " when creating a relationship graph" do @@ -467,6 +467,6 @@ describe Puppet::Node::Configuration, " when writing dot files" do end after do - Puppet.config.clear + Puppet.settings.clear end end diff --git a/spec/unit/node/node.rb b/spec/unit/node/node.rb index 53f362da6..3146f6e7e 100755 --- a/spec/unit/node/node.rb +++ b/spec/unit/node/node.rb @@ -66,7 +66,7 @@ describe Puppet::Node, " when returning the environment" do end it "should return the central environment if there is no environment fact nor explicit environment" do - Puppet.config.expects(:[]).with(:environment).returns(:centralenv) + Puppet.settings.expects(:[]).with(:environment).returns(:centralenv) @node.environment.should == :centralenv end @@ -81,7 +81,7 @@ describe Puppet::Node, " when returning the environment" do end it "should not use an explicit environment that is an empty string" do - Puppet.config.expects(:[]).with(:environment).returns(nil) + Puppet.settings.expects(:[]).with(:environment).returns(nil) @node.environment.should be_nil end end diff --git a/spec/unit/node/searching.rb b/spec/unit/node/searching.rb index b7105050a..e747996e4 100755 --- a/spec/unit/node/searching.rb +++ b/spec/unit/node/searching.rb @@ -74,6 +74,6 @@ describe Puppet::Node::Searching, " when searching for nodes" do end after do - Puppet.config.clear + Puppet.settings.clear end end diff --git a/spec/unit/other/modules.rb b/spec/unit/other/modules.rb index dbd091d9a..f53c43e89 100755 --- a/spec/unit/other/modules.rb +++ b/spec/unit/other/modules.rb @@ -26,7 +26,7 @@ describe Puppet::Module, " when building its search path" do end it "should use the environment-specific search path when a node environment is provided" do - Puppet.config.expects(:value).with(:modulepath, "myenv").returns("/mone:/mtwo") + Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/mone:/mtwo") File.stubs(:directory?).returns(true) Puppet::Module.modulepath("myenv").should == %w{/mone /mtwo} end @@ -82,30 +82,30 @@ describe Puppet::Module, " when searching for templates" do end it "should use the main templatedir if no module is found" do - Puppet.config.expects(:value).with(:templatedir, nil).returns("/my/templates") + Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates") Puppet::Module.expects(:find).with("mymod", nil).returns(nil) Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate" end it "should return unqualified templates directly in the template dir" do - Puppet.config.expects(:value).with(:templatedir, nil).returns("/my/templates") + Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates") Puppet::Module.expects(:find).never Puppet::Module.find_template("mytemplate").should == "/my/templates/mytemplate" end it "should use the environment templatedir if no module is found and an environment is specified" do - Puppet.config.expects(:value).with(:templatedir, "myenv").returns("/myenv/templates") + Puppet.settings.expects(:value).with(:templatedir, "myenv").returns("/myenv/templates") Puppet::Module.expects(:find).with("mymod", "myenv").returns(nil) Puppet::Module.find_template("mymod/mytemplate", "myenv").should == "/myenv/templates/mymod/mytemplate" end it "should use the node environment if specified" do - Puppet.config.expects(:value).with(:modulepath, "myenv").returns("/my/templates") + Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/templates") File.stubs(:directory?).returns(true) Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/templates/mymod/templates/envtemplate" end - after { Puppet.config.clear } + after { Puppet.settings.clear } end describe Puppet::Module, " when searching for manifests" do @@ -125,27 +125,27 @@ describe Puppet::Module, " when searching for manifests" do end it "should use the node environment if specified" do - Puppet.config.expects(:value).with(:modulepath, "myenv").returns("/env/modules") + Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/env/modules") File.stubs(:directory?).returns(true) Dir.expects(:glob).with("/env/modules/mymod/manifests/envmanifest.pp").returns(%w{/env/modules/mymod/manifests/envmanifest.pp}) Puppet::Module.find_manifests("mymod/envmanifest.pp", :environment => "myenv").should == ["/env/modules/mymod/manifests/envmanifest.pp"] end it "should return all manifests matching the glob pattern" do - Puppet.config.expects(:value).with(:modulepath, nil).returns("/my/modules") + Puppet.settings.expects(:value).with(:modulepath, nil).returns("/my/modules") File.stubs(:directory?).returns(true) Dir.expects(:glob).with("/my/modules/mymod/manifests/yay/*.pp").returns(%w{/one /two}) Puppet::Module.find_manifests("mymod/yay/*.pp").should == %w{/one /two} end it "should default to the 'init.pp' file in the manifests directory" do - Puppet.config.expects(:value).with(:modulepath, nil).returns("/my/modules") + Puppet.settings.expects(:value).with(:modulepath, nil).returns("/my/modules") File.stubs(:directory?).returns(true) Dir.expects(:glob).with("/my/modules/mymod/manifests/init.pp").returns(%w{my manifest}) Puppet::Module.find_manifests("mymod").should == %w{my manifest} end - after { Puppet.config.clear } + after { Puppet.settings.clear } end describe Puppet::Module, " when returning files" do diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb index c0f9d54b3..a79267b52 100755 --- a/spec/unit/parser/interpreter.rb +++ b/spec/unit/parser/interpreter.rb @@ -77,8 +77,8 @@ describe Puppet::Parser::Interpreter, " when creating parser instances" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - Puppet.config.stubs(:read_file).with(file).returns(text) - Puppet.config.parse(file) + Puppet.settings.stubs(:read_file).with(file).returns(text) + Puppet.settings.parse(file) parser1 = mock 'parser1' Puppet::Parser::Parser.expects(:new).with(:environment => :env1).returns(parser1) diff --git a/spec/unit/util/config.rb b/spec/unit/util/settings.rb index 8114acb8e..8d11737b3 100755 --- a/spec/unit/util/config.rb +++ b/spec/unit/util/settings.rb @@ -2,154 +2,154 @@ require File.dirname(__FILE__) + '/../../spec_helper' -describe Puppet::Util::Config, " when specifying defaults" do +describe Puppet::Util::Settings, " when specifying defaults" do before do - @config = Puppet::Util::Config.new + @settings = Puppet::Util::Settings.new end it "should start with no defined parameters" do - @config.params.length.should == 0 + @settings.params.length.should == 0 end it "should allow specification of default values associated with a section as an array" do - @config.setdefaults(:section, :myvalue => ["defaultval", "my description"]) + @settings.setdefaults(:section, :myvalue => ["defaultval", "my description"]) end it "should not allow duplicate parameter specifications" do - @config.setdefaults(:section, :myvalue => ["a", "b"]) - lambda { @config.setdefaults(:section, :myvalue => ["c", "d"]) }.should raise_error(ArgumentError) + @settings.setdefaults(:section, :myvalue => ["a", "b"]) + lambda { @settings.setdefaults(:section, :myvalue => ["c", "d"]) }.should raise_error(ArgumentError) end it "should allow specification of default values associated with a section as a hash" do - @config.setdefaults(:section, :myvalue => {:default => "defaultval", :desc => "my description"}) + @settings.setdefaults(:section, :myvalue => {:default => "defaultval", :desc => "my description"}) end it "should consider defined parameters to be valid" do - @config.setdefaults(:section, :myvalue => ["defaultval", "my description"]) - @config.valid?(:myvalue).should be_true + @settings.setdefaults(:section, :myvalue => ["defaultval", "my description"]) + @settings.valid?(:myvalue).should be_true end it "should require a description when defaults are specified with an array" do - lambda { @config.setdefaults(:section, :myvalue => ["a value"]) }.should raise_error(ArgumentError) + lambda { @settings.setdefaults(:section, :myvalue => ["a value"]) }.should raise_error(ArgumentError) end it "should require a description when defaults are specified with a hash" do - lambda { @config.setdefaults(:section, :myvalue => {:default => "a value"}) }.should raise_error(ArgumentError) + lambda { @settings.setdefaults(:section, :myvalue => {:default => "a value"}) }.should raise_error(ArgumentError) end it "should support specifying owner, group, and mode when specifying files" do - @config.setdefaults(:section, :myvalue => {:default => "/some/file", :owner => "blah", :mode => "boo", :group => "yay", :desc => "whatever"}) + @settings.setdefaults(:section, :myvalue => {:default => "/some/file", :owner => "blah", :mode => "boo", :group => "yay", :desc => "whatever"}) end it "should support specifying a short name" do - @config.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) + @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) end it "should fail when short names conflict" do - @config.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) - lambda { @config.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) }.should raise_error(ArgumentError) + @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) + lambda { @settings.setdefaults(:section, :myvalue => {:default => "w", :desc => "b", :short => "m"}) }.should raise_error(ArgumentError) end end -describe Puppet::Util::Config, " when setting values" do +describe Puppet::Util::Settings, " when setting values" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :main, :myval => ["val", "desc"] - @config.setdefaults :main, :bool => [true, "desc"] + @settings = Puppet::Util::Settings.new + @settings.setdefaults :main, :myval => ["val", "desc"] + @settings.setdefaults :main, :bool => [true, "desc"] end it "should provide a method for setting values from other objects" do - @config[:myval] = "something else" - @config[:myval].should == "something else" + @settings[:myval] = "something else" + @settings[:myval].should == "something else" end it "should support a getopt-specific mechanism for setting values" do - @config.handlearg("--myval", "newval") - @config[:myval].should == "newval" + @settings.handlearg("--myval", "newval") + @settings[:myval].should == "newval" end it "should support a getopt-specific mechanism for turning booleans off" do - @config.handlearg("--no-bool") - @config[:bool].should == false + @settings.handlearg("--no-bool") + @settings[:bool].should == false end it "should support a getopt-specific mechanism for turning booleans on" do # Turn it off first - @config[:bool] = false - @config.handlearg("--bool") - @config[:bool].should == true + @settings[:bool] = false + @settings.handlearg("--bool") + @settings[:bool].should == true end it "should clear the cache when setting getopt-specific values" do - @config.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"] - @config[:two].should == "whah yay" - @config.handlearg("--one", "else") - @config[:two].should == "else yay" + @settings.setdefaults :mysection, :one => ["whah", "yay"], :two => ["$one yay", "bah"] + @settings[:two].should == "whah yay" + @settings.handlearg("--one", "else") + @settings[:two].should == "else yay" end it "should not clear other values when setting getopt-specific values" do - @config[:myval] = "yay" - @config.handlearg("--no-bool") - @config[:myval].should == "yay" + @settings[:myval] = "yay" + @settings.handlearg("--no-bool") + @settings[:myval].should == "yay" end it "should call passed blocks when values are set" do values = [] - @config.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }}) + @settings.setdefaults(:section, :hooker => {:default => "yay", :desc => "boo", :hook => lambda { |v| values << v }}) values.should == [] - @config[:hooker] = "something" + @settings[:hooker] = "something" values.should == %w{something} end it "should munge values using the element-specific methods" do - @config[:bool] = "false" - @config[:bool].should == false + @settings[:bool] = "false" + @settings[:bool].should == false end it "should prefer cli values to values set in Ruby code" do - @config.handlearg("--myval", "cliarg") - @config[:myval] = "memarg" - @config[:myval].should == "cliarg" + @settings.handlearg("--myval", "cliarg") + @settings[:myval] = "memarg" + @settings[:myval].should == "cliarg" end end -describe Puppet::Util::Config, " when returning values" do +describe Puppet::Util::Settings, " when returning values" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"], :four => ["$two $three FOUR", "d"] + @settings = Puppet::Util::Settings.new + @settings.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"], :four => ["$two $three FOUR", "d"] end it "should provide a mechanism for returning set values" do - @config[:one] = "other" - @config[:one].should == "other" + @settings[:one] = "other" + @settings[:one].should == "other" end it "should interpolate default values for other parameters into returned parameter values" do - @config[:one].should == "ONE" - @config[:two].should == "ONE TWO" - @config[:three].should == "ONE ONE TWO THREE" + @settings[:one].should == "ONE" + @settings[:two].should == "ONE TWO" + @settings[:three].should == "ONE ONE TWO THREE" end it "should interpolate default values that themselves need to be interpolated" do - @config[:four].should == "ONE TWO ONE ONE TWO THREE FOUR" + @settings[:four].should == "ONE TWO ONE ONE TWO THREE FOUR" end it "should interpolate set values for other parameters into returned parameter values" do - @config[:one] = "on3" - @config[:two] = "$one tw0" - @config[:three] = "$one $two thr33" - @config[:four] = "$one $two $three f0ur" - @config[:one].should == "on3" - @config[:two].should == "on3 tw0" - @config[:three].should == "on3 on3 tw0 thr33" - @config[:four].should == "on3 on3 tw0 on3 on3 tw0 thr33 f0ur" + @settings[:one] = "on3" + @settings[:two] = "$one tw0" + @settings[:three] = "$one $two thr33" + @settings[:four] = "$one $two $three f0ur" + @settings[:one].should == "on3" + @settings[:two].should == "on3 tw0" + @settings[:three].should == "on3 on3 tw0 thr33" + @settings[:four].should == "on3 on3 tw0 on3 on3 tw0 thr33 f0ur" end it "should not cache interpolated values such that stale information is returned" do - @config[:two].should == "ONE TWO" - @config[:one] = "one" - @config[:two].should == "one TWO" + @settings[:two].should == "ONE TWO" + @settings[:one] = "one" + @settings[:two].should == "one TWO" end it "should not cache values such that information from one environment is returned for another environment" do @@ -157,31 +157,31 @@ describe Puppet::Util::Config, " when returning values" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) - @config.value(:one, "env1").should == "oneval" - @config.value(:one, "env2").should == "twoval" + @settings.value(:one, "env1").should == "oneval" + @settings.value(:one, "env2").should == "twoval" end it "should have a name determined by the 'name' parameter" do - @config.setdefaults(:whatever, :name => ["something", "yayness"]) - @config.name.should == :something - @config[:name] = :other - @config.name.should == :other + @settings.setdefaults(:whatever, :name => ["something", "yayness"]) + @settings.name.should == :something + @settings[:name] = :other + @settings.name.should == :other end end -describe Puppet::Util::Config, " when choosing which value to return" do +describe Puppet::Util::Settings, " when choosing which value to return" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :section, + @settings = Puppet::Util::Settings.new + @settings.setdefaults :section, :one => ["ONE", "a"], :name => ["myname", "w"] end it "should return default values if no values have been set" do - @config[:one].should == "ONE" + @settings[:one].should == "ONE" end it "should return values set on the cli before values set in the configuration file" do @@ -189,17 +189,17 @@ describe Puppet::Util::Config, " when choosing which value to return" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:parse_file).returns(text) - @config.handlearg("--one", "clival") - @config.parse(file) + @settings.stubs(:parse_file).returns(text) + @settings.handlearg("--one", "clival") + @settings.parse(file) - @config[:one].should == "clival" + @settings[:one].should == "clival" end it "should return values set on the cli before values set in Ruby" do - @config[:one] = "rubyval" - @config.handlearg("--one", "clival") - @config[:one].should == "clival" + @settings[:one] = "rubyval" + @settings.handlearg("--one", "clival") + @settings[:one].should == "clival" end it "should return values set in the executable-specific section before values set in the main section" do @@ -207,10 +207,10 @@ describe Puppet::Util::Config, " when choosing which value to return" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) - @config[:one].should == "nameval" + @settings[:one].should == "nameval" end it "should not return values outside of its search path" do @@ -219,9 +219,9 @@ describe Puppet::Util::Config, " when choosing which value to return" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) - @config[:one].should == "ONE" + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:one].should == "ONE" end it "should return values in a specified environment" do @@ -230,9 +230,9 @@ describe Puppet::Util::Config, " when choosing which value to return" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) - @config.value(:one, "env").should == "envval" + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) + @settings.value(:one, "env").should == "envval" end it "should return values in a specified environment before values in the main or name sections" do @@ -241,16 +241,16 @@ describe Puppet::Util::Config, " when choosing which value to return" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/whatever") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) - @config.value(:one, "env").should == "envval" + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) + @settings.value(:one, "env").should == "envval" end end -describe Puppet::Util::Config, " when parsing its configuration" do +describe Puppet::Util::Settings, " when parsing its configuration" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] + @settings = Puppet::Util::Settings.new + @settings.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] end it "should return values set in the configuration file" do @@ -258,22 +258,22 @@ describe Puppet::Util::Config, " when parsing its configuration" do one = fileval " file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:one].should == "fileval" + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:one].should == "fileval" end #484 - this should probably be in the regression area it "should not throw an exception on unknown parameters" do text = "[main]\nnosuchparam = mval\n" file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - lambda { @config.parse(file) }.should_not raise_error + @settings.expects(:read_file).with(file).returns(text) + lambda { @settings.parse(file) }.should_not raise_error end it "should support an old parse method when per-executable configuration files still exist" do # I'm not going to bother testing this method. - @config.should respond_to(:old_parse) + @settings.should respond_to(:old_parse) end it "should convert booleans in the configuration file into Ruby booleans" do @@ -282,10 +282,10 @@ describe Puppet::Util::Config, " when parsing its configuration" do two = false " file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:one].should == true - @config[:two].should == false + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:one].should == true + @settings[:two].should == false end it "should convert integers in the configuration file into Ruby Integers" do @@ -293,42 +293,42 @@ describe Puppet::Util::Config, " when parsing its configuration" do one = 65 " file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:one].should == 65 + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:one].should == 65 end it "should support specifying file all metadata (owner, group, mode) in the configuration file" do - @config.setdefaults :section, :myfile => ["/myfile", "a"] + @settings.setdefaults :section, :myfile => ["/myfile", "a"] text = "[main] myfile = /other/file {owner = luke, group = luke, mode = 644} " file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:myfile].should == "/other/file" - @config.metadata(:myfile).should == {:owner => "luke", :group => "luke", :mode => "644"} + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:myfile].should == "/other/file" + @settings.metadata(:myfile).should == {:owner => "luke", :group => "luke", :mode => "644"} end it "should support specifying file a single piece of metadata (owner, group, or mode) in the configuration file" do - @config.setdefaults :section, :myfile => ["/myfile", "a"] + @settings.setdefaults :section, :myfile => ["/myfile", "a"] text = "[main] myfile = /other/file {owner = luke} " file = "/some/file" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:myfile].should == "/other/file" - @config.metadata(:myfile).should == {:owner => "luke"} + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:myfile].should == "/other/file" + @settings.metadata(:myfile).should == {:owner => "luke"} end end -describe Puppet::Util::Config, " when reparsing its configuration" do +describe Puppet::Util::Settings, " when reparsing its configuration" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] + @settings = Puppet::Util::Settings.new + @settings.setdefaults :section, :one => ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"] end it "should replace in-memory values with on-file values" do @@ -337,8 +337,8 @@ describe Puppet::Util::Config, " when reparsing its configuration" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/test/file") - @config[:one] = "init" - @config.file = file + @settings[:one] = "init" + @settings.file = file # Now replace the value text = "[main]\none = disk-replace\n" @@ -346,21 +346,21 @@ describe Puppet::Util::Config, " when reparsing its configuration" do # This is kinda ridiculous - the reason it parses twice is that # it goes to parse again when we ask for the value, because the # mock always says it should get reparsed. - @config.expects(:read_file).with(file).returns(text).times(2) - @config.reparse - @config[:one].should == "disk-replace" + @settings.expects(:read_file).with(file).returns(text).times(2) + @settings.reparse + @settings[:one].should == "disk-replace" end it "should retain parameters set by cli when configuration files are reparsed" do - @config.handlearg("--one", "clival") + @settings.handlearg("--one", "clival") text = "[main]\none = on-disk\n" file = mock 'file' file.stubs(:file).returns("/test/file") - @config.stubs(:read_file).with(file).returns(text) - @config.parse(file) + @settings.stubs(:read_file).with(file).returns(text) + @settings.parse(file) - @config[:one].should == "clival" + @settings[:one].should == "clival" end it "should remove in-memory values that are no longer set in the file" do @@ -369,30 +369,30 @@ describe Puppet::Util::Config, " when reparsing its configuration" do file = mock 'file' file.stubs(:changed?).returns(true) file.stubs(:file).returns("/test/file") - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - @config[:one].should == "disk-init" + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + @settings[:one].should == "disk-init" # Now replace the value text = "[main]\ntwo = disk-replace\n" - @config.expects(:read_file).with(file).returns(text) - @config.parse(file) - #@config.reparse + @settings.expects(:read_file).with(file).returns(text) + @settings.parse(file) + #@settings.reparse # The originally-overridden value should be replaced with the default - @config[:one].should == "ONE" + @settings[:one].should == "ONE" # and we should now have the new value in memory - @config[:two].should == "disk-replace" + @settings[:two].should == "disk-replace" end end -describe Puppet::Util::Config, " when being used to manage the host machine" do +describe Puppet::Util::Settings, " when being used to manage the host machine" do before do - @config = Puppet::Util::Config.new - @config.setdefaults :main, :maindir => ["/maindir", "a"], :seconddir => ["/seconddir", "a"] - @config.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "luke", :group => "johnny", :mode => 0755} - @config.setdefaults :files, :myfile => {:default => "/myfile", :desc => "a", :mode => 0755} + @settings = Puppet::Util::Settings.new + @settings.setdefaults :main, :maindir => ["/maindir", "a"], :seconddir => ["/seconddir", "a"] + @settings.setdefaults :other, :otherdir => {:default => "/otherdir", :desc => "a", :owner => "luke", :group => "johnny", :mode => 0755} + @settings.setdefaults :files, :myfile => {:default => "/myfile", :desc => "a", :mode => 0755} end it "should provide a method that writes files with the correct modes" do @@ -402,20 +402,20 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do it "should provide a method that creates directories with the correct modes" do Puppet::Util::SUIDManager.expects(:asuser).with("luke", "johnny").yields Dir.expects(:mkdir).with("/otherdir", 0755) - @config.mkdir(:otherdir) + @settings.mkdir(:otherdir) end it "should be able to create needed directories in a single section" do Dir.expects(:mkdir).with("/maindir") Dir.expects(:mkdir).with("/seconddir") - @config.use(:main) + @settings.use(:main) end it "should be able to create needed directories in multiple sections" do Dir.expects(:mkdir).with("/maindir") Dir.expects(:mkdir).with("/otherdir", 0755) Dir.expects(:mkdir).with("/seconddir") - @config.use(:main, :other) + @settings.use(:main, :other) end it "should provide a method to trigger enforcing of file modes on existing files and directories" do @@ -433,7 +433,7 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do Puppet.features.stubs(:root?).returns(true) File.stubs(:exist?).with("/myfile").returns(true) trans = nil - trans = @config.to_transportable + trans = @settings.to_transportable resources = [] trans.delve { |obj| resources << obj if obj.is_a? Puppet::TransObject } %w{/maindir /seconddir /otherdir /myfile}.each do |path| @@ -459,7 +459,7 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do it "should not try to manage user or group when not running as root" do Puppet.features.stubs(:root?).returns(false) trans = nil - trans = @config.to_transportable(:other) + trans = @settings.to_transportable(:other) trans.delve do |obj| next unless obj.is_a?(Puppet::TransObject) obj[:owner].should be_nil @@ -469,10 +469,10 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do it "should add needed users and groups to the manifest when asked" do # This is how we enable user/group management - @config.setdefaults :main, :mkusers => [true, "w"] + @settings.setdefaults :main, :mkusers => [true, "w"] Puppet.features.stubs(:root?).returns(false) trans = nil - trans = @config.to_transportable(:other) + trans = @settings.to_transportable(:other) resources = [] trans.delve { |obj| resources << obj if obj.is_a? Puppet::TransObject and obj.type != "file" } @@ -496,7 +496,7 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do # Make it think we're root so it tries to manage user and group. Puppet.features.stubs(:root?).returns(true) trans = nil - trans = @config.to_transportable + trans = @settings.to_transportable file = nil trans.delve { |obj| file = obj if obj.name == "/myfile" } file.should be_nil @@ -518,18 +518,18 @@ describe Puppet::Util::Config, " when being used to manage the host machine" do Puppet::Util::Storage.expects(:store).never Puppet::Util::Storage.expects(:load).never Dir.expects(:mkdir).with("/maindir") - @config.use(:main) + @settings.use(:main) end it "should convert all relative paths to fully-qualified paths (#795)" do - @config[:myfile] = "unqualified" + @settings[:myfile] = "unqualified" dir = Dir.getwd - @config[:myfile].should == File.join(dir, "unqualified") + @settings[:myfile].should == File.join(dir, "unqualified") end it "should support a method for re-using all currently used sections" do - Dir.expects(:mkdir).with(@config[:otherdir], 0755).times(2) - @config.use(:other) - @config.reuse + Dir.expects(:mkdir).with(@settings[:otherdir], 0755).times(2) + @settings.use(:other) + @settings.reuse end end diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb index fb1611d7f..3d863dc27 100755 --- a/test/certmgr/certmgr.rb +++ b/test/certmgr/certmgr.rb @@ -239,13 +239,13 @@ class TestCertMgr < Test::Unit::TestCase ca.revoke(h1.serial) - oldcert = File.read(Puppet.config[:cacert]) - oldserial = File.read(Puppet.config[:serial]) + oldcert = File.read(Puppet.settings[:cacert]) + oldserial = File.read(Puppet.settings[:serial]) # Recreate the CA from disk ca = mkCA() - newcert = File.read(Puppet.config[:cacert]) - newserial = File.read(Puppet.config[:serial]) + newcert = File.read(Puppet.settings[:cacert]) + newserial = File.read(Puppet.settings[:serial]) assert_equal(oldcert, newcert, "The certs are not equal after making a new CA.") assert_equal(oldserial, newserial, "The serials are not equal after making a new CA.") store = mkStore(ca) diff --git a/test/certmgr/inventory.rb b/test/certmgr/inventory.rb index 15d3e5217..9efcb0c09 100755 --- a/test/certmgr/inventory.rb +++ b/test/certmgr/inventory.rb @@ -56,8 +56,8 @@ class TestCertInventory < Test::Unit::TestCase file.expects(:puts).with do |written| written.include? cert.subject.to_s end - Puppet::Util::Config.any_instance.stubs(:write) - Puppet::Util::Config.any_instance.expects(:write). + Puppet::Util::Settings.any_instance.stubs(:write) + Puppet::Util::Settings.any_instance.expects(:write). with(:cert_inventory, 'a').yields(file) Puppet::SSLCertificates::Inventory.add(cert) diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 33e3b2daf..021d6d1de 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -154,7 +154,7 @@ module PuppetTest $group = nonrootgroup().gid.to_s end - Puppet.config.clear + Puppet.settings.clear Puppet[:user] = $user Puppet[:group] = $group @@ -264,7 +264,7 @@ module PuppetTest Puppet::Type.allclear Puppet::Util::Storage.clear Puppet.clear - Puppet.config.clear + Puppet.settings.clear Puppet::Indirector::Indirection.clear_cache @memoryatend = Puppet::Util.memory diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb index 00ed7413a..511b6fcaa 100755 --- a/test/network/client/ca.rb +++ b/test/network/client/ca.rb @@ -23,7 +23,7 @@ class TestClientCA < Test::Unit::TestCase end [:hostprivkey, :hostcert, :localcacert].each do |name| - assert(FileTest.exists?(Puppet.config[name]), + assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert %s" % name) end end diff --git a/test/network/client/client.rb b/test/network/client/client.rb index 93c63d637..382cd55cf 100755 --- a/test/network/client/client.rb +++ b/test/network/client/client.rb @@ -113,9 +113,9 @@ class TestClient < Test::Unit::TestCase # Create a new ssl root. confdir = tempfile() Puppet[:ssldir] = confdir - Puppet.config.mkdir(:ssldir) - Puppet.config.clearused - Puppet.config.use(:ssl, :ca) + Puppet.settings.mkdir(:ssldir) + Puppet.settings.clearused + Puppet.settings.use(:ssl, :ca) mkserver diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 2e9ed2752..169a1de5f 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -680,7 +680,7 @@ end client.apply # Make sure the config is not cached. - config = Puppet.config[:localconfig] + ".yaml" + config = Puppet.settings[:localconfig] + ".yaml" assert(! File.exists?(config), "Cached an invalid configuration") end end diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index df946fa33..4f8e7fab2 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -75,7 +75,7 @@ class TestMaster < Test::Unit::TestCase assert(! client.fresh?(facts), "Client is incorrectly up to date") - Puppet.config.use(:main) + Puppet.settings.use(:main) config = nil assert_nothing_raised { config = client.getconfig diff --git a/test/other/report.rb b/test/other/report.rb index 7499c51e2..3de2dfbee 100755 --- a/test/other/report.rb +++ b/test/other/report.rb @@ -86,7 +86,7 @@ class TestReports < Test::Unit::TestCase # We have to reuse reporting here because of something going on in the # server/report.rb file - Puppet.config.use(:reporting) + Puppet.settings.use(:reporting) 3.times { |i| log = Puppet.warning("Report test message %s" % i) @@ -113,7 +113,7 @@ class TestReports < Test::Unit::TestCase if Puppet.features.rrd? def test_rrdgraph_report - Puppet.config.use(:metrics) + Puppet.settings.use(:metrics) report = mkreport assert(! report.metrics.empty?, "Did not receive any metrics") diff --git a/test/puppet/conffiles.rb b/test/puppet/conffiles.rb index 3dfa53a13..1800c80f6 100755 --- a/test/puppet/conffiles.rb +++ b/test/puppet/conffiles.rb @@ -3,7 +3,6 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppettest' -require 'puppet/util/config' class TestConfFiles < Test::Unit::TestCase include PuppetTest @@ -72,7 +71,7 @@ class TestConfFiles < Test::Unit::TestCase path = tempfile() sampledata { |data| - config = Puppet::Util::Config.new + config = Puppet::Util::Settings.new data.each { |section, hash| hash.each { |param, value| config.setdefaults(section, param => [value, value]) @@ -100,7 +99,7 @@ class TestConfFiles < Test::Unit::TestCase # that the default config is free of simple typos etc. def test_genconfig assert_nothing_raised { - Puppet::config::to_config + Puppet::settings::to_config } end diff --git a/test/util/config.rb b/test/util/settings.rb index cbd02b4f9..62f34fda6 100755 --- a/test/util/config.rb +++ b/test/util/settings.rb @@ -4,14 +4,14 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'mocha' require 'puppettest' -require 'puppet/util/config' +require 'puppet/util/settings' require 'puppettest/parsertesting' -class TestConfig < Test::Unit::TestCase +class TestSettings < Test::Unit::TestCase include PuppetTest include PuppetTest::ParserTesting - CElement = Puppet::Util::Config::CElement - CBoolean = Puppet::Util::Config::CBoolean + CElement = Puppet::Util::Settings::CElement + CBoolean = Puppet::Util::Settings::CBoolean def setup super @@ -95,7 +95,7 @@ class TestConfig < Test::Unit::TestCase def mkconfig c = nil assert_nothing_raised { - c = Puppet::Util::Config.new + c = Puppet::Util::Settings.new } return c end @@ -768,15 +768,15 @@ yay = /a/path } assert_equal("http://yayness/rahness", val, - "Config got messed up") + "Settings got messed up") end def test_correct_type_assumptions config = mkconfig - file = Puppet::Util::Config::CFile - element = Puppet::Util::Config::CElement - bool = Puppet::Util::Config::CBoolean + file = Puppet::Util::Settings::CFile + element = Puppet::Util::Settings::CElement + bool = Puppet::Util::Settings::CBoolean # We have to keep these ordered, unfortunately. [ |