summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '2.7.x'Nick Lewis2011-08-241-10/+22
|\ | | | | | | | | | | | | | | | | | | Conflicts: lib/puppet/feature/base.rb lib/puppet/file_serving/configuration.rb spec/unit/indirector/ssl_file_spec.rb spec/unit/parser/functions/extlookup_spec.rb spec/unit/resource/catalog_spec.rb test/language/ast/variable.rb
| * Maint: Fix line wrapping in create_resources functionnfagerlund2011-08-181-2/+4
| | | | | | | | | | This is a cosmetic commit improving the line wrapping in the create_resources function's documentation string.
| * Maint: Improve create_resources function's doc stringnfagerlund2011-08-171-10/+20
| | | | | | | | | | | | | | The create_resources function's doc string was not particularly clear and had incorrect markdown formatting. This commit adds a more complete example which demonstrates the necessary hash format, and changes the doc string to a heredoc to simplify escaping.
* | Merge branch '2.7.x'Matt Robinson2011-08-151-8/+10
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.7.x: (25 commits) (#4411) Explain that runinterval = 0 does not mean "never run" Maint: Fix missing option text in puppet agent and arrange options alphabetically (#8302) Improve documentation of exec providers (#7853) Clarify and complete docs for the tagmail report processor Maint: Mention that audit metaparameter will accept "all" Maint: Adjust wording for file type's content parameter Maint: Fix poor documentation for versioncmp function. maint: Fix case sensitive require maint: Add inspect app options to help maint: Fix inspect help Increment lib/puppet.rb VERSION string Updated CHANGELOG for 2.7.3rc1 (#4762) Ensure that clients on the moon can successfully connect. Add document outlining preferred contribution methods Add document outlining preferred contribution methods Add document outlining preferred contribution methods Revert "Merge branch 'vcsrepo'" Revert "Merge branch 'vcsrepo'" Updating CHANGELOG for 2.7.2rc3 (#8704) Give better errors for invalid fileserver.conf ... Manually Resolved Conflicts: lib/puppet/parser/functions/versioncmp.rb spec/integration/node/facts_spec.rb
| * Maint: Fix poor documentation for versioncmp function.nfagerlund2011-08-091-6/+9
| | | | | | | | | | | | The versioncmp function's documentation was missing punctuation and was unnecessarily vague. This commit clarifies the return data and makes the documentation more legible at a glance.
| * Merge branch '2.7rc' into 2.7.xMichael Stahnke2011-07-253-0/+78
| |\
| * | (#8032) Add containment to create_resourcesJeff McCune2011-07-101-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this change native resource types declared using the create_resources() function are not contained within the class scope of the function call. As a result, resources were "floating off" in the graph, disconnected from the rest of the relationship edges. With this change, the scope is preserved and native resources are contained by the class the function call is executed from. Reviewed-by: Dan Bode <dan@puppetlabs.com>
* | | (#8814) Update fqdn_rand for ruby 1.9.2 rand bug.Nan Liu2011-08-111-1/+1
| | | | | | | | | | | | | | | | | | Ruby 1.9.2 does not accept a string for rand function, so rand('1') fails even though this works in Ruby 1.8.x and the string is implicitly converted to a number. We added to_i to avoid this bug.
* | | Cleaning up indentation in versoncmp functionLuke Kanies2011-07-151-4/+2
| | | | | | | | | | | | | | | Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* | | Adding []/[]= support to ScopeLuke Kanies2011-07-152-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The interface to scope is much clearer this way anyway, but this is needed to integrate Puppet with Hiera[1]. It just provides hash-like behavior to Scope, which Hiera and others can now easily rely on. I also went through all of the code that used Scope#lookupvar and Scope#setvar and changed it if possible, and at the same time cleaned up a lot of tests that were unnecessarily stubbing (and thus making it difficult to tell if I had actually broken anything). 1 - https://github.com/ripienaar/hiera Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* | | (#8032) Add containment to create_resourcesJeff McCune2011-06-211-5/+6
| |/ |/| | | | | | | | | | | | | | | | | | | | | Without this change native resource types declared using the create_resources() function are not contained within the class scope of the function call. As a result, resources were "floating off" in the graph, disconnected from the rest of the relationship edges. With this change, the scope is preserved and native resources are contained by the class the function call is executed from. Reviewed-by: Dan Bode <dan@puppetlabs.com>
* | Fixed #7481 - Added MIT license to Thomas Bellman's function codeJames Turnbull2011-05-123-0/+78
|/
* (#6830) Fix sha1 to digest/sha1 require issue for Ruby 1.9Matt Robinson2011-04-131-1/+1
| | | | Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
* Refactor en route to #5027 -- remove usestring parameter from lookupvarMarkus Roberts2011-04-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The usestring parameter to lookupvar was objectionable for several reasons; first, it performed a function orthogonal to the main purpose of the method, second its default was the least common value, and third it was causing other code to work for reasons that were not obvious (extlookup). This refactor breaks the value-transforming function out into a seperate method which allows the user to specify the value to be used in lieu of :undef and removes the parameter. The function, Scope#undef_as(default,exp) is written so that it can be used in user code (templates, functions, etc.) if needed. This refactor will introduce a user-visible behaviour change in the case where users were counting on lookupvar to return "" for undefined variables. The best solution is to have them use undef_as, replacing: lookupvar('myvar') with undef_as('',lookupvar('myvar')) (with the option to specify another default value if desired). If this is too objectionable, we could rename the existing lookupvar as raw_lookupvar and define def lookupvar(v) undef_as('',raw_lookupvar(v)) end to restore the present behaviour.
* Fix for #5063 -- explicitly scope internal variable lookupsMarkus Roberts2011-04-122-8/+3
| | | | | When we lookup a global variable / fact from code we should explicitly look in the global scope.
* Merge branch 'feature/2.6.next/5909' of https://github.com/bodepd/puppet ↵Jesse Wolfe2011-03-291-0/+47
|\ | | | | | | into next
| * (5909) Function to dyncamically generate resources.Dan Bode2011-03-161-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function allows you to dynamically generate resources, passing them as a hash to the create_resources function. This was originally written to be used together with an ENC. Resources can be programitally generated as yaml and passed to a class. classes: webserver::instances: instances: instance1: foo: bar instance2: foo: blah Then puppet code can consume the hash parameters and convert then into resources class webserver::instances ( $instances = {} ) { create_resources('webserver::instance', $instances) } Now I can dynamically determine how webserver instances are deployed to nodes by updating the YAML files.
* | (#6830) Fix MD5 handling to work with Ruby 1.9Matt Robinson2011-03-291-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 1.9 you have to require 'digest/md5' instead of just 'md5'. The following irb sessions from each version of Ruby should explain the changes in how MD5 is used between Ruby versions and why this patch was made. ruby-1.9.2-p136 :001 > require 'md5' LoadError: no such file to load -- md5 ruby-1.9.2-p136 :002 > require 'digest/md5' => true ruby-1.9.2-p136 :003 > Digest::MD5.hexdigest('mystring') => "169319501261c644a58610f967e8f9d0" ruby-1.9.2-p136 :004 > Digest::MD5.new('mystring') => #<Digest::MD5: d41d8cd98f00b204e9800998ecf8427e> ruby-1.8.7-p330 :001 > require 'digest/md5' => [] ruby-1.8.7-p330 :002 > require 'md5' => ["MD5"] ruby-1.8.7-p330 :003 > Digest::MD5.hexdigest('mystring') => "169319501261c644a58610f967e8f9d0" ruby-1.8.7-p330 :004 > MD5.new('mystring') => #<MD5: 169319501261c644a58610f967e8f9d0> ruby-1.8.7-p330 :005 > MD5.new('mystring').to_s => "169319501261c644a58610f967e8f9d0" ruby-1.8.7-p330 :006 > Digest::MD5.new('mystring') ArgumentError: wrong number of arguments (1 for 0) Reviewed-by: Jesse Wolfe <jesse@puppetlabs.com>
* (#6270) Fix formatting in split function's doc stringnfagerlund2011-02-091-7/+7
| | | | | | * Repaired a 2-indent/4-indent issue that kept a code block from being recognized * Wrapped literal strings in backticks to format as code and protect from Markdown * Added note about backslashes for escaping metacharacters.
* (#6270) Fix formatting in regsubst function's doc stringnfagerlund2011-02-091-14/+7
| | | | | | * Fixed ULs being interpreted as code blocks * Changed an example for variety. * Turned set of paragraphs inside a LI into a nested list.
* Merge branch 'tickets/2.6.x/5564' into 2.6.nextPaul Berry2011-02-011-3/+6
|\ | | | | | | | | * tickets/2.6.x/5564: Fixed #5564 - Added some more fqdn_rand documentation
| * Fixed #5564 - Added some more fqdn_rand documentationJames Turnbull2011-02-011-3/+6
| | | | | | | | Reviewed-by: Paul Berry <paul@puppetlabs.com>
* | (#5944) Remove documentation of define() when used on nodes, as it is not a ↵nfagerlund2011-01-251-21/+3
| | | | | | | | | | | | supported use of this function. Final patch in this series reviewed by Dan Bode.
* | (#5944) Further edits of inline defined() documentation.nfagerlund2011-01-251-25/+30
| | | | | | | | Fixing use of define/declare; editing for clarity.
* | (#5944) Improve documentation of defined() functionnfagerlund2011-01-251-6/+41
|/ | | | The differences in the way defined() handles different types of entities weren't well-explained. Documentation was also added for the behavior of defined(Node["somenode.domain.com"]).
* Fixed documentation typoJames Turnbull2010-10-011-1/+1
|
* Fixed versioncmp function typoJames Turnbull2010-09-161-1/+1
|
* Documentation updates for Markdown conversionJames Turnbull2010-09-141-3/+3
|
* Fixed extlookup documentation and spacingJames Turnbull2010-08-312-143/+134
|
* Rewrote functions documentation to MarkdownJames Turnbull2010-08-1110-46/+48
|
* added md5 support as requested in ↵Alice Kærast2010-08-031-0/+5
| | | | http://serverfault.com/questions/166199/puppet-md5-sum-of-string
* [#4381] extlookup shouldn't trigger reparses of .pp filesJesse Wolfe2010-08-031-3/+0
| | | | | | | extlookup was adding its data files to the list of watched source files. This causes the .pp manifests to be re-parsed whenever the .csv files change, which is no longer necessary, as the .csv files are already reparsed on every function call.
* [#4370] Fixes extlookup precedence getting overwritten between runsMatt Robinson2010-08-031-10/+6
| | | | | | | | | | | | | | | We found the gsub! in extlookup was actually modifying the value for extlookup_precedence, so the next node to call it just got the interpolated value from the first run. We did two things in the code to prevent this: 1. We returned a dup of the ast string object so that modifying it wouldn’t change puppet’s state. We didn’t do this for all possible return values because we depend on using the original ast array object to do array concatenation 2. We fixed extlookup to not do a destructive gsub Reviewed by: Jesse Wolfe
* extlookup() is a builtinJesse Wolfe2010-07-251-0/+173
| | | | | | This patch promotes extlookup() to being a builtin function. It also adds test and makes some minor tweaks to the code. The behavior of extlookup has been left unchanged.
* Fixes errant Trac references in documentationJames Turnbull2010-07-151-1/+1
|
* Code smell: Two space indentationMarkus Roberts2010-07-0919-331/+331
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Code smell: Avoid needless decorationsMarkus Roberts2010-07-092-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 704 occurances of (.*)\b([a-z_]+)\(\) with \1\2 3 Examples: The code: ctx = OpenSSL::SSL::SSLContext.new() becomes: ctx = OpenSSL::SSL::SSLContext.new The code: skip() becomes: skip The code: path = tempfile() becomes: path = tempfile * Replaced 31 occurances of ^( *)end *#.* with \1end 3 Examples: The code: becomes: The code: end # Dir.foreach becomes: end The code: end # def becomes: end
* Code smell: Line modifiers are preferred to one-line blocks.Markus Roberts2010-07-095-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 6 occurances of (while .*?) *do$ with The do is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: while line = f.gets do becomes: while line = f.gets The code: while line = shadow.gets do becomes: while line = shadow.gets The code: while wrapper = zeros.pop do becomes: while wrapper = zeros.pop * Replaced 19 occurances of ((if|unless) .*?) *then$ with The then is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then becomes: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } The code: unless defined?(@spec_command) then becomes: unless defined?(@spec_command) The code: if c == ?\n then becomes: if c == ?\n * Replaced 758 occurances of ((?:if|unless|while|until) .*) (.*) end with The one-line form is preferable provided: * The condition is not used to assign a variable * The body line is not already modified * The resulting line is not too long 3 Examples: The code: if Puppet.features.libshadow? has_feature :manages_passwords end becomes: has_feature :manages_passwords if Puppet.features.libshadow? The code: unless (defined?(@current_pool) and @current_pool) @current_pool = process_zpool_data(get_pool_data) end becomes: @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) The code: if Puppet[:trace] puts detail.backtrace end becomes: puts detail.backtrace if Puppet[:trace]
* Code smell: Use string interpolationMarkus Roberts2010-07-096-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 83 occurances of (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[]) with \1#{\2}" 3 Examples: The code: puts "PUPPET " + status + ": " + process + ", " + state becomes: puts "PUPPET " + status + ": " + process + ", #{state}" The code: puts "PUPPET " + status + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" The code: }.compact.join( "\n" ) + "\n" + t + "]\n" becomes: }.compact.join( "\n" ) + "\n#{t}" + "]\n" * Replaced 21 occurances of (.*)" *[+] *" with \1 3 Examples: The code: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}, #{state}" The code: puts "PUPPET #{status}" + ": #{process}, #{state}" becomes: puts "PUPPET #{status}: #{process}, #{state}" The code: res = self.class.name + ": #{@name}" + "\n" becomes: res = self.class.name + ": #{@name}\n" * Don't use string concatenation to split lines unless they would be very long. Replaced 11 occurances of (.*)(['"]) *[+] *(['"])(.*) with 3 Examples: The code: o.define_head "The check_puppet Nagios plug-in checks that specified " + "Puppet process is running and the state file is no " + becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + The code: o.separator "Mandatory arguments to long options are mandatory for " + "short options too." becomes: o.separator "Mandatory arguments to long options are mandatory for short options too." The code: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + "older than specified interval." becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval." * Replaced no occurances of do (.*?) end with {\1} * Replaced 1488 occurances of "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b) with 20 Examples: The code: args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") becomes: args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") The code: puts "%s" % Puppet.version becomes: puts "#{Puppet.version}" The code: raise "Could not find information for %s" % node becomes: raise "Could not find information for #{node}" The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" The code: Puppet.err "Could not run %s: %s" % [client_class, detail] becomes: Puppet.err "Could not run #{client_class}: #{detail}" The code: raise "Could not find handler for %s" % arg becomes: raise "Could not find handler for #{arg}" The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" The code: raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail becomes: raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" The code: raise "Could not find facts for %s" % Puppet[:certname] becomes: raise "Could not find facts for #{Puppet[:certname]}" The code: raise ArgumentError, "%s is not readable" % path becomes: raise ArgumentError, "#{path} is not readable" The code: raise ArgumentError, "Invalid handler %s" % name becomes: raise ArgumentError, "Invalid handler #{name}" The code: debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] becomes: debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" The code: raise Puppet::Error, "unknown cert type '%s'" % hash[:type] becomes: raise Puppet::Error, "unknown cert type '#{hash[:type]}'" The code: Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] becomes: Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" The code: "Cannot create alias %s: object already exists" % [name] becomes: "Cannot create alias #{name}: object already exists" The code: return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] becomes: return "replacing from source #{metadata.source} with contents #{metadata.checksum}" The code: it "should have a %s parameter" % param do becomes: it "should have a #{param} parameter" do The code: describe "when registring '%s' messages" % log do becomes: describe "when registring '#{log}' messages" do The code: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } becomes: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } The code: assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do becomes: assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
* Code smell: Inconsistent indentation and related formatting issuesMarkus Roberts2010-07-0910-57/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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|
* Fixed require warning documentationJames Turnbull2010-06-241-3/+2
|
* Updated Template documentation linkJames Turnbull2010-02-171-3/+3
|
* Fix to the fix for #3295Markus Roberts2010-02-171-6/+2
| | | | | | The output variable in the inner block wasn't visible in the outer block, and wasn't needed in any case, since the results are returned naturally if you just leave everything alone.
* Fixes #3295 - generate() now sets the working directory to the directory ↵Paul Lathrop2010-02-171-2/+4
| | | | | | containing the specified command. Also adds rspec tests for generate().
* Fixed link typoJames Turnbull2010-04-221-1/+1
|
* Fixed #3384 - Updated broken linkJames Turnbull2010-04-221-3/+3
|
* Removing Resource::Reference classesLuke Kanies2010-02-172-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fixing "require" function to use new class interfaceLuke Kanies2010-02-171-1/+1
| | | | Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Fix #3186 - require function set relationship only on the last classBrice Figureau2010-02-171-1/+1
| | | | | | | | Due to the fact that resource.set_parameter is overwriting the previous set_parameters, we were losing the previous relationships we set there, either in a previous call of require or in the same call. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Fix #3150 - require function doesn't like ::class syntaxBrice Figureau2010-02-171-0/+7
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>