summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions/validate_hash_spec.rb
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2013-01-02 12:10:43 +0000
committerJeff McCune <jeff@puppetlabs.com>2013-01-09 17:51:12 -0800
commit20e0e0709021b7ba4a819f1324526d98bcb5dcc3 (patch)
tree85d283d806ded7d21a02c0fda4ce8df7ebc9906f /spec/unit/puppet/parser/functions/validate_hash_spec.rb
parentd674190d8e160b74250c514775003569b36d9984 (diff)
Add getparam function to get defined resource parameters
As far as i know there's no other puppet-dsl-like way to get parameter of defined resource, so that's why i implemented getparam function, which takes resource reference and parameter name and returns parameter value. Here's another example why this function is really useful: define config($path, $config_param1, $config_param2) { } define example_resource($config) { $path = getparam($config, "path") notice("Path is $path") } define example_resource2($example_resource, $config = getparam($example_resource, "config")) { $config_param1 = getparam($config, "config_param1") notice("Config parameter is $config_param1") } define example_resource3($example_resource, $config = getparam($example_resource, "config")) { $config_param2 = getparam($config, "config_param2") notice("Config parameter is $config_param2") } class test_getparam { config { "config_instance": path => "/some/config/path", config_param1 => "someconfigtext1", config_param2 => "someconfigtext2", } example_resource { "example_resource_instance": config => Config["config_instance"] } example_resource2 { "example_resource_instance": example_resource => Example_resource["example_resource_instance"] } example_resource3 { "example_resource_instance": example_resource => Example_resource2["example_resource_instance"] } } class { "test_getparam": }
Diffstat (limited to 'spec/unit/puppet/parser/functions/validate_hash_spec.rb')
0 files changed, 0 insertions, 0 deletions