summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Code smell: Inconsistent indentation and related formatting issuesMarkus Roberts2010-07-09385-5642/+6801
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 163 occurances of defined\? +([@a-zA-Z_.0-9?=]+) with defined?(\1) This makes detecting subsequent patterns easier. 3 Examples: The code: if ! defined? @parse_config becomes: if ! defined?(@parse_config) The code: return @option_parser if defined? @option_parser becomes: return @option_parser if defined?(@option_parser) The code: if defined? @local and @local becomes: if defined?(@local) and @local * Eliminate trailing spaces. Replaced 428 occurances of ^(.*?) +$ with \1 1 file was skipped. test/ral/providers/host/parsed.rb because 0 * Replace leading tabs with an appropriate number of spaces. Replaced 306 occurances of ^(\t+)(.*) with Tabs are not consistently expanded in all environments. * Don't arbitrarily wrap on sprintf (%) operator. Replaced 143 occurances of (.*['"] *%) +(.*) with Splitting the line does nothing to aid clarity and hinders further refactorings. 3 Examples: The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] * Don't break short arrays/parameter list in two. Replaced 228 occurances of (.*) +(.*) with 3 Examples: The code: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) becomes: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) The code: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) becomes: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) The code: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") becomes: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") * If arguments must wrap, treat them all equally Replaced 510 occurances of lines ending in things like ...(foo, or ...(bar(1,3), with \1 \2 3 Examples: The code: midscope.to_hash(false), becomes: assert_equal( The code: botscope.to_hash(true), becomes: # bottomscope, then checking that we see the right stuff. The code: :path => link, becomes: * Replaced 4516 occurances of ^( *)(.*) with The present code base is supposed to use four-space indentation. In some places we failed to maintain that standard. These should be fixed regardless of the 2 vs. 4 space question. 15 Examples: The code: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc becomes: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc The code: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( becomes: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( The code: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } becomes: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } The code: #passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } becomes: # passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } The code: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") becomes: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") The code: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", becomes: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", The code: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do becomes: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do The code: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') becomes: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') The code: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) becomes: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) The code: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") becomes: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") The code: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } becomes: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } The code: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid becomes: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid The code: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' becomes: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' The code: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs becomes: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs The code: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element| becomes: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element|
* Code smell: Miscellaneous oddity removalMarkus Roberts2010-07-092-2/+2
| | | | | | | | * Changed "string = self[1].gsub(%r((?:\\\\[\\\\bfnrt\"/]|(?:\\\\u(?:[A-Fa-f\\d]{4}))+|\\\\[\\x20-\\xff]))n) do |c|" to "string = self[1].gsub(%r{(?:\\\\[\\\\bfnrt\"/]|(?:\\\\u(?:[A-Fa-f\\d]{4}))+|\\\\[\\x20-\\xff])}n) do |c|" in lib/puppet/external/pson/pure/parser.rb * * Changed "\"$\"" to "'$'" in lib/puppet/provider/augeas/augeas.rb
* Code smell: Win32 --> MS_windowsMarkus Roberts2010-07-0913-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 12 occurances of Win32 with Microsoft Windows 3 Examples: The code: # and all .rb files in lib/. This is disabled by default on Win32. becomes: # and all .rb files in lib/. This is disabled by default on Microsoft Windows. The code: # We can use Win32 functions becomes: # We can use Microsoft Windows functions The code: desc "Uses Win32 functionality to manage file's users and rights." becomes: desc "Uses Microsoft Windows functionality to manage file's users and rights." * Replaced 10 occurances of :win32 with :microsoft_windows 3 Examples: The code: Puppet.features.add(:win32, :libs => ["sys/admin", "win32/process", "win32/dir"]) becomes: Puppet.features.add(:microsoft_windows, :libs => ["sys/admin", "win32/process", "win32/dir"]) The code: Puppet::Type.type(:file).provide :win32 do becomes: Puppet::Type.type(:file).provide :microsoft_windows do The code: confine :feature => :win32 becomes: confine :feature => :microsoft_windows * Replaced 13 occurances of win32\? with microsoft_windows? 3 Examples: The code: signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs }) unless Puppet.features.win32? becomes: signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs }) unless Puppet.features.microsoft_windows? The code: raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.win32? becomes: raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? The code: require 'sys/admin' if Puppet.features.win32? becomes: require 'sys/admin' if Puppet.features.microsoft_windows?
* Updated GPG rake signing task for new Puppet Labs keyJames Turnbull2010-07-091-3/+3
|
* [#4182] show_diff was broken for streamed file contentsJesse Wolfe2010-07-092-3/+20
| | | | | | | | | show_diff was written assuming that a file's contents would be loaded into memory. That's no longer true, for perfomance reasons. This patch streams the file to a temporary file to take the diff. As a consequence, it means that when show_diff is on, files may get streamed twice.
* Fix for #4117 "Storing newly-audited value" messagesMarkus Roberts2010-07-092-2/+2
| | | | They're semantically info, not notifications, and now are handled as such.
* Manifests with variables were broken when read from STDIN to puppet applyJesse Wolfe2010-07-091-0/+5
| | | | | Because the new settings scope was trying to interpolate the "code" string, causing strange failures.
* Use the name in the search path for looking for metadataBryan Kearney2010-07-091-0/+1
|
* maint:rename resource_type to define in internal dslMarkus Roberts2010-07-092-2/+2
| | | | That's it. Now its got the same name internal or external.
* [#4198] Require 'fileutils' everywhere FileUtils is usedJesse Wolfe2010-07-095-0/+5
|
* [#4196] Move the docs into the source directory structureJesse Wolfe2010-07-0921-885/+914
| | | | | | Since it is no longer possible to find the running executable from the call stack, docs have to be kept somewhere in the source tree. Of course, at this point, we shouldn't be using RDoc::Usage at all.
* Fix for #4178 - generalize autoloading to include .rbLuke Kanies2010-07-096-45/+29
| | | | | | | | | | This mostly modifies autoloading to look for files ending in either 'pp' or 'rb' using Dir globing with {,.pp,.rb} or .{pp,rb} as appropriate. It could easily be extended to add support for other formats (e.g. xml) by adding them to the globs (though, if this were to be done often, having a centralized list of supported extensions would be a good (and easy) refactor). Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* [#3582] Remove assumption that Puppet.settings would return values of a ↵Jesse Wolfe2010-07-091-8/+8
| | | | | | | | | consistent type Currently, we cannot trust Puppet::Util::Settings to return values of any particular type for a given setting. This patch makes sure that we explicitly cast to string when checking for empty values.
* [#4180] Support legacy module structureJesse Wolfe2010-07-092-1/+4
| | | | | This patch updates the earlier #4180 patches to support both the old and the new module structures.
* Update RDoc parser to reflect change of custom plugin and fact locationsJames Turnbull2010-07-092-4/+4
|
* Fixed #4180 - Updated old module structure to match correct defaultJames Turnbull2010-07-092-3/+3
| | | | Thanks to Daniel Grafe for the patch
* [#2730] mount ensure present shouldn't unmountJesse Wolfe2010-07-092-16/+78
| | | | | | | | | Ensuring "defined" on a mount just demands that the entry appears in the fstab file. Ensure "present" is now an alias for ensure "defined", so drives are no longer unmounted unless the resource is set to ensure "unmounted" This patch is based on a patch submitted by Aurelien Degremont.
* Fixed subscribe exampleJames Turnbull2010-07-091-1/+1
|
* Fix for environments in startup script.Ken Barber2010-07-091-9/+9
| | | | | | | | - Dropped the forced --manifest switch in the suse startup script to allow for environments to re-define this. Otherwise, environments will not work as puppet override configuration with command line arguments.
* Redmine: 2474 - Fix for mount fstype documentationSteven Jenkins2010-07-091-1/+1
|
* Fix for #4137 -- Oracle needs text for strings > 255Markus Roberts2010-07-081-1/+1
| | | | | | Oracle has a maximum VARCHAR (string) column length of 255 characters. Any column that is larger than 255 characters needs to be cast as a :text column instead of :string.
* Fix for #2807 Puppet settings available as variablesMarkus Roberts2010-07-072-1/+22
| | | | | | | This is Luke's patch plus a change to fix a test that it broke. It creates a new sub-scope off the top scope, called "settings" and adds each of the environment's settings to it as variables, thus satisfying the ticket while taking us one step further from being able to implement futures. *sigh*
* [#4161] RDoc fails to parse some of our ruby syntaxJesse Wolfe2010-07-072-0/+12
| | | | | | | | RDoc's parser produces errors on this sort of statement: def (variable).method This patch wraps our occurances of those definitions with comments that suspend RDoc parsing.
* [#3169] Adds more debugging to SSL cert verificationNick Lewis2010-07-071-0/+14
| | | | | This patch (via Nicholas Veeser) adds more debugging when SSL cert verification fails.
* Fix for #4167 -- overriding file permissions in conf fileMarkus Roberts2010-07-072-1/+2
| | | | | The logic which iterates over the searchpath in reverse does not translate the name. Therefore file overrides in :master or :agent are not picked up.
* [#4114] Fixes test failures caused by previous 4114 fixesNick Lewis2010-07-072-1/+2
| | | | | An array was being used as a hash index, and still being pushed to, making Log::close fail to find and close it.
* saving work for my unit tests. The redhat one still fails...Dan Bode2010-07-073-3/+75
| | | | | | [4123] [4124] - combined unit test for both fixes since they share some common code. proper unit tests to verify features for both patches.
* [4123] - allows self.instances to correctly report state of services.Dan Bode2010-07-072-2/+3
| | | | | | Added hasstatus => true as attribute for new provider instance in init. redhat checks the hasstatus in the provider to determine service status.
* created init provider method self.get_services which accepts an array of ↵Dan Bode2010-07-072-3/+11
| | | | | | | | filenames to exclude when processing defpath. also updated redhat provider to pass in a list of services to ignore. didnt need to munch exclude to an array, include? is safe to call on strings
* [#4114] Fix failures in the unit testsMatt Robinson2010-07-076-27/+16
| | | | | | The initial commit changed the name of a method (close -> close_all) and changed the way the array log destination worked before we saw that the unit tests were using it differently.
* [#4114] Added queueing to the logNick Lewis2010-07-074-30/+65
| | | | | The log will now queue any log messages created when there is no destination, and will flush the queue when a destination is added.
* [#4110] Wrap Type#retrieve calls for backwards compatibilityJesse Wolfe2010-07-076-13/+19
| | | | | | | | This patch introduces Type#retrieve_resource as a wrapper for Type#resource, to coerce the return value from legacy types from Hash to Resource. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Fix for #4120 No namevar running puppet doc -r typeMarkus Roberts2010-07-071-2/+2
| | | | Reworked it to use the new key_attributes instead.
* [#2370] Allow OpenBSD to add packages with versions and flavorsMatt Robinson2010-07-062-9/+43
| | | | This patch is from Joe McDonagh <joseph.e.mcdonagh@gmail.com>
* [#4108] Changed missing Application constant errorNick Lewis2010-07-061-1/+1
| | | | | Changed the error message when searching for an Application constant which is undefined.
* [#4149] Don't create two Resource::TypeCollectionsJesse Wolfe2010-07-062-2/+2
| | | | | | By asking the environment for known resources instead of creating a type collection ourselves, we avoid accidentally creating two Resource::TypeCollection objects.
* [#3906] Fixed missing constant Puppet::Rails when using storeconfigsNick Lewis2010-07-062-5/+1
| | | | | | The hook for storeconfig will now require 'puppet/rails' if the setting is set to true. It was previously being indirectly required via parser/interpreter, which was removed.
* [#4136] Specs should listen on localhostJesse Wolfe2010-07-063-5/+8
| | | | | | This patch prevents specs from opening IP ports to the world. Some specs had to be adjusted to unset this setting so they could test the non-spec default value.
* [#3961] Part two: --destroy should also be localJesse Wolfe2010-07-062-1/+19
|
* Fix for #4148 (2.6 is greater than 0.25.x)Markus Roberts2010-07-061-1/+1
| | | | | We had a hardcoded assumption that the version number would always start with a zero, and thus were failing to recognise 2.6.0 as greater than 0.25.x
* Fix for #4142 stray use of JSON instead of PSONMarkus Roberts2010-07-061-1/+1
| | | | Somehow one use of JSON escaped the global find and replace of PSON --> JSON.
* [#3172] Fix the arguments to Application::Kick.new, which I had brokenJesse Wolfe2010-07-022-1/+8
|
* Maint: Explicitly put test sqlite files in a temp directoryJesse Wolfe2010-07-021-0/+6
| | | | | A spec was failing because it didn't know where to put a temporary sqlite database file
* maint: fix stub failure in report_spec.rbJesse Wolfe2010-07-021-0/+3
| | | | | Puppet::Util::Storage was trying to create state.yaml during an unrelated spec.
* maint: fix stub failures in report_spec.rbJesse Wolfe2010-07-022-1/+4
| | | | | Puppet::Util::Storage was trying to create state.yaml during unrelated specs.
* maint: fix stubbing in package_spec.rbJesse Wolfe2010-07-021-148/+153
| | | | | Puppet::Util::Storage was trying to create state.yaml during unrelated specs.
* maint: fix stubs in transaction_spec.rbJesse Wolfe2010-07-021-0/+4
| | | | | Puppet::Util::Storage was trying to create state.yaml during unrelated specs.
* maint: fix stubbing in catalog_spec.rbJesse Wolfe2010-07-021-0/+4
| | | | | Puppet::Util::Storage was trying to create state.yaml during unrelated specs.
* Maint: Improve the speed of setting settings.Nick Lewis2010-07-021-12/+19
| | | | | Our settings were slow because I was querying Application objects for their run_mode repetitively
* maint: file_spec heisenbugsJesse Wolfe2010-07-021-0/+7
| | | | | Puppet::Util::Storage was trying to create state.yaml during unrelated specs.