diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-06 20:12:30 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-06 20:12:30 -0500 |
commit | 7abc78ad25979c62b585127a8f2a32c55e96819f (patch) | |
tree | 51cc4c7be632b09025b91100441672d5918bed81 | |
parent | 4212f9c2250377793d6ed636c18c7a8538160366 (diff) | |
download | puppet-7abc78ad25979c62b585127a8f2a32c55e96819f.tar.gz puppet-7abc78ad25979c62b585127a8f2a32c55e96819f.tar.xz puppet-7abc78ad25979c62b585127a8f2a32c55e96819f.zip |
Fixing #795 -- configuration elements now make sure all file paths are fully qualified by prepending the wd to unqualified path names.
-rw-r--r-- | lib/puppet/util/config.rb | 6 | ||||
-rwxr-xr-x | test/util/config.rb | 17 |
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/puppet/util/config.rb b/lib/puppet/util/config.rb index f5cc4bcce..9cdb4cfe3 100644 --- a/lib/puppet/util/config.rb +++ b/lib/puppet/util/config.rb @@ -1137,7 +1137,11 @@ Generated on #{Time.now}. path.shift # remove the leading nil objects = [] - obj = Puppet::TransObject.new(self.value, "file") + path = self.value + unless path =~ /^#{File::SEPARATOR}/ + path = File.join(Dir.getwd, path) + end + obj = Puppet::TransObject.new(path, "file") # Only create directories, or files that are specifically marked to # create. diff --git a/test/util/config.rb b/test/util/config.rb index 137c55d10..f99ad54b4 100755 --- a/test/util/config.rb +++ b/test/util/config.rb @@ -59,6 +59,21 @@ class TestConfig < Test::Unit::TestCase } end + # #795 - when --config=relative, we want to fully expand file paths. + def test_relative_paths_when_to_transportable + config = mkconfig + config.setdefaults :yay, :transtest => ["/what/ever", "yo"] + file = config.element(:transtest) + + # Now override it with a relative path name + config[:transtest] = "here" + + should = File.join(Dir.getwd, "here") + + object = file.to_transportable[0] + assert_equal(should, object.name, "Did not translate relative pathnames to full path names") + end + def test_to_manifest set_configs manifest = nil @@ -79,7 +94,7 @@ class TestConfig < Test::Unit::TestCase trans = interp.compile(node) end assert_nothing_raised("Could not instantiate objects") { - trans.to_type + trans.extract.to_type } end |