R.I.Pienaar
unread,Jul 30, 2015, 10:37:02 AM7/30/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet-users
hello,
I've done a few little things with the type system and really like what it achieves,
was able to find a few bad data items in my hiera data and it saves on a lot of the
super annoying validation function calls.
The syntax though is pretty difficult to use, consider:
define foo(
Enum["present", "absent"] $ensure = "present",
Optional[String] $ssh_authorized_file = undef,
Optional[String] $email = undef,
Optional[Integer] $uid = undef,
Optional[Integer] $gid = undef,
Variant[Boolean, String] $sudoer = false,
Boolean $setup_shell = false,
Boolean $setup_rbenv = false
) {
So this has a few issues for me:
Reading it, I just don't see the property names now, its become a real effort
to read this.
$ssh_authorized_file Optional[String] = undef,
seems better for this use case to me and this is probably going to be the most
often used use case.
This gets much worse when we involve more complex type definitions, I can't imagine
ever using a full on Struct definition here for example it would render it entirely
unreadable and be impossible to maintain
How would you ever fit this into a param declaration and maintain readability:
Struct[{mode => Enum[read, write, update],
path => Optional[String[1]],
NotUndef[owner] => Optional[String[1]]}]
This leads to my 2nd question, I couldn't find a way to make my own abstract
types.
Consider this hypothetical with made up syntax and all:
site.pp:
typedef MyData Struct[{mode => Enum[read, write, update],
path => Optional[String[1]],
NotUndef[owner] => Optional[String[1]]}]
foo.pp:
define foo(Mydata $data) {
this would improve matters a whole lot. Does a typedef like feature exist? I couldn't
find anything and tried a few things but failed
---
R.I.Pienaar