Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

(maint) Syncs up file_concat with concat #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,5 @@ example:

## Limitations

A bug where module will be unable to build correct dependency graph if the manifest contains a resource to recursively purge a parent directory.

Example: [MODULES-2054](https://tickets.puppetlabs.com/browse/MODULES-2054)
~~~
file { '/tmp/bug':
ensure => directory,
purge => true,
recurse => true,
force => true
}

file_concat { 'test' :
path => '/tmp/bug/tester',
tag => 'mytag',
require => File['/tmp/bug']
}

file_fragment { 'test-1':
tag => 'mytag',
content => 'test'
}
~~~

## Development

47 changes: 32 additions & 15 deletions lib/puppet/type/file_concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,9 @@ def decompound(d)
decompound(a[0]) <=> decompound(b[0])
end
else
sorted = content_fragments.sort do |a, b|
def decompound(d)
d.split('___').first
end

decompound(a[0]) <=> decompound(b[0])
sorted = content_fragments.sort_by do |a|
a_order, a_name = a[0].split('__')
[a_order, a_name]
end
end

Expand Down Expand Up @@ -149,19 +146,39 @@ def fragment_content(r)
fragment_content
end

def eval_generate
content = self.should_content
def generate
file_opts = {
:ensure => self[:ensure] == :absent ? :absent : :file,
}

file_opts = {}
file_opts[:ensure] = self[:ensure] == :absent ? :absent : :file
file_opts[:content] = content if !content.nil? and !content.empty?
[:path,
:owner,
:group,
:mode,
:replace,
:backup,
:validate_cmd,
end

[:path, :owner, :group, :mode, :replace, :backup].each do |param|
unless self[param].nil?
file_opts[param] = self[param]
end
metaparams = Puppet::Type.metaparams
excluded_metaparams = [ :before, :notify, :require, :subscribe, :tag ]

metaparams.reject! { |param| excluded_metaparams.include? param }

metaparams.each do |metaparam|
file_opts[metaparam] = self[metaparam] if self[metaparam]
end

[Puppet::Type.type(:file).new(file_opts)]
end

def eval_generate
content = self.should_content

if !content.nil? and !content.empty?
catalog.resource("File[#{self[:path]}]")[:content] = content
end

[ catalog.resource("File[#{self[:path]}]") ]
end
end