[PUP-7852] Simplify definition and override of constants in Object Created: 2017/08/20  Updated: 2017/12/11  Resolved: 2017/09/05

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 5.2.0

Type: New Feature Priority: Normal
Reporter: Henrik Lindberg Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Plan language/executor
Sub-team: Language
Sprint: Tasks Kanban
Release Notes: Not Needed
Release Notes Summary: Part of a larger feature (Pcore) that has not yet been officially released
QA Risk Assessment: No Action


Before this, a constant in an Object required a full specification of an attribute setting kind to constant, and then specifying both value and type. This is in almost all cases excessive and makes simple definition of objects long.

To make constants easier to define - it should be possible to specify constants with just name and value and let the data type of the value determine the constant's data type.

This example:

constants => { size => 10}

is equivalent to the long form:

attributes => { size => { kind => constant, type => Integer, value => 10} }

The two forms are interchangeable.

The inferred data type for the constant is made generic to the base data type. If a more restricted data type is wanted, the long form must be used. When overriding a constant with the same name in a parent type, the constant must be of a compliant type. When using the short form to override, the resulting data type is inherited from the base type. If a narrowing of the type is wanted when overriding the long form must be used.

Comment by Henrik Lindberg [ 2017/08/21 ]

Ping Rick Sherman and Thomas Honey for info

Comment by Kenn Hussey [ 2017/08/24 ]

Henrik Lindberg did this make it through CI yet?

Comment by Kenn Hussey [ 2017/08/31 ]

John Duarte might you be able to help determine whether these changes have cleared CI?

Comment by John Duarte [ 2017/08/31 ]

This has passed the puppet-agent CI pipeline using puppet-agent at SHA a8c304273fab6ff37629c177bdd5c3433ef496cc containing puppet at SHA 8a6d5192a9365b6f712bddcd1671f219217a19aa

Comment by Henrik Lindberg [ 2017/12/11 ]

In Puppet 5.4.0 there are commits mentioning this ticket, but they are really for PUP-7864.

Generated at Mon Dec 16 04:47:57 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.