Skip to content

Commit

Permalink
adds file autorequire
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bmjen committed May 28, 2015
1 parent e9ee044 commit 78fdb4e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/puppet/type/concat_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ def exists?
end.compact
end

# Copied from puppet's file type
# Autorequire the nearest ancestor directory found in the catalog.
autorequire(:file) do
req = []
path = Pathname.new(self[:path])
if !path.root?
# Start at our parent, to avoid autorequiring ourself
parents = path.parent.enum_for(:ascend)
if found = parents.find { |p| catalog.resource(:file, p.to_s) }
req << found.to_s
end
end

req
end

def should_content
return @generated_content if @generated_content
@generated_content = ""
Expand Down

0 comments on commit 78fdb4e

Please sign in to comment.