Issue #17715 has been updated by Lee Lowder.

Status changed from Unreviewed to Needs Decision

This is doing what it is supposed to do, based on my understanding of 
databindings

The order of precedence is supplied parameter when the class is called -> hiera 
-> default from class definition.

What you described is the expected behavior - most of the modules I have 
written rely on this.


----------------------------------------
Bug #17715: Variables with defaults incorrectly looked up in hiera if a value 
is not passed to a class declared like a resource.
https://projects.puppetlabs.com/issues/17715#change-83127

Author: Jon Topper
Status: Needs Decision
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 3.0.1
Keywords: 
Branch: 


Given a puppet manifest like:

<pre>
class test_class ( $test_param = 'foo' ) {
    info( $test_param )
}

node default {
    class { test_class: }
}
</pre>

and a hiera.yaml like

<pre>
---
:backends: - yaml
           - puppet

:logger: console

:hierarchy: - environments/%{fqdn}
            - common
:yaml:
    :datadir: /tmp

:puppet:
    :datasource: data
</pre>

When invoked thus:

<pre>
puppet apply --verbose test.pp --hiera_config ./hiera.yaml 
</pre>

the following warnings occur:

<pre>
Warning: Scope(Class[Test_class]): Could not look up qualified variable 
'data::environments/core.vagrant::test_class::test_param'; class 
data::environments/core.vagrant::test_class could not be found
Warning: Scope(Class[Test_class]): Could not look up qualified variable 
'data::common::test_class::test_param'; class data::common::test_class could 
not be found
Warning: Scope(Class[Test_class]): Could not look up qualified variable 
'fake::data::test_class::test_param'; class fake::data::test_class could not be 
found
</pre>

It looks like this is the hiera code attempting to look up the value of 
test_param in the hiera data.  I believe this is incorrect, and that the 
behaviour should be equivalent to me invoking the class as

<pre>
    class { test_class:
        test_param => 'foo'
    }
</pre>

which doesn't throw the warnings.

TL;DR: if I set a variable's default in the class definition, this shouldn't be 
looked up in hiera if I don't pass it when declaring the class like a resource.


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to