Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-536) Proper datatype parsing and checking #23

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

DavidS
Copy link
Contributor

@DavidS DavidS commented Feb 21, 2018

This uses Puppet4+ pops to parse and check datatypes. This allows types
to use the full range of expressibility when declaring attributes.

@DavidS DavidS force-pushed the pdk-536-puppet4-datatypes branch 2 times, most recently from 2a0e03f to 956fab5 Compare February 21, 2018 15:22
@DavidS DavidS force-pushed the pdk-536-puppet4-datatypes branch from 956fab5 to 0764325 Compare February 21, 2018 15:30
return true if type.instance?(value)

inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
if inferred_type.is_a? Puppet::Pops::Types::PStringType

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeCalculator#infer_set can be rather expensive and the inferred_type is not really of any use unless there's a mismatch so I'd suggest using:

if value.is_a?(String)

instead and move the call to #infer_set down to where the mismatch error is generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.

@DavidS DavidS force-pushed the pdk-536-puppet4-datatypes branch from 0764325 to aa5c466 Compare February 21, 2018 15:55
This uses Puppet4+ pops to parse and check datatypes. This allows types
to use the full range of expressibility when declaring attributes.
@DavidS DavidS force-pushed the pdk-536-puppet4-datatypes branch from aa5c466 to 2ac94e9 Compare February 21, 2018 17:41
@DavidS DavidS merged commit c83271a into puppetlabs:master Feb 21, 2018
@DavidS DavidS deleted the pdk-536-puppet4-datatypes branch February 21, 2018 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants