Skip to content

Commit 78fdb4e

Browse files
committed
adds file autorequire
autorequire will add parent directories of the concat_file to the dependency chain. So they can be created in the right order if they do not exist.
1 parent e9ee044 commit 78fdb4e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/puppet/type/concat_file.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ def exists?
8989
end.compact
9090
end
9191

92+
# Copied from puppet's file type
93+
# Autorequire the nearest ancestor directory found in the catalog.
94+
autorequire(:file) do
95+
req = []
96+
path = Pathname.new(self[:path])
97+
if !path.root?
98+
# Start at our parent, to avoid autorequiring ourself
99+
parents = path.parent.enum_for(:ascend)
100+
if found = parents.find { |p| catalog.resource(:file, p.to_s) }
101+
req << found.to_s
102+
end
103+
end
104+
105+
req
106+
end
107+
92108
def should_content
93109
return @generated_content if @generated_content
94110
@generated_content = ""

0 commit comments

Comments
 (0)