Skip to content

Commit 7b7a896

Browse files
committed
(PUP-11763) Converts ctime/mtime to string
Prior to this commit, Puppet's file type returned a file's ctime and mtime (created and modified times) as Time objects. This commit converts those to Strings instead to alleviate issues when those values needed to be used in formats that don't understand Time objects (e.g. YAML).
1 parent d6d631a commit 7b7a896

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

lib/puppet/type/file/ctime.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def retrieve
1010
if stat
1111
current_value = stat.ctime
1212
end
13-
current_value
13+
current_value.to_s
1414
end
1515

1616
validate do |val|

lib/puppet/type/file/mtime.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def retrieve
99
if stat
1010
current_value = stat.mtime
1111
end
12-
current_value
12+
current_value.to_s
1313
end
1414

1515
validate do |val|

spec/unit/type/file/ctime_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@resource[:audit] = [:ctime]
1616

1717
# this .to_resource audit behavior is magical :-(
18-
expect(@resource.to_resource[:ctime]).to eq(Puppet::FileSystem.stat(@filename).ctime)
18+
expect(@resource.to_resource[:ctime]).to eq(Puppet::FileSystem.stat(@filename).ctime.to_s)
1919
end
2020

2121
it "should return absent if auditing an absent file" do

spec/unit/type/file/mtime_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@resource[:audit] = [:mtime]
1616

1717
# this .to_resource audit behavior is magical :-(
18-
expect(@resource.to_resource[:mtime]).to eq(Puppet::FileSystem.stat(@filename).mtime)
18+
expect(@resource.to_resource[:mtime]).to eq(Puppet::FileSystem.stat(@filename).mtime.to_s)
1919
end
2020

2121
it "should return absent if auditing an absent file" do

0 commit comments

Comments
 (0)