Issue #5909 has been updated by Dan Bode.

Status changed from Merged - Pending Release to Closed

This is closed as of 2.7.0
----------------------------------------
Feature #5909: puppet language needs a way to convert from hashes to resources
https://projects.puppetlabs.com/issues/5909

Author: Dan Bode
Status: Closed
Priority: Normal
Assignee: Dan Bode
Category: functions
Target version: 
Affected Puppet version: 
Keywords: accepts function hash
Branch: https://github.com/bodepd/puppet/tree/feature/2.6.next/5909


Now that we support hashes, I propose the following:

We need a way to convert from hashes to resources in puppet language.

I propose a function called accepts

void accepts($type, $hash)

Converts $hash to be instances of the $type resource

where hash is a hash of title => {params}

consider the following code example:

<pre>

$users = {
  'dannyboy23' => {'ensure' => 'present'},
  'bobbyflay' => {'ensure' => 'present'}
}

class foo($users={}) {
  accepts('user', $users)
}

class { 'foo':
  users => $users,
}
</pre>

<pre>
# puppet apply --noop hashes.pp  
notice: /User[dannyboy23]/ensure: is absent, should be present (noop)
notice: /User[bobbyflay]/ensure: is absent, should be present (noop)
</pre>




-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to