language-puppet icon indicating copy to clipboard operation
language-puppet copied to clipboard

No error when using unknow var in exported resources

Open PierreR opened this issue 9 years ago • 3 comments

For instance, given

class foo {
  @@bar { "bar":
    test => "test"
  }
}
define bar (
  $test = undefined,
){
  notify { "${tst}":}
}

puppetresources won't give any signal that tst is misspelled.

PierreR avatar Apr 06 '16 09:04 PierreR

Actually even this is not failing:

  @@bar { "bar":
    unknown => "test"
  }

PierreR avatar Apr 06 '16 09:04 PierreR

The second case can be fixed with relative ease.

For the first case, it would require interpreting the bar define, which will be annoying (state would need to be restored after the interpretation), and won't work in many cases anyway. The exported resource is allowed to use context that is not existent on the current node (such as requiring resources that are only on the collecting node), and even a completely distinct set of .pp files (even though I suspect nobody does that).

I don't really know what the semantics is with regards to hiera. In that case:

define bar($test) { }

Does $test gets autoloaded from the exporting node context, or from the importing one ?

bartavelle avatar Apr 11 '16 07:04 bartavelle

Does $test gets autoloaded from the exporting node context, or from the importing one ?

IIRC $test is interpreted in the importing (collector) context.

I will do some more testing to see how Puppet behaves exactly in the first case. For instance I think Puppet would reject the compilation at the exporting node (so before collecting) but I am not so sure (and it is a bit surprising).

PierreR avatar Apr 11 '16 08:04 PierreR