| It would be nice if I could test if a data type exists. Henrik Lindberg suggested on Slack that this functionality might be easily implemented in the defined() function. The use case is: As a module maintainer I need to support Puppet 5 and 6. If I want to implemented Deferred I need to do the following to ensure Puppet 5 doesn't try to compile the Deferred data type. This would lead to a compile error.
# $serverversion is empty on 'puppet apply' runs. Just use clientversion. |
$_serverversion = get('serverversion') ? { |
undef => $clientversion, |
default => $serverversion, |
} |
|
if versioncmp($clientversion, '6.0') >= 0 and versioncmp($_serverversion, '6.0') >= 0 { |
assert_type(Optional[Variant[String, Deferred]], $content) |
} else { |
assert_type(Optional[String], $content) |
} |
It would be nice if I could do something like this:
if defined('Deferred') { |
assert_type(Optional[Variant[String, Deferred]], $content) |
} else { |
assert_type(Optional[String], $content) |
}
|
It would be especially awesome if you could backport this to Puppet 5  |