Hi, I am playing around with the Puppet 4 Type system and nested hashes. Is it possible to use the Type system on a hash and check sub hashes as Struct?
# nested hashes $hash = { ‘ben’ => { uid => 2204, home => ‘/home/ben’, }, ‘jones’ => { uid => 2205, home => ‘home/jones’, } } # class definition class users ( Hash[String, Struct[{ uid => Integer, home => Pattern[/^\/.*/]}]] $hash, ){ … } # class declaration class { ‘users’: hash => $hash, } In this case I receive the following error: Error: Expected parameter 'hash' of 'Class[Users]' to have type Hash[String, Struct[{'uid'=>Integer, 'home'=>Pattern[/^\/.*/]}]], got Struct[{'ben'=>Struct[{'uid'=>Integer, 'home'=>String}], 'jones'=>Struct[{'uid'=>Integer, 'home'=>String}]}] at /root/hash.pp:16 on node puppetmaster.example.net When using the Struct one needs to know the keys. But the keys may be any arbitrary value. Within class users I could use the keys function and a define and check for the data types within the define. But I thought that the mentioned approach is valid (at least I haven’t found a hint that my approach is not valid). Any help/feedback appreciated, best, Martin -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/9F591C12-8459-4144-9C9D-80EB32616E74%40gmail.com. For more options, visit https://groups.google.com/d/optout.