Open
Description
Use Case
Sometimes, for backwards compatibility prior to deprecation, it would be useful to change an attribute's name but retain an alias to the old/alternate name. Similarly, sometimes the parameters for the underlying object being managed itself have aliases which should be usable at the Puppet resource level.
Describe the Solution You Would Like
A new optional key for attributes called aliases
which takes one ore more symbols as alternate names. For example:
Puppet::ResourceApi.register_type(
name: 'testy_resource',
docs: 'test resource',
attributes: {
ensure: {
type: 'Enum[present, absent]',
desc: 'Whether this resource should be present or absent on the target system.',
default: 'present',
},
name: {
type: 'String',
desc: 'Description of the purpose for this resource declaration.',
behaviour: :namevar,
},
foo: {
type: 'String',
desc: 'Description of the purpose for this resource declaration.',
aliases: [:bar, :baz],
},
)
Which would then have the following equivalent manifest declarations:
testy_resource { 'some title':
foo => 'bing!',
}
testy_resource { 'some title':
bar => 'bing!',
}
testy_resource { 'some title':
baz => 'bing!',
}
But would fail if you tried to specify either the same attribute, regardless of name/alias, twice in the same resource:
testy_resource { 'some title':
foo => 'boop!',
bar => 'woop!',
}