summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/file.rb
Commit message (Collapse)AuthorAgeFilesLines
* Treat Windows absolute paths as absolute pathsJacob Helwig2011-08-191-3/+17
| | | | | | | | | | | | | | | Previously, we only considered files that matched the *nix concept of 'absolute' as being absolute paths. Since absolute paths on Windows look more like URLs with this world-view, we need to specifically look for the Windows absolute paths, and treat them as such. We will still treat *nix absolute paths as absolute on Windows, even though they are actually relative to the "current" drive. We do not currently limit which "style" of absolute path is allowed based on what the agent is. Reviewed-by: Nick Lewis <nick@puppetlabs.com> (cherry picked from commit 568d25ee10effd5e87c57cdc8c24280eabf9cd93)
* Remove cached_attrs from Puppet::Type::FileNick Lewis2011-08-191-9/+14
| | | | | | | | | | | | | | | | | | | | | | | These values needn't be cached_attrs, because they can be managed manually. 'stat' does need to be cached, so that we avoid statting the file for each property we want to check from disk. The 'content' attribute of 'source' also needs to be cached, because it's retrieved from the server, which we certainly don't want to do multiple times. We need a mechanism for invalidating the 'stat' after we've written the file, so we use a special value :needs_stat, which essentially represented "undefined". We use this rather than nil so that we can store a failed stat if it occurs. Because the content and metadata of our source file will never change, there is no need to be able to similarly expire the values of those attributes. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 4b0c847f19d5db81758b5561bdc8196591209ef0) Conflicts: lib/puppet/type/file/source.rb
* (#8268) Require windows drive letters in absolute file pathsJosh Cooper2011-08-191-1/+1
| | | | | | | | | | | When testing whether a file path is absolute, the regexp was only handling POSIX style file paths. This commit requires Windows style file paths to start with a drive letter. A future commit will refacter the various places we do path validation to support both Windows drive letters and UNC paths. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 45ae5b4a9ced26dfcd3e324391f9a26cb02bf93d)
* Maint: Correct docs for filebucket type and file's backup parameternfagerlund2011-08-181-9/+11
| | | | | | | There's a known bug that prevents remote filebucket resources from working unless you set path => false. Until this bug is fixed, the docs should reflect reality as she is played. This commit mentions the bug in both areas where it is relevant.
* Merge branch '2.6.x' into 2.7.xJacob Helwig2011-08-171-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: Reset indirector state after configurer tests. (#8770) Don't fail to set supplementary groups when changing user to root (#8770) Always fully drop privileges when changing user (#8662) Migrate suidmanager test case to rspec (#8740) Do not enumerate files in the root directory. (#3553) Explain that cron resources require time attributes Conflicts: lib/puppet/application/resource.rb test/puppet/tc_suidmanager.rb
| * (#8740) Do not enumerate files in the root directory.Josh Cooper2011-08-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the command 'puppet resource file' would enumerate all files in the root directory, and generate an exception if the file type was not a directory, file, or link. Worse, it would also do this when a file or directory was specified, e.g. 'puppet resource file /etc/hosts'. Ideally, the find method of the ral terminus should not need to call the type's instances class method, instead just creating an instance of the type with the specified name and parameters. However, some types, like package, depend on this behavior. The type walks all providers and all instances that they provide, checking to see if the provider provides an instance with that name, and also warning if another provider provides an instance with the same name. Also, ideally, puppet should not blow up when encountering an unsupported file type, e.g. Unix domain socket, but that would be too big of a change for 2.6.x. This commit changes 'puppet resource file' to return a message saying that the operation is not supported: Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc The change is bit of a hack, as ideally, the file type's instances method could raise an exception when called in a 'search' context, but return an empty array in a 'find' context. But that also would be too big of a change for 2.6.x. This commit also adds spec tests for the resource application and file type, as well as an acceptance test, which creates a Unix domain socket in the root directory, while running 'puppet resource file'. Paired-with: Nick Lewis <nick@puppetlabs.com> Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* | (#7507) Add more 1.9 filtersJosh Cooper2011-05-201-1/+1
| | | | | | | | | | | | Additionally we fixed a scoping issue with the File type. Paired-With: Matt Robinson <matt@puppetlabs.com>
* | Merge branch ↵Jacob Helwig2011-04-221-2/+8
|\ \ | | | | | | | | | | | | | | | | | | 'tickets/2.7.next/6368-files-autorequire-nearest-ancestor-directory' into 2.7.next * tickets/2.7.next/6368-files-autorequire-nearest-ancestor-directory: (#6368) Make the File type autorequire its nearest ancestor directory
| * | (#6368) Make the File type autorequire its nearest ancestor directoryIan Ward Comfort2011-04-221-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The File type will now autorequire the nearest ancestor directory found in the catalog, not just the file's parent directory. This is useful for setting up transitive relationships in cases when a package or other resource creates a large directory hierarchy, e.g. package { 'foo': ensure => present } file { '/var/lib/foo': require => Package['foo'] } This will make File resources at arbitrarily deep levels under /var/lib/foo automatically (transitively) require the foo package. Only the nearest ancestor is autorequired, to prevent explosion of the relationship graph.
* | | Merge branch '2.6.x' into nextMax Martin2011-04-071-9/+10
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: (maint) Indentation fixes (#6490) Add plugin initialization callback system to core Fix #4339 - Locally save the last report to $lastrunreport Fix #4339 - Save a last run report summary to $statedir/last_run_summary.yaml Fixed #3127 - removed legacy debug code Fixed #3127 - Fixed gem selection regex (#5437) Invalidate cached TypeCollection when there was an error parsing (#6937) Adjust formatting of recurse's desc (#6937) Document the recurse parameter of File type. (#6893) Document the cron type in the case of specials. (#5670) Don't trigger refresh from a failed resource Fixed #6554 - Missing $haveftool if/else conditional in install.rb breaking Ruby 1.9 Conflicts (Manually resolved): lib/puppet/application/agent.rb lib/puppet/application/apply.rb lib/puppet/configurer.rb lib/puppet/resource/type_collection.rb lib/puppet/type/file.rb spec/integration/configurer_spec.rb spec/unit/application/agent_spec.rb spec/unit/application/apply_spec.rb spec/unit/configurer_spec.rb spec/unit/indirector/report/yaml_spec.rb spec/unit/resource/type_collection_spec.rb Paired-with: Nick Lewis
| * | (#6937) Adjust formatting of recurse's descnfagerlund2011-04-011-9/+10
| | | | | | | | | | | | | | | | | | Prevous formatting would result in broken Markdown after the docs were generated, as Markdown does not recognize a two-space tab as a syntactical element. This patch also changes the list of values to a bulleted list instead of a code block.
| * | (#6937) Document the recurse parameter of File type.Ben Hughes2011-04-011-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | Update the desc block with information gleaned from #1469 and the code about recurse => remote and other types of recursion. The auto generated documentation was sparse and this is an area that often comes up on the mailing list/IRC.
* | | Merge branch 'feature/next/resource_application_order' into nextMarkus Roberts2011-04-061-12/+2
|\ \ \
| * | | (6911) Refactor to localize eval_generate dependency assumptionsMarkus Roberts2011-03-311-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To implement #6911 we will need to be able to make incremental descisions about order of application based only on the contents of the resource graph and local "working data." This commit begins to pull the needed structure into a method (visit_resources) while, for the moment, maintaining the original semantic. Paired-with: Jesse Wolfe
| * | | (6911) Use normal methods to implement "depthfirst?" testMarkus Roberts2011-03-301-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There was a class instance variable that was used to determine if a resource types's children should be processed before or after the parent, to support the one type (tidy) which did this. Instead, we define a normal function in Type to return false and override it in Tidy to return true. Paired-with: Jesse Wolfe
* | | | (#6937) Document the recurse parameter of File type.Ben Hughes2011-04-011-1/+11
|/ / / | | | | | | | | | | | | | | | | | | | | | Update the desc block with information gleaned from #1469 and the code about recurse => remote and other types of recursion. The auto generated documentation was sparse and this is an area that often comes up on the mailing list/IRC.
* | | (#6820) Fix File class lookup in the file type for Ruby 1.9Matt Robinson2011-03-231-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Was getting the following error when we simply called File.dirname err: Got an uncaught exception of type NoMethodError: undefined method `dirname' for Puppet::Type::File:Class The constant lookup has changed in Ruby 1.9 to look at local scopes first, so we need to make it clearer that File is the Ruby File class and not something scoped in Puppet. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
* | | Merge branch '2.6.x' into nextMatt Robinson2011-03-181-1/+3
|\| | | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: (36 commits) Updated CHANGELOG for 2.6.7rc1 (#5073) Download plugins even if you're filtering on tags Fix #5610: Prevent unnecessary RAL lookups Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next" (#6723) Fix withenv environment restoration bug (#6689) Remove extraneous include of Puppet::Util in InventoryActiveRecord Remove extra trailing whitespace from lib/puppet/resource.rb (#5428) More fully "stub" Puppet::Resource::Reference for use with storedconfigs (#6707) Fix typo in rest_authconfig.rb (#6689) Make inventory_active_record terminus search quickly (#5392) Give a better error when realizing a non-existant resource (#2645) Adding a less-stubby test to verify the "system" attribute's behavior Update CHANGELOG for 2.6.6 maint: Remove serialization of InventoryFact values maint: Rename InventoryHost to InventoryNode Fixed #2645 - Added support for creating system users maint: Remove spec run noise maint:Refactor of mount provider integration tests (#6338) Support searching on metadata in InventoryActiveRecord terminus (#6338) Implement search for InventoryActiveRecord facts terminus ... This merge includes essentially reverting #4904's change to the mount type since tests that came in from 2.6.x specified different behavior and what's correct is not clear to me. I've reopened #4904 and added it to our backlog, and talked to Nigel about the RFC that's currently out on the puppet-users mailing list for a bigger refactor of how the mount provider works. Manually Resolved Conflicts: spec/spec_helper.rb spec/unit/indirector/queue_spec.rb
| * (#6606) Inline docs: Document all autorequire relationshipsnfagerlund2011-03-041-1/+3
| | | | | | | | This patch appends **Autorequires:** notes to the @doc string of every type whose instances can autorequire other resources. This will put autorequire info right on the types reference where it can do the most good.
* | Merge branch '2.6.x' into nextMatt Robinson2011-02-021-25/+15
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.6.x: (46 commits) Augmentation of tests for prior commit Fix to fix for #5755 -- backref serialization issues in zaml Fixed #5564 - Added some more fqdn_rand documentation Fixed #4968 - Updated list of options turned on by --test in documentation (#5061) - allow special hostclass/define variables to be evaluated as defaults. (#6107) Fix an error when auditing a file with empty content Remove already initialized constant warning from file_spec.rb tests (#5566) Treat source only File checksums as syntax errors when used with content Rename variable used in File type validation to be more clear Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types. Remove order dependency when specifying source and checksum on File type Bug #5755 -- ZAML generates extra newline in some hash backreferences. bug #5681 -- code fix to handle AIX mount output Bug #5681 -- parse AIX mount command output. Spec for #5681 to allow parsing of AIX mount output in mount provider Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes Bug #6091 -- test leading double-slash in filenames are allowed. Fixed #6071 - Fixed typo and improved exec path error message Fixed #6061 - Allowed -1 as password min/max age Bug #6061 -- verify that negative {min,max}_password_age are accepted. ... Manually Resolved Conflicts: lib/puppet/util/zaml.rb spec/unit/util/zaml_spec.rb
| * Merge branch 'ticket/2.6.next/3165' into 2.6.nextPaul Berry2011-02-011-19/+2
| |\ | | | | | | | | | | | | * ticket/2.6.next/3165: Fix #3165 Ralsh (bin/puppet resource) can't manage files
| | * Fix #3165 Ralsh (bin/puppet resource) can't manage filesJesse Wolfe2011-01-231-19/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is based on the patch submitted by Owen Smith. File management was being blocked by two problems: an obsolete, broken `instances` method for the file type, and a bug in the way resource/ral handled slashes in resource names. This patch makes two changes to Owen's version: 1) our unit tests caught an unexpected ruby quirk: "text/".split("/") and "text/".split("/", 2) do not return the same values. 2) File.instances now reproduces the old behavior of listing files in the root directory. This is now implemented in terms of the existing file recursion feature.
| * | (#5566) Treat source only File checksums as syntax errors when used with contentJacob Helwig2011-02-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain checksum types (ctime, mtime) only make sense when used with the 'source' File parameter, since there is no way to check them on raw strings. Given the limitations of the current checksumming implementations, it is likely to introduce unexpected behavior when using the 'none' checksum type and either one of the 'source', and 'content' File parameters. Because of this, it is now a syntax error to use a checksum of 'none' with either parameter. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
| * | Rename variable used in File type validation to be more clearJacob Helwig2011-02-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | The 'count' variable is used to keep track of how many 'creator' parameters are set on the Type in order to raise an exception if this is greater than one. Be explicit about this. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
| * | Fixed #6091 - Changed POSIX path matching to allow multiple leading slashesJames Turnbull2011-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266: "Multiple successive slashes are considered to be the same as one slash.", so '//tmp/xxx' is a valid POSIX pathname. Thomas Bellman adds: You should probably read section 3.2 then as well: 3.2 Absolute Pathname A pathname beginning with a single or more than two slashes; see also Pathname. Note that a pathname starting with exactly two slashes is *not* an absolute pathname according to Posix. And 4.11 (Pathname Resolution) says: A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash. Posix has this rule to accomodate DomainOS, which was a Unix- like OS from Apollo, where paths on the form "//foo/bar/gazonk" meant the file "/bar/gazonk" on the machine named "foo". You may recognize this format from URLs, or MS Windows SMB paths (with backslashes instead of forward slashes). This ignores that complication, since none of our supported platforms treat the '//' form as significant. Signed-off-by: James Turnbull <james@lovedthanlost.net> Signed-off-by: Daniel Pittman <daniel@puppetlabs.com> Signed-off-by: Rick Bradley <rick@rickbradley.com>
| * | (#5931) Prevent errors when calling insync? on audited propertiesPaul Berry2011-01-251-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | Created a method safe_insync? which first checks whether the property has a "should" value of nil, and if so returns true. Most insync? methods were already doing this, but a few were not, leading to bugs if a property was being audited but not set. Types should continue to override the insync? method, but callers of insync? should call safe_insync? instead. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
* | Merge branch '2.6.x' into nextNick Lewis2011-01-061-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: Rakefile lib/puppet/resource/type_collection.rb lib/puppet/simple_graph.rb lib/puppet/transaction.rb lib/puppet/transaction/report.rb lib/puppet/util/metric.rb spec/integration/indirector/report/rest_spec.rb spec/spec_specs/runnable_spec.rb spec/unit/configurer_spec.rb spec/unit/indirector_spec.rb spec/unit/transaction/change_spec.rb
| * Implement #5168 and #5169 ctime and mtime are propertiesJesse Wolfe2010-12-201-0/+2
| | | | | | | | | | File ctime and mtime are now implemented as read-only properties, so they can be examined with audit.
* | Merge branch '2.6.x' into nextNick Lewis2010-12-161-1/+2
|\| | | | | | | | | | | | | | | | | Manually Resolved Conflicts: lib/puppet/resource/type_collection.rb spec/unit/configurer_spec.rb spec/unit/indirector/catalog/active_record_spec.rb spec/unit/resource/type_collection_spec.rb spec/unit/transaction/resource_harness_spec.rb
| * Fix #1757 Change file mode representation to octalJesse Wolfe2010-12-081-1/+2
| | | | | | | | | | | | This patch changes the internal representation of a file's mode to a string instead of an integer. This simplifies the problem of displaying the value consistently throughout all of puppet.
* | Maint: Refactor code to use <class>.indirection.<method>Paul Berry2010-11-291-1/+1
|/ | | | | | Replaced uses of the find, search, destroy, and expire methods on model classes with direct calls to the indirection objects. Also removed the old methods that delegated to the indirection object.
* Reformatting documentation from RST to MarkDown (#4509)Jes Fraser2010-08-111-25/+25
| | | | Signed-off-by: Jes Fraser <jes@gadget.geek.nz>
* [#4233] Ruby regexps are not multiline by default, but Resource titles can ↵Jesse Wolfe2010-07-181-1/+1
| | | | | | | | be multiline Puppet allows resource titles to contain newlines. We recently introduced several regexps that were failing on resources with multiline titles.
* Code smell: Two space indentationMarkus Roberts2010-07-091-744/+744
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: Omit needless checks on definedMarkus Roberts2010-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 53 occurances of defined\?\((.+?)\) (?:and|&&) \1( |$) with \1\2 In code like: unless defined? @foo and @foo and bar("baz") "defined? @foo and @foo" can safely be replaced with "@foo": unless @foo and bar("baz") Because: * Both evaluate to false/nil when @foo is not defined * Both evaluate to @foo when @foo is defined 3 Examples: The code: @sync = Sync.new unless defined?(@sync) and @sync becomes: @sync = Sync.new unless @sync The code: unless defined?(@content) and @content becomes: unless @content The code: raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if defined?(@indirection) and @indirection becomes: raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection * Replaced 2 occurances of defined\?\((.+?)\) (?:and|&&) ! *\1.nil\? with !\1.nil? In code like: while defined? @foo and ! @foo.nil? ... "defined? @foo and ! @foo.nil?" can safely be replaced with "! @foo.nil?": while ! @foo.nil? ... Because: * Both evaluate to false/nil when @foo is not defined * Both evaluate to "! @foo.nil?" when @foo is defined 2 Examples: The code: !!(defined?(@value) and ! @value.nil?) becomes: !!(!@value.nil?) The code: self.init unless defined?(@@state) and ! @@state.nil? becomes: self.init unless !@@state.nil?
* Code smell: Avoid explicit returnsMarkus Roberts2010-07-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 583 occurances of (DEF) (LINES) return (.*) end with 3 Examples: The code: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end return filters end becomes: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end filters end The code: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return return_value end becomes: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return_value end The code: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target return fakefile(File::join("data/types/mount", name)) end becomes: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target fakefile(File::join("data/types/mount", name)) end
* Code smell: Booleans are first class values.Markus Roberts2010-07-091-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 2 occurances of def (.*) begin (.*) = Integer\((.*)\) return \2 rescue ArgumentError \2 = nil end if \2 = (.*) return \2 else return false end end with 2 Examples: The code: def validuser?(value) begin number = Integer(value) return number rescue ArgumentError number = nil end if number = uid(value) return number else return false end end becomes: def validuser?(value) Integer(value) rescue uid(value) || false end The code: def validgroup?(value) begin number = Integer(value) return number rescue ArgumentError number = nil end if number = gid(value) return number else return false end end becomes: def validgroup?(value) Integer(value) rescue gid(value) || false end * Replaced 28 occurances of return (.*?) if (.*) return (.*) with 3 Examples: The code: return send(options[:mode]) if [:rdoc, :trac, :markdown].include?(options[:mode]) return other becomes: return[:rdoc, :trac, :markdown].include?(options[:mode]) ? send(options[:mode]) : other The code: return true if known_resource_types.definition(name) return false becomes: return(known_resource_types.definition(name) ? true : false) The code: return :rest if request.protocol == 'https' return Puppet::FileBucket::File.indirection.terminus_class becomes: return(request.protocol == 'https' ? :rest : Puppet::FileBucket::File.indirection.terminus_class) * Replaced no occurances of return (.*?) unless (.*) return (.*) with * Replaced 7 occurances of if (.*) (.*[^:])false else \2true end with 3 Examples: The code: if RUBY_PLATFORM == "i386-mswin32" InstallOptions.ri = false else InstallOptions.ri = true end becomes: InstallOptions.ri = RUBY_PLATFORM != "i386-mswin32" The code: if options[:references].length > 1 with_contents = false else with_contents = true end becomes: with_contents = options[:references].length <= 1 The code: if value == false or value == "" or value == :undef return false else return true end becomes: return (value != false and value != "" and value != :undef) * Replaced 19 occurances of if (.*) (.*[^:])true else \2false end with 3 Examples: The code: if Puppet::Util::Log.level == :debug return true else return false end becomes: return Puppet::Util::Log.level == :debug The code: if satisfies?(*features) return true else return false end becomes: return !!satisfies?(*features) The code: if self.class.parsed_auth_db.has_key?(resource[:name]) return true else return false end becomes: return !!self.class.parsed_auth_db.has_key?(resource[:name]) * Replaced 1 occurance of if ([a-z_]) = (.*) (.*[^:])\1 else \3(.*) end with 1 Example: The code: if c = self.send(@subclassname, method) return c else return nil end becomes: return self.send(@subclassname, method) || nil * Replaced 2 occurances of if (.*) (.*[^:])\1 else \2false end with 2 Examples: The code: if hash[:Local] @local = hash[:Local] else @local = false end becomes: @local = hash[:Local] The code: if hash[:Local] @local = hash[:Local] else @local = false end becomes: @local = hash[:Local] * Replaced 10 occurances of if (.*) (.*[^:])(.*) else \2false end with 3 Examples: The code: if defined?(@isnamevar) return @isnamevar else return false end becomes: return defined?(@isnamevar) && @isnamevar The code: if defined?(@required) return @required else return false end becomes: return defined?(@required) && @required The code: if number = uid(value) return number else return false end becomes: return (number = uid(value)) && number * Replaced no occurances of if (.*) (.*[^:])nil else \2(true) end with * Replaced no occurances of if (.*) (.*[^:])true else \2nil end with * Replaced no occurances of if (.*) (.*[^:])\1 else \2nil end with * Replaced 23 occurances of if (.*) (.*[^:])(.*) else \2nil end with 3 Examples: The code: if node = Puppet::Node.find(hostname) env = node.environment else env = nil end becomes: env = (node = Puppet::Node.find(hostname)) ? node.environment : nil The code: if mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files? return @mounts[MODULES].copy(mod.name, mod.file_directory) else return nil end becomes: return (mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil The code: if hash.include?(:CA) and hash[:CA] @ca = Puppet::SSLCertificates::CA.new() else @ca = nil end becomes: @ca = (hash.include?(:CA) and hash[:CA]) ? Puppet::SSLCertificates::CA.new() : nil
* Code smell: Line modifiers are preferred to one-line blocks.Markus Roberts2010-07-091-30/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-091-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-091-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: Win32 --> MS_windowsMarkus Roberts2010-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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?
* [#4089] Replace internal usage of :check with :auditNick Lewis2010-07-011-2/+2
| | | | | | Per Luke's replacement of :check with :audit, and deprecation of :check, I've replaced all of our internal uses of :check with :audit. Importantly, this silence the deprecation warnings during regular usage from eg. ralsh.
* [#1621] Composite keys for resourcesJesse Wolfe2010-06-211-12/+5
| | | | | | | | | | | | | | | | This patch implements the fundamental pieces of the move to composite keys: * Instead of having a single namevar, we have a non-empty collection of them, and two resources are the same if and only if all of them match. Note that the present situation is a special case of this, where the collection always has exactly one member. * As currently, namevar is determined by the type. * Instead just of inferring the single namevar from the title we let types decompose the title into values for several (perhaps all) of the namevar components; note that the present situation is again a special case of this. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Avoid trying to symlink() on windowsDavid Schmitt2010-02-171-2/+2
|
* Expand file type to be able to handle Win32 and UNC pathsDavid Schmitt2010-02-171-6/+16
| | | | | | | Win32 paths start with a drive letter, a colon and a slash; UNC paths start with two slashes, the name of the server and another slash. Signed-off-by: David Schmitt <david@dasz.at>
* Fix path handlingDavid Schmitt2010-02-171-1/+2
| | | | | *) Use File.expand_path as indicator for being an absolute path *) Use basename instead of parsing the path manually
* Feature #2276 Single Executable: Update docstringsJesse Wolfe2010-02-171-1/+1
| | | | | | | Update documentation strings everywhere to use single-executable notation rather than the old executable names. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
* Fix #3373 - Client side file streamingBrice Figureau2010-02-171-19/+30
| | | | | | | | | | This patch moves file content writing to the content properties and always write (or read) contents by chunks. This reduces drastically puppetd memory consumption when handling large sourced files. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Renamed all references to Reductive Labs to Puppet LabsMarkus Roberts2010-02-171-1/+1
| | | | Find and replace to the rescue...