> I think you nailed the point of complexity there: our current language
> support doesn't do what we need, and kwalify is probably the best
> choice for a validation language right now.
>
> My major concern around this is that separate schema and class make it
> hard for folks to keep them in sync; I know when I was doing Win32
> development and we needed to maintain a separate "export" file next to
> our code, the most common failure was to forget to update that.
>
> I would ideally like to see this integrated as part of typing in the
> language, so you would express constraints when you declare the
> parameters to your class or define. That would give the assurance
> that both were always consistent, and have only one place to view the
> data.
Well one workaround for keeping the file in sync is to have code that
does a comparison on the top level between arguments and the schema
and throw an obvious error if they are not. At least then its caught
at runtime.
But I do feel your sentiments ... Java went through this same exercise
with CMP. In the end I believe they moved a lot of the logic to
annotations inside the Java code to avoid the double file exercise.
You could in theory transfer kwalify-like specification to the
language ... here is a quick hack for discussion:
class bind (
$options => {
type => map,
required => false,
mapping => {
"zone-statistics" => {
type => bool,
desc => "If true, the server will collect statistical data on
all zones"
},
"auth-nxdomain" => {
type => bool,
desc => "If true, then the AA bit is always set on NXDOMAIN
responses, even if the server is not actually authoritative."
},
"allow-query" => {
type => seq,
sequence => { type => str, desc => "Valid IP address",
pattern => '/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/' },
desc => "Specifies which hosts are allowed to receive zone
transfers from the server",
},
}
},
$bind_user => {
type => str,
pattern => '/\w{1,15}/'
description => "OS user that bind runs as",
},
...
) {
# do something ...
}
Of course bind has hundreds of options ... so this would get large ...
but at least its all in one file.
> I nearly said "kwalify is the least worst choice", because aside from
> Rx (http://rx.codesimply.com/) it is one of the few validation
> languages that was both complete enough and simple enough to use. It
> still felt painful to use, though, in the real world.
Rx looks interesting - I haven't seen it before.
On another point ... I can see the need for handling obvious patterns
in a re-usable way like in the example above for IPv4. In kwalify this
would be done with merge mappings:
http://www.kuwata-lab.com/kwalify/ruby/users-guide.02.html#tips-merge
Which allows you to define a type, and use it later (and override
parts of it). Functionality much like this would be nice.
ken.
--
"Join us for PuppetConf, September 22nd and 23rd in Portland, OR:
http://bit.ly/puppetconfsig"
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.